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


C# Uri.GetIpAddress方法代码示例

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


在下文中一共展示了Uri.GetIpAddress方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetEndPoint

 public static IPEndPoint GetEndPoint(string server)
 {
     const int maxSplits = 2;
     var address = server.Split(':');
     if (address.Count() != maxSplits)
     {
         throw new ArgumentException("server");
     }
     IPAddress ipAddress;
     if (!IPAddress.TryParse(address[0], out ipAddress))
     {
         var uri = new Uri(String.Format("http://{0}", address[0]));
         ipAddress = uri.GetIpAddress(ClientConfiguration.UseInterNetworkV6Addresses);
         if (ipAddress == null)
         {
             throw new ArgumentException("ipAddress");
         }
     }
     int port;
     if (!int.TryParse(address[1], out port))
     {
         throw new ArgumentException("port");
     }
     return new IPEndPoint(ipAddress, port);
 }
开发者ID:RossMerr,项目名称:CouchbaseNetClient,代码行数:25,代码来源:IPEndPointExtensions.cs

示例2: GetIpAddress_DnsEntry_NoDeadlock

        public void GetIpAddress_DnsEntry_NoDeadlock()
        {
            // Using an asynchronous view query within an MVC Web API action causes
            // a deadlock if you wait for the result synchronously.

            var context = new Mock<SynchronizationContext>
            {
                CallBase = true
            };

            SynchronizationContext.SetSynchronizationContext(context.Object);
            try
            {
                var uri = new Uri("http://localhost/");

                uri.GetIpAddress(false);

                // If view queries are incorrectly awaiting on the current SynchronizationContext
                // We will see calls to Post or Send on the mock

                context.Verify(m => m.Post(It.IsAny<SendOrPostCallback>(), It.IsAny<object>()), Times.Never);
                context.Verify(m => m.Send(It.IsAny<SendOrPostCallback>(), It.IsAny<object>()), Times.Never);
            }
            finally
            {
                SynchronizationContext.SetSynchronizationContext(null);
            }
        }
开发者ID:brantburnett,项目名称:couchbase-net-client,代码行数:28,代码来源:UriExtensionsTests.cs

示例3: GetIpAddress_DnsEntry_ReturnsIp

        public void GetIpAddress_DnsEntry_ReturnsIp()
        {
            // Arrange

            var uri = new Uri("http://localhost/");

            // Act

            var result = uri.GetIpAddress(false);

            // Assert

            Assert.AreEqual(new IPAddress(new byte[] {127, 0, 0, 1}), result);
        }
开发者ID:brantburnett,项目名称:couchbase-net-client,代码行数:14,代码来源:UriExtensionsTests.cs

示例4: GetEndPoint

 public static IPEndPoint GetEndPoint(Node node, BucketConfiguration clientConfig, IBucketConfig serverConfig)
 {
     var address = node.Hostname.Split(':').First();
     IPAddress ipAddress;
     if (!IPAddress.TryParse(address, out ipAddress))
     {
         var uri = new Uri(String.Format("http://{0}", address));
         ipAddress = uri.GetIpAddress();
         if (ipAddress == null)
         {
             throw new ArgumentException("ipAddress");
         }
     }
     var port = clientConfig.UseSsl ? node.Ports.SslDirect : node.Ports.Direct;
     return new IPEndPoint(ipAddress, port);
 }
开发者ID:orangeloop,项目名称:couchbase-net-client,代码行数:16,代码来源:IPEndPointExtensions.cs

示例5: When_GetIpAddress_Called_With_IpAddress_Returns_HostIP

 public void When_GetIpAddress_Called_With_IpAddress_Returns_HostIP()
 {
     var uri = new Uri("http://127.0.0.1:8091/pools");
     var ipAddress = uri.GetIpAddress();
     Assert.AreEqual("127.0.0.1", ipAddress.ToString());
 }
开发者ID:orangeloop,项目名称:couchbase-net-client,代码行数:6,代码来源:UriExtensionTests.cs

示例6: When_Hostname_Is_IPAddress_Return_It

 public void When_Hostname_Is_IPAddress_Return_It()
 {
     var uri = new Uri("http://192.168.56.102:8091/pools");
     var ipAddress = uri.GetIpAddress();
     Assert.AreEqual("192.168.56.102", ipAddress.ToString());
 }
开发者ID:orangeloop,项目名称:couchbase-net-client,代码行数:6,代码来源:UriExtensionTests.cs

示例7: When_GetIPAddress_Called_With_LocalHost_Returns_LoopBackIP

 public void When_GetIPAddress_Called_With_LocalHost_Returns_LoopBackIP()
 {
     var uri = new Uri("http://localhost:8091/pools");
     var ipAddress = uri.GetIpAddress();
     Assert.AreEqual("127.0.0.1", ipAddress.ToString());
 }
开发者ID:kendallb,项目名称:couchbase-net-client,代码行数:6,代码来源:UriExtensionTests.cs

示例8: When_GetIpAddress_Called_With_IpAddress_Returns_HostIP

 public void When_GetIpAddress_Called_With_IpAddress_Returns_HostIP()
 {
     var uri = new Uri("http://127.0.0.1:8091/pools");
     var ipAddress = uri.GetIpAddress(ClientConfiguration.UseInterNetworkV6Addresses);
     Assert.AreEqual("127.0.0.1", ipAddress.ToString());
 }
开发者ID:brantburnett,项目名称:couchbase-net-client,代码行数:6,代码来源:UriExtensionTests.cs

示例9: When_Hostname_Is_IPAddress_Return_It

 public void When_Hostname_Is_IPAddress_Return_It()
 {
     var uri = new Uri("http://192.168.56.102:8091/pools");
     var ipAddress = uri.GetIpAddress(ClientConfiguration.UseInterNetworkV6Addresses);
     Assert.AreEqual("192.168.56.102", ipAddress.ToString());
 }
开发者ID:brantburnett,项目名称:couchbase-net-client,代码行数:6,代码来源:UriExtensionTests.cs


注:本文中的System.Uri.GetIpAddress方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。