当前位置: 首页>>代码示例>>C#>>正文


C# URIish.GetHost方法代码示例

本文整理汇总了C#中NGit.Transport.URIish.GetHost方法的典型用法代码示例。如果您正苦于以下问题:C# URIish.GetHost方法的具体用法?C# URIish.GetHost怎么用?C# URIish.GetHost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NGit.Transport.URIish的用法示例。


在下文中一共展示了URIish.GetHost方法的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: IsUrlValid

		public override bool IsUrlValid (string url)
		{
			try {
				NGit.Transport.URIish u = new NGit.Transport.URIish (url);
				if (!string.IsNullOrEmpty (u.GetHost ()))
					return true;
			} catch {
			}
			return base.IsUrlValid (url);
		}
开发者ID:okrmartin,项目名称:monodevelop,代码行数:10,代码来源:GitRepository.cs

示例3: 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

示例4: 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

示例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: CanHandle

		internal static bool CanHandle(URIish uri)
		{
			if (!uri.IsRemote())
			{
				return false;
			}
			string scheme = uri.GetScheme();
			if ("ssh".Equals(scheme))
			{
				return true;
			}
			if ("ssh+git".Equals(scheme))
			{
				return true;
			}
			if ("git+ssh".Equals(scheme))
			{
				return true;
			}
			if (scheme == null && uri.GetHost() != null && uri.GetPath() != null)
			{
				return true;
			}
			return false;
		}
开发者ID:nickname100,项目名称:monodevelop,代码行数:25,代码来源:TransportGitSsh.cs

示例9: CanHandle

        /// <summary>Determine if this protocol can handle a particular URI.</summary>
        /// <remarks>
        /// Determine if this protocol can handle a particular URI.
        /// <p/>
        /// Implementations should try to avoid looking at the local filesystem, but
        /// may look at implementation specific configuration options in the remote
        /// block of
        /// <code>local.getConfig()</code>
        /// using
        /// <code>remoteName</code>
        /// if the name
        /// is non-null.
        /// <p/>
        /// The default implementation of this method matches the scheme against
        /// <see cref="GetSchemes()">GetSchemes()</see>
        /// , required fields against
        /// <see cref="GetRequiredFields()">GetRequiredFields()</see>
        /// , and optional fields against
        /// <see cref="GetOptionalFields()">GetOptionalFields()</see>
        /// , returning true only if all of the fields
        /// match the specification.
        /// </remarks>
        /// <param name="uri">address of the Git repository; never null.</param>
        /// <param name="local">
        /// the local repository that will communicate with the other Git
        /// repository. May be null if the caller is only asking about a
        /// specific URI and does not have a local Repository.
        /// </param>
        /// <param name="remoteName">
        /// name of the remote, if the remote as configured in
        /// <code>local</code>
        /// ; otherwise null.
        /// </param>
        /// <returns>true if this protocol can handle this URI; false otherwise.</returns>
        public virtual bool CanHandle(URIish uri, Repository local, string remoteName)
        {
            if (!GetSchemes().IsEmpty() && !GetSchemes().Contains(uri.GetScheme()))
            {
                return false;
            }
            foreach (TransportProtocol.URIishField field in GetRequiredFields())
            {
                switch (field)
                {
                    case TransportProtocol.URIishField.USER:
                    {
                        if (uri.GetUser() == null || uri.GetUser().Length == 0)
                        {
                            return false;
                        }
                        break;
                    }

                    case TransportProtocol.URIishField.PASS:
                    {
                        if (uri.GetPass() == null || uri.GetPass().Length == 0)
                        {
                            return false;
                        }
                        break;
                    }

                    case TransportProtocol.URIishField.HOST:
                    {
                        if (uri.GetHost() == null || uri.GetHost().Length == 0)
                        {
                            return false;
                        }
                        break;
                    }

                    case TransportProtocol.URIishField.PORT:
                    {
                        if (uri.GetPort() <= 0)
                        {
                            return false;
                        }
                        break;
                    }

                    case TransportProtocol.URIishField.PATH:
                    {
                        if (uri.GetPath() == null || uri.GetPath().Length == 0)
                        {
                            return false;
                        }
                        break;
                    }

                    default:
                    {
                        return false;
                        break;
                    }
                }
            }
            ICollection<TransportProtocol.URIishField> canHave = EnumSet.CopyOf(GetRequiredFields
                ());
            Sharpen.Collections.AddAll(canHave, GetOptionalFields());
            if (uri.GetUser() != null && !canHave.Contains(TransportProtocol.URIishField.USER
//.........这里部分代码省略.........
开发者ID:sharwell,项目名称:ngit,代码行数:101,代码来源:TransportProtocol.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.GetHost方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。