コード例 #1
0
        public static BindingInformation Parse(string value)
        {
            var bindingInformation = new BindingInformation();

            if (string.IsNullOrEmpty(value))
            {
                return bindingInformation;
            }

            var values = value.Split(':');

            if (values.Length >= 1)
            {
                bindingInformation.IpAddress = values[0];
            }

            if (values.Length >= 2)
            {
                bindingInformation.Port = Convert.ToInt32(values[1]);
            }

            if (values.Length >= 3)
            {
                bindingInformation.HostName = values[2];
            }

            return bindingInformation;
        }
コード例 #2
0
        public static BindingInformation Parse(string value)
        {
            var bindingInformation = new BindingInformation();

            if (string.IsNullOrEmpty(value))
            {
                return(bindingInformation);
            }

            var values = value.Split(':');


            if (values.Length >= 1)
            {
                bindingInformation.IpAddress = values[0];
            }

            if (values.Length >= 2)
            {
                bindingInformation.Port = Convert.ToInt32(values[1]);
            }

            if (values.Length >= 3)
            {
                bindingInformation.HostName = values[2];
            }

            return(bindingInformation);
        }
コード例 #3
0
        public static Binding AddNewWithDefaults(this BindingCollection bindings)
        {
            const string protocol = "http";

            string bindingInformation = BindingInformation.Default().ToString();

            return(bindings.Add(bindingInformation, protocol));
        }
コード例 #4
0
        public void Constructor_ShouldSetDefaults()
        {
            var information = new BindingInformation();

            Assert.Equal("*", information.IpAddress);
            Assert.Equal(80, information.Port);
            Assert.Equal(null, information.HostName);
        }
コード例 #5
0
        public void Parse_ReturnsDefaultsWhenPassedEmptyString()
        {
            var information = BindingInformation.Parse(string.Empty);

            Assert.Equal("*", information.IpAddress);
            Assert.Equal(80, information.Port);
            Assert.Equal(null, information.HostName);
        }
コード例 #6
0
        public void Parse_ConstructsTheBindingCorrectly()
        {
            var information = BindingInformation.Parse("192.168.1.1:8080:mysite.com");

            Assert.Equal("192.168.1.1", information.IpAddress);
            Assert.Equal(8080, information.Port);
            Assert.Equal("mysite.com", information.HostName);
        }
コード例 #7
0
        public void Constructor_ShouldSetDefaults()
        {
            var information = new BindingInformation();

            Assert.Equal("*", information.IpAddress);
            Assert.Equal(80, information.Port);
            Assert.Equal(null, information.HostName);
        }
コード例 #8
0
 public IBindingConfigurer UseIpAddress(string ipAddress)
 {
     return(Configure(binding =>
     {
         var information = BindingInformation.Parse(binding.BindingInformation);
         information.IpAddress = ipAddress;
         binding.BindingInformation = information.ToString();
     }));
 }
コード例 #9
0
 public IBindingConfigurer UseHostName(string hostName)
 {
     return(Configure(binding =>
     {
         var information = BindingInformation.Parse(binding.BindingInformation);
         information.HostName = hostName;
         binding.BindingInformation = information.ToString();
     }));
 }
コード例 #10
0
 public IBindingConfigurer OnPort(int port)
 {
     return(Configure(binding =>
     {
         var information = BindingInformation.Parse(binding.BindingInformation);
         information.Port = port;
         binding.BindingInformation = information.ToString();
     }));
 }
コード例 #11
0
        public void ToString_BuildsTheCorrectStringRepresentingTheBinding()
        {
            var information = new BindingInformation();
            information.Port = 8080;
            information.IpAddress = "192.168.1.1";
            information.HostName = "mysite.com";

            var expected = "192.168.1.1:8080:mysite.com";
            var actual = information.ToString();

            Assert.Equal(expected, actual);
        }
コード例 #12
0
        public void ToString_BuildsTheCorrectStringRepresentingTheBinding()
        {
            var information = new BindingInformation();

            information.Port      = 8080;
            information.IpAddress = "192.168.1.1";
            information.HostName  = "mysite.com";

            var expected = "192.168.1.1:8080:mysite.com";
            var actual   = information.ToString();

            Assert.Equal(expected, actual);
        }
コード例 #13
0
 internal static BindingInformation ToBindingInformation(this Binding binding)
 {
     return(BindingInformation.Parse(binding.BindingInformation));
 }