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));
        }
        public void Constructor_ShouldSetDefaults()
        {
            var information = new BindingInformation();

            Assert.Equal("*", information.IpAddress);
            Assert.Equal(80, information.Port);
            Assert.Equal(null, information.HostName);
        }
        public void Parse_ReturnsDefaultsWhenPassedEmptyString()
        {
            var information = BindingInformation.Parse(string.Empty);

            Assert.Equal("*", information.IpAddress);
            Assert.Equal(80, information.Port);
            Assert.Equal(null, information.HostName);
        }
        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);
        }
        public void Constructor_ShouldSetDefaults()
        {
            var information = new BindingInformation();

            Assert.Equal("*", information.IpAddress);
            Assert.Equal(80, information.Port);
            Assert.Equal(null, information.HostName);
        }
 public IBindingConfigurer UseIpAddress(string ipAddress)
 {
     return(Configure(binding =>
     {
         var information = BindingInformation.Parse(binding.BindingInformation);
         information.IpAddress = ipAddress;
         binding.BindingInformation = information.ToString();
     }));
 }
 public IBindingConfigurer UseHostName(string hostName)
 {
     return(Configure(binding =>
     {
         var information = BindingInformation.Parse(binding.BindingInformation);
         information.HostName = hostName;
         binding.BindingInformation = information.ToString();
     }));
 }
 public IBindingConfigurer OnPort(int port)
 {
     return(Configure(binding =>
     {
         var information = BindingInformation.Parse(binding.BindingInformation);
         information.Port = port;
         binding.BindingInformation = information.ToString();
     }));
 }
        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);
        }
        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));
 }