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


C# HttpSelfHostConfiguration.ConfigureBinding方法代码示例

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


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

示例1: HttpSelfHostConfiguration_CorrectClientCredentialType_WithX509CertificateValidator_Works

        public void HttpSelfHostConfiguration_CorrectClientCredentialType_WithX509CertificateValidator_Works(string address, HttpBindingSecurityMode mode, HttpClientCredentialType clientCredentialType)
        {
            // Arrange
            HttpBinding binding = new HttpBinding();
            HttpSelfHostConfiguration config = new HttpSelfHostConfiguration(address)
            {
                X509CertificateValidator = new Mock<X509CertificateValidator>().Object
            };

            config.ClientCredentialType = clientCredentialType;

            // Act
            BindingParameterCollection parameters = config.ConfigureBinding(binding);
        }
开发者ID:KevMoore,项目名称:aspnetwebstack,代码行数:14,代码来源:HttpSelfHostConfigurationTest.cs

示例2: HttpSelfHostConfiguration_UserNamePasswordValidator_PropagatesToBinding

        public void HttpSelfHostConfiguration_UserNamePasswordValidator_PropagatesToBinding(string address, HttpBindingSecurityMode mode)
        {
            // Arrange
            HttpBinding binding = new HttpBinding();
            UserNamePasswordValidator validator = new Mock<UserNamePasswordValidator>().Object;
            HttpSelfHostConfiguration config = new HttpSelfHostConfiguration(address)
            {
                UserNamePasswordValidator = validator
            };

            // Act
            BindingParameterCollection parameters = config.ConfigureBinding(binding);

            // Assert
            Assert.NotNull(parameters);
            ServiceCredentials serviceCredentials = parameters.Find<ServiceCredentials>();
            Assert.NotNull(serviceCredentials);
            Assert.Equal(HttpClientCredentialType.Basic, binding.Security.Transport.ClientCredentialType);
            Assert.Equal(mode, binding.Security.Mode);
        }
开发者ID:KevMoore,项目名称:aspnetwebstack,代码行数:20,代码来源:HttpSelfHostConfigurationTest.cs

示例3: HttpSelfHostConfiguration_CorrectClientCredentialType_WithUsernamePasswordValidator_Works

        public void HttpSelfHostConfiguration_CorrectClientCredentialType_WithUsernamePasswordValidator_Works(string address, HttpBindingSecurityMode mode, HttpClientCredentialType clientCredentialType)
        {
            // Arrange
            HttpBinding binding = new HttpBinding();
            HttpSelfHostConfiguration config = new HttpSelfHostConfiguration(address)
            {
                UserNamePasswordValidator = new CustomUsernamePasswordValidator()
            };

            config.ClientCredentialType = clientCredentialType;

            // Act
            BindingParameterCollection parameters = config.ConfigureBinding(binding);
        }
开发者ID:KevMoore,项目名称:aspnetwebstack,代码行数:14,代码来源:HttpSelfHostConfigurationTest.cs

示例4: HttpSelfHostConfiguration_WrongClientCredentialType_WithX509CertificateValidator_Throws

        public void HttpSelfHostConfiguration_WrongClientCredentialType_WithX509CertificateValidator_Throws(string address, HttpBindingSecurityMode mode, HttpClientCredentialType clientCredentialType)
        {
            // Arrange
            HttpBinding binding = new HttpBinding();
            HttpSelfHostConfiguration config = new HttpSelfHostConfiguration(address)
            {
                X509CertificateValidator = new Mock<X509CertificateValidator>().Object
            };

            config.ClientCredentialType = clientCredentialType;

            Assert.Throws<InvalidOperationException>(() =>
            {
                // Act
                BindingParameterCollection parameters = config.ConfigureBinding(binding);
            });
        }
开发者ID:KevMoore,项目名称:aspnetwebstack,代码行数:17,代码来源:HttpSelfHostConfigurationTest.cs

示例5: HttpSelfHostConfiguration_WrongClientCredentialType_WithUsernamePasswordValidator_Throws

        public void HttpSelfHostConfiguration_WrongClientCredentialType_WithUsernamePasswordValidator_Throws(string address, HttpBindingSecurityMode mode, HttpClientCredentialType clientCredentialType)
        {
            // Arrange
            HttpBinding binding = new HttpBinding();
            HttpSelfHostConfiguration config = new HttpSelfHostConfiguration(address)
            {
                UserNamePasswordValidator = new CustomUsernamePasswordValidator()
            };

            config.ClientCredentialType = clientCredentialType;

            Assert.Throws<InvalidOperationException>(() =>
                {
                    // Act
                    BindingParameterCollection parameters = config.ConfigureBinding(binding);
                });
        }
开发者ID:KevMoore,项目名称:aspnetwebstack,代码行数:17,代码来源:HttpSelfHostConfigurationTest.cs

示例6: HttpSelfHostConfiguration_ClientCredentialType_PropagatesToHttpBinding

        public void HttpSelfHostConfiguration_ClientCredentialType_PropagatesToHttpBinding(string address, HttpBindingSecurityMode mode, HttpClientCredentialType clientCredentialType)
        {
            // Arrange
            HttpBinding binding = new HttpBinding();
            HttpSelfHostConfiguration config = new HttpSelfHostConfiguration(address)
            {
                ClientCredentialType = clientCredentialType
            };

            // Act
            BindingParameterCollection parameters = config.ConfigureBinding(binding);

            Assert.Equal(clientCredentialType, binding.Security.Transport.ClientCredentialType);
            Assert.Equal(mode, binding.Security.Mode);
        }
开发者ID:KevMoore,项目名称:aspnetwebstack,代码行数:15,代码来源:HttpSelfHostConfigurationTest.cs

示例7: HttpSelfHostConfiguration_Settings_PropagateToBinding

        public void HttpSelfHostConfiguration_Settings_PropagateToBinding()
        {
            // Arrange
            HttpBinding binding = new HttpBinding();
            binding.ConfigureTransportBindingElement = ConfigureTransportBindingElement;
            HttpSelfHostConfiguration config = new HttpSelfHostConfiguration("http://localhost")
            {
                MaxBufferSize = 10,
                MaxReceivedMessageSize = 11,
                ReceiveTimeout = new TimeSpan(1, 0, 0),
                SendTimeout = new TimeSpan(1, 0, 0),
                TransferMode = TransferMode.StreamedResponse,
                HostNameComparisonMode = HostNameComparisonMode.WeakWildcard
            };

            // Act
            config.ConfigureBinding(binding);

            // Assert
            Assert.Equal(10, binding.MaxBufferSize);
            Assert.Equal(11, binding.MaxReceivedMessageSize);
            Assert.Equal(new TimeSpan(1, 0, 0), binding.ReceiveTimeout);
            Assert.Equal(new TimeSpan(1, 0, 0), binding.SendTimeout);
            Assert.Equal(TransferMode.StreamedResponse, binding.TransferMode);
            Assert.Equal(HostNameComparisonMode.WeakWildcard, binding.HostNameComparisonMode);
            Assert.Equal(Net.AuthenticationSchemes.Ntlm, binding.CreateBindingElements().Find<HttpTransportBindingElement>().AuthenticationScheme);
        }
开发者ID:KevMoore,项目名称:aspnetwebstack,代码行数:27,代码来源:HttpSelfHostConfigurationTest.cs

示例8: HttpSelfHostConfiguration_UseWindowsAuth_PropagatesToHttpBinding

        public void HttpSelfHostConfiguration_UseWindowsAuth_PropagatesToHttpBinding(string address, HttpBindingSecurityMode mode)
        {
            // Arrange
            HttpBinding binding = new HttpBinding();
            HttpSelfHostConfiguration config = new HttpSelfHostConfiguration(address)
            {
                UseWindowsAuthentication = true
            };

            // Act
            BindingParameterCollection parameters = config.ConfigureBinding(binding);

            // Assert
            Assert.NotNull(parameters);
            ServiceCredentials serviceCredentials = parameters.Find<ServiceCredentials>();
            Assert.NotNull(serviceCredentials);
            Assert.Equal(HttpClientCredentialType.Windows, binding.Security.Transport.ClientCredentialType);
            Assert.Equal(mode, binding.Security.Mode);
        }
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:19,代码来源:HttpSelfHostConfigurationTest.cs

示例9: HttpSelfHostConfiguration_Settings_PropagateToBinding

        public void HttpSelfHostConfiguration_Settings_PropagateToBinding()
        {
            // Arrange
            HttpBinding binding = new HttpBinding();
            HttpSelfHostConfiguration config = new HttpSelfHostConfiguration("http://localhost")
            {
                MaxBufferSize = 10,
                MaxReceivedMessageSize = 11,
                TransferMode = TransferMode.StreamedResponse,
                HostNameComparisonMode = HostNameComparisonMode.WeakWildcard
            };

            // Act
            config.ConfigureBinding(binding);

            // Assert
            Assert.Equal(10, binding.MaxBufferSize);
            Assert.Equal(11, binding.MaxReceivedMessageSize);
            Assert.Equal(TransferMode.StreamedResponse, binding.TransferMode);
            Assert.Equal(HostNameComparisonMode.WeakWildcard, binding.HostNameComparisonMode);
        }
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:21,代码来源:HttpSelfHostConfigurationTest.cs


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