當前位置: 首頁>>代碼示例>>C#>>正文


C# URIish.GetPort方法代碼示例

本文整理匯總了C#中NGit.Transport.URIish.GetPort方法的典型用法代碼示例。如果您正苦於以下問題:C# URIish.GetPort方法的具體用法?C# URIish.GetPort怎麽用?C# URIish.GetPort使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在NGit.Transport.URIish的用法示例。


在下文中一共展示了URIish.GetPort方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: TestFileProtocol

 public virtual void TestFileProtocol()
 {
     // as defined by git docu
     URIish u = new URIish("file:///a/b.txt");
     NUnit.Framework.Assert.AreEqual("file", u.GetScheme());
     NUnit.Framework.Assert.IsFalse(u.IsRemote());
     NUnit.Framework.Assert.IsNull(u.GetHost());
     NUnit.Framework.Assert.IsNull(u.GetPass());
     NUnit.Framework.Assert.AreEqual("/a/b.txt", u.GetPath());
     NUnit.Framework.Assert.AreEqual(-1, u.GetPort());
     NUnit.Framework.Assert.IsNull(u.GetUser());
     NUnit.Framework.Assert.AreEqual("b.txt", u.GetHumanishName());
     FilePath tmp = FilePath.CreateTempFile("jgitUnitTest", ".tmp");
     u = new URIish(tmp.ToURI().ToString());
     NUnit.Framework.Assert.AreEqual("file", u.GetScheme());
     NUnit.Framework.Assert.IsFalse(u.IsRemote());
     NUnit.Framework.Assert.IsNull(u.GetHost());
     NUnit.Framework.Assert.IsNull(u.GetPass());
     NUnit.Framework.Assert.IsTrue(u.GetPath().Contains("jgitUnitTest"));
     NUnit.Framework.Assert.AreEqual(-1, u.GetPort());
     NUnit.Framework.Assert.IsNull(u.GetUser());
     NUnit.Framework.Assert.IsTrue(u.GetHumanishName().StartsWith("jgitUnitTest"));
     u = new URIish("file:/a/b.txt");
     NUnit.Framework.Assert.AreEqual("file", u.GetScheme());
     NUnit.Framework.Assert.IsFalse(u.IsRemote());
     NUnit.Framework.Assert.IsNull(u.GetHost());
     NUnit.Framework.Assert.IsNull(u.GetPass());
     NUnit.Framework.Assert.AreEqual("/a/b.txt", u.GetPath());
     NUnit.Framework.Assert.AreEqual(-1, u.GetPort());
     NUnit.Framework.Assert.IsNull(u.GetUser());
     NUnit.Framework.Assert.AreEqual("b.txt", u.GetHumanishName());
 }
開發者ID:nnieslan,項目名稱:ngit,代碼行數:32,代碼來源:URIishTest.cs

示例2: CanHandle

            public override bool CanHandle(URIish uri, Repository local, string remoteName)
            {
                if (uri.GetPath() == null || uri.GetPort() > 0 || uri.GetUser() != null || uri.GetPass
                    () != null || uri.GetHost() != null || (uri.GetScheme() != null && !this.GetSchemes
                    ().Contains(uri.GetScheme())))
                {
                    return false;
                }
                return true;
            }
開發者ID:LunarLanding,項目名稱:ngit,代碼行數:10,代碼來源:TransportBundleFile.cs

示例3: CanHandle

        internal static bool CanHandle(URIish uri, FS fs)
        {
            if (uri.GetHost() != null || uri.GetPort() > 0 || uri.GetUser() != null || uri.GetPass
                () != null || uri.GetPath() == null)
            {
                return false;
            }
            if ("file".Equals(uri.GetScheme()) || uri.GetScheme() == null)
            {
                FilePath f = fs.Resolve(new FilePath("."), uri.GetPath());
                return f.IsFile() || f.GetName().EndsWith(".bundle");
            }
            return false;
        }
開發者ID:nickname100,項目名稱:monodevelop,代碼行數:14,代碼來源:TransportBundleFile.cs

示例4: TestSshProtoWithUserPassAndPort

 public virtual void TestSshProtoWithUserPassAndPort()
 {
     string str = "ssh://user:[email protected]:33/some/p ath";
     URIish u = new URIish(str);
     NUnit.Framework.Assert.AreEqual("ssh", u.GetScheme());
     NUnit.Framework.Assert.IsTrue(u.IsRemote());
     NUnit.Framework.Assert.AreEqual("/some/p ath", u.GetPath());
     NUnit.Framework.Assert.AreEqual("example.com", u.GetHost());
     NUnit.Framework.Assert.AreEqual("user", u.GetUser());
     NUnit.Framework.Assert.AreEqual("pass", u.GetPass());
     NUnit.Framework.Assert.AreEqual(33, u.GetPort());
     NUnit.Framework.Assert.AreEqual(str, u.ToPrivateString());
     NUnit.Framework.Assert.AreEqual(u.SetPass(null).ToPrivateString(), u.ToString());
     NUnit.Framework.Assert.AreEqual(u, new URIish(str));
 }
開發者ID:nnieslan,項目名稱:ngit,代碼行數:15,代碼來源:URIishTest.cs

示例5: TestSshProto

 public virtual void TestSshProto()
 {
     string str = "ssh://example.com/some/p ath";
     URIish u = new URIish(str);
     NUnit.Framework.Assert.AreEqual("ssh", u.GetScheme());
     NUnit.Framework.Assert.IsTrue(u.IsRemote());
     NUnit.Framework.Assert.AreEqual("/some/p ath", u.GetPath());
     NUnit.Framework.Assert.AreEqual("example.com", u.GetHost());
     NUnit.Framework.Assert.AreEqual(-1, u.GetPort());
     NUnit.Framework.Assert.AreEqual(str, u.ToString());
     NUnit.Framework.Assert.AreEqual(u, new URIish(str));
 }
開發者ID:nnieslan,項目名稱:ngit,代碼行數:12,代碼來源:URIishTest.cs

示例6: TestScpStyleWithUser

 public virtual void TestScpStyleWithUser()
 {
     string str = "[email protected]:some/p ath";
     URIish u = new URIish(str);
     NUnit.Framework.Assert.IsNull(u.GetScheme());
     NUnit.Framework.Assert.IsTrue(u.IsRemote());
     NUnit.Framework.Assert.AreEqual("some/p ath", u.GetPath());
     NUnit.Framework.Assert.AreEqual("user", u.GetUser());
     NUnit.Framework.Assert.AreEqual("example.com", u.GetHost());
     NUnit.Framework.Assert.AreEqual(-1, u.GetPort());
     NUnit.Framework.Assert.AreEqual(str, u.ToString());
     NUnit.Framework.Assert.AreEqual(u, new URIish(str));
 }
開發者ID:nnieslan,項目名稱:ngit,代碼行數:13,代碼來源:URIishTest.cs

示例7: TestGitWithUserHome

 public virtual void TestGitWithUserHome()
 {
     string str = "git://example.com/~some/p ath";
     URIish u = new URIish(str);
     NUnit.Framework.Assert.AreEqual("git", u.GetScheme());
     NUnit.Framework.Assert.IsTrue(u.IsRemote());
     NUnit.Framework.Assert.AreEqual("~some/p ath", u.GetPath());
     NUnit.Framework.Assert.AreEqual("example.com", u.GetHost());
     NUnit.Framework.Assert.IsNull(u.GetUser());
     NUnit.Framework.Assert.IsNull(u.GetPass());
     NUnit.Framework.Assert.AreEqual(-1, u.GetPort());
     NUnit.Framework.Assert.AreEqual(str, u.ToPrivateString());
     NUnit.Framework.Assert.AreEqual(u.SetPass(null).ToPrivateString(), u.ToString());
     NUnit.Framework.Assert.AreEqual(u, new URIish(str));
 }
開發者ID:nnieslan,項目名稱:ngit,代碼行數:15,代碼來源:URIishTest.cs

示例8: TestGitProtoWindowsPort

 public virtual void TestGitProtoWindowsPort()
 {
     string str = "git://example.com:338/D:/m y";
     URIish u = new URIish(str);
     NUnit.Framework.Assert.AreEqual("git", u.GetScheme());
     NUnit.Framework.Assert.IsTrue(u.IsRemote());
     NUnit.Framework.Assert.AreEqual("D:/m y", u.GetPath());
     NUnit.Framework.Assert.AreEqual(338, u.GetPort());
     NUnit.Framework.Assert.AreEqual("example.com", u.GetHost());
     NUnit.Framework.Assert.AreEqual(str, u.ToString());
     NUnit.Framework.Assert.AreEqual(u, new URIish(str));
 }
開發者ID:nnieslan,項目名稱:ngit,代碼行數:12,代碼來源:URIishTest.cs

示例9: GetSession

        /// <exception cref="NGit.Errors.TransportException"></exception>
        public override RemoteSession GetSession(URIish uri, CredentialsProvider credentialsProvider
            , FS fs, int tms)
        {
            lock (this)
            {
                string user = uri.GetUser();
                string pass = uri.GetPass();
                string host = uri.GetHost();
                int port = uri.GetPort();
                try
                {
                    if (config == null)
                    {
                        config = OpenSshConfig.Get(fs);
                    }
                    OpenSshConfig.Host hc = config.Lookup(host);
                    host = hc.GetHostName();
                    if (port <= 0)
                    {
                        port = hc.GetPort();
                    }
                    if (user == null)
                    {
                        user = hc.GetUser();
                    }
                    Session session = CreateSession(credentialsProvider, fs, user, pass, host, port,
                        hc);
                    int retries = 0;
                    while (!session.IsConnected() && retries < 3)
                    {
                        try
                        {
                            retries++;
                            session.Connect(tms);
                        }
                        catch (JSchException e)
                        {
                            session.Disconnect();
                            session = null;
                            // if authentication failed maybe credentials changed at the
                            // remote end therefore reset credentials and retry
                            if (credentialsProvider != null && e.InnerException == null && e.Message.Equals("Auth fail"
                                ))
                            {
                                credentialsProvider.Reset(uri);
                                session = CreateSession(credentialsProvider, fs, user, pass, host, port, hc);
                            }
                            else
                            {
                                throw;
                            }
                        }
                    }
                    return new JschSession(session, uri);
                }
                catch (JSchException je)
                {
                    Exception c = je.InnerException;
                    if (c is UnknownHostException)
                    {
                        throw new TransportException(uri, JGitText.Get().unknownHost);
                    }
                    if (c is ConnectException)
                    {
                        throw new TransportException(uri, c.Message);
                    }
                    throw new TransportException(uri, je.Message, je);
                }
            }
        }
開發者ID:kenji-tan,項目名稱:ngit,代碼行數:71,代碼來源:JschConfigSessionFactory.cs

示例10: TestGetSet

        public virtual void TestGetSet()
        {
            string str = "ssh://DOMAIN\\user:[email protected]:33/some/p ath%20";
            URIish u = new URIish(str);
            u = u.SetHost(u.GetHost());
            u = u.SetPass(u.GetPass());
            u = u.SetPort(u.GetPort());
            NUnit.Framework.Assert.AreEqual("ssh", u.GetScheme());
            NUnit.Framework.Assert.IsTrue(u.IsRemote());
            u = u.SetRawPath(u.GetRawPath());
            NUnit.Framework.Assert.AreEqual("/some/p ath%20", u.GetRawPath());
            u = u.SetPath(u.GetPath());
            NUnit.Framework.Assert.AreEqual("/some/p ath ", u.GetRawPath());
            NUnit.Framework.Assert.AreEqual("/some/p ath ", u.GetPath());
            NUnit.Framework.Assert.AreEqual("example.com", u.GetHost());
            NUnit.Framework.Assert.AreEqual("DOMAIN\\user", u.GetUser());
            NUnit.Framework.Assert.AreEqual("pass", u.GetPass());
            NUnit.Framework.Assert.AreEqual(33, u.GetPort());
            NUnit.Framework.Assert.AreEqual("ssh://DOMAIN\\user:[email protected]:33/some/p ath "
                , u.ToPrivateString());
            NUnit.Framework.Assert.AreEqual("ssh://DOMAIN\\user:[email protected]:33/some/p%20ath%20"
                , u.ToPrivateASCIIString());
            NUnit.Framework.Assert.AreEqual(u.SetPass(null).ToPrivateString(), u.ToString());
            NUnit.Framework.Assert.AreEqual(u.SetPass(null).ToPrivateASCIIString(), u.ToASCIIString
                ());
            NUnit.Framework.Assert.AreEqual(u, new URIish(str));
        }
開發者ID:LunarLanding,項目名稱:ngit,代碼行數:27,代碼來源:URIishTest.cs

示例11: TestURIEncodeDecode

        public virtual void TestURIEncodeDecode()
        {
            string str = "ssh://%3ax%25:%40%[email protected]:33/some%c3%a5/p%20a th";
            URIish u = new URIish(str);
            NUnit.Framework.Assert.AreEqual("ssh", u.GetScheme());
            NUnit.Framework.Assert.IsTrue(u.IsRemote());
            NUnit.Framework.Assert.AreEqual("/some%c3%a5/p%20a th", u.GetRawPath());
            NUnit.Framework.Assert.AreEqual("/some\u00e5/p a th", u.GetPath());
            NUnit.Framework.Assert.AreEqual("example.com", u.GetHost());
            NUnit.Framework.Assert.AreEqual(":x%", u.GetUser());
            NUnit.Framework.Assert.AreEqual("@Ax", u.GetPass());
            NUnit.Framework.Assert.AreEqual(33, u.GetPort());
            NUnit.Framework.Assert.AreEqual("ssh://%3ax%25:%[email protected]:33/some%c3%a5/p%20a th"
                , u.ToPrivateString());
            NUnit.Framework.Assert.AreEqual("ssh://%3ax%25:%[email protected]:33/some%c3%a5/p%20a%20th"
                , u.ToPrivateASCIIString());
            NUnit.Framework.Assert.AreEqual(u.SetPass(null).ToPrivateString(), u.ToString());
            NUnit.Framework.Assert.AreEqual(u.SetPass(null).ToPrivateASCIIString(), u.ToASCIIString
                ());
            NUnit.Framework.Assert.AreEqual(u, new URIish(str));
        }
開發者ID:LunarLanding,項目名稱:ngit,代碼行數:21,代碼來源:URIishTest.cs

示例12: TestSshProtoWithEscapedADUserPassAndPort

        public virtual void TestSshProtoWithEscapedADUserPassAndPort()
        {
            string str = "ssh://DOMAIN%5c\u00fcser:[email protected]:33/some/p ath";
            URIish u = new URIish(str);
            NUnit.Framework.Assert.AreEqual("ssh", u.GetScheme());
            NUnit.Framework.Assert.IsTrue(u.IsRemote());
            NUnit.Framework.Assert.AreEqual("/some/p ath", u.GetRawPath());
            NUnit.Framework.Assert.AreEqual("/some/p ath", u.GetPath());
            NUnit.Framework.Assert.AreEqual("example.com", u.GetHost());
            NUnit.Framework.Assert.AreEqual("DOMAIN\\\u00fcser", u.GetUser());
            NUnit.Framework.Assert.AreEqual("pass", u.GetPass());
            NUnit.Framework.Assert.AreEqual(33, u.GetPort());
            NUnit.Framework.Assert.AreEqual("ssh://DOMAIN\\\u00fcser:[email protected]:33/some/p ath"
                , u.ToPrivateString());
            NUnit.Framework.Assert.AreEqual("ssh://DOMAIN\\%c3%bcser:[email protected]:33/some/p%20ath"
                , u.ToPrivateASCIIString());
            NUnit.Framework.Assert.AreEqual(u.SetPass(null).ToPrivateString(), u.ToString());
            NUnit.Framework.Assert.AreEqual(u.SetPass(null).ToPrivateASCIIString(), u.ToASCIIString
                ());
            NUnit.Framework.Assert.AreEqual(u, new URIish(str));
        }
開發者ID:LunarLanding,項目名稱:ngit,代碼行數:21,代碼來源:URIishTest.cs

示例13: TestSshProtoWithUserAndPort

        public virtual void TestSshProtoWithUserAndPort()
        {
            string str = "ssh://[email protected]:33/some/p ath";
            URIish u = new URIish(str);
            NUnit.Framework.Assert.AreEqual("ssh", u.GetScheme());
            NUnit.Framework.Assert.IsTrue(u.IsRemote());
            NUnit.Framework.Assert.AreEqual("/some/p ath", u.GetRawPath());
            NUnit.Framework.Assert.AreEqual("/some/p ath", u.GetPath());
            NUnit.Framework.Assert.AreEqual("example.com", u.GetHost());
            NUnit.Framework.Assert.AreEqual("user", u.GetUser());
            NUnit.Framework.Assert.IsNull(u.GetPass());
            NUnit.Framework.Assert.AreEqual(33, u.GetPort());
            NUnit.Framework.Assert.AreEqual("ssh://[email protected]:33/some/p ath", u.ToString
                ());
            NUnit.Framework.Assert.AreEqual("ssh://[email protected]:33/some/p%20ath", u.ToASCIIString
                ());
            NUnit.Framework.Assert.AreEqual(u, new URIish(str));
        }
開發者ID:LunarLanding,項目名稱:ngit,代碼行數:18,代碼來源:URIishTest.cs

示例14: TestScpStyleWithoutUserAbsolutePath

        public virtual void TestScpStyleWithoutUserAbsolutePath()
        {
            string str = "example.com:/some/p ath";
            URIish u = new URIish(str);
            NUnit.Framework.Assert.IsNull(u.GetScheme());
            NUnit.Framework.Assert.IsTrue(u.IsRemote());
            NUnit.Framework.Assert.AreEqual("/some/p ath", u.GetRawPath());
            NUnit.Framework.Assert.AreEqual("/some/p ath", u.GetPath());
            NUnit.Framework.Assert.AreEqual("example.com", u.GetHost());
            NUnit.Framework.Assert.AreEqual(-1, u.GetPort());
            NUnit.Framework.Assert.AreEqual(str, u.ToString());
            NUnit.Framework.Assert.AreEqual(str, u.ToASCIIString());
            NUnit.Framework.Assert.AreEqual(u, new URIish(str));
        }
開發者ID:LunarLanding,項目名稱:ngit,代碼行數:14,代碼來源:URIishTest.cs

示例15: TestGitProtoUnixPort

        public virtual void TestGitProtoUnixPort()
        {
            string str = "git://example.com:333/home/m y";
            URIish u = new URIish(str);
            NUnit.Framework.Assert.AreEqual("git", u.GetScheme());
            NUnit.Framework.Assert.IsTrue(u.IsRemote());
            NUnit.Framework.Assert.AreEqual("example.com", u.GetHost());
            NUnit.Framework.Assert.AreEqual("/home/m y", u.GetRawPath());
            NUnit.Framework.Assert.AreEqual("/home/m y", u.GetPath());
            NUnit.Framework.Assert.AreEqual(333, u.GetPort());
            NUnit.Framework.Assert.AreEqual("git://example.com:333/home/m y", u.ToString());
            NUnit.Framework.Assert.AreEqual("git://example.com:333/home/m%20y", u.ToASCIIString
                ());
            NUnit.Framework.Assert.AreEqual(u, new URIish(str));
        }
開發者ID:LunarLanding,項目名稱:ngit,代碼行數:15,代碼來源:URIishTest.cs


注:本文中的NGit.Transport.URIish.GetPort方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。