BasicHttpBindingElement.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Configuration / BasicHttpBindingElement.cs / 1 / BasicHttpBindingElement.cs

                            //------------------------------------------------------------------------------ 
// Copyright (c) Microsoft Corporation.  All rights reserved.
//-----------------------------------------------------------------------------

namespace System.ServiceModel.Configuration 
{
    using System.Configuration; 
    using System.ServiceModel; 
    using System.Globalization;
    using System.ServiceModel.Security; 
    using System.Text;
    using System.ComponentModel;
    using System.ServiceModel.Channels;
 
    public partial class BasicHttpBindingElement : StandardBindingElement
    { 
        public BasicHttpBindingElement(string name) 
            : base(name)
        { 
        }

        public BasicHttpBindingElement()
            : this(null) 
        {
        } 
 
        protected override Type BindingElementType
        { 
            get { return typeof(BasicHttpBinding); }
        }

        [ConfigurationProperty(ConfigurationStrings.AllowCookies, DefaultValue = HttpTransportDefaults.AllowCookies)] 
        public bool AllowCookies
        { 
            get { return (bool)base[ConfigurationStrings.AllowCookies]; } 
            set { base[ConfigurationStrings.AllowCookies] = value; }
 
        }

        [ConfigurationProperty(ConfigurationStrings.BypassProxyOnLocal, DefaultValue = HttpTransportDefaults.BypassProxyOnLocal)]
        public bool BypassProxyOnLocal 
        {
            get {return (bool) base[ConfigurationStrings.BypassProxyOnLocal]; } 
            set {base[ConfigurationStrings.BypassProxyOnLocal] = value; } 
        }
 
        [ConfigurationProperty(ConfigurationStrings.HostNameComparisonMode, DefaultValue = HttpTransportDefaults.HostNameComparisonMode)]
        [ServiceModelEnumValidator(typeof(HostNameComparisonModeHelper))]
        public HostNameComparisonMode HostNameComparisonMode
        { 
            get {return (HostNameComparisonMode) base[ConfigurationStrings.HostNameComparisonMode]; }
            set {base[ConfigurationStrings.HostNameComparisonMode] = value; } 
        } 

        [ConfigurationProperty(ConfigurationStrings.MaxBufferSize, DefaultValue = TransportDefaults.MaxBufferSize)] 
        [IntegerValidator(MinValue = 1)]
        public int MaxBufferSize
        {
            get {return (int)base[ConfigurationStrings.MaxBufferSize]; } 
            set {base[ConfigurationStrings.MaxBufferSize] = value; }
        } 
 
        [ConfigurationProperty(ConfigurationStrings.MaxBufferPoolSize, DefaultValue = TransportDefaults.MaxBufferPoolSize)]
        [LongValidator(MinValue = 0)] 
        public long MaxBufferPoolSize
        {
            get {return (long) base[ConfigurationStrings.MaxBufferPoolSize]; }
            set {base[ConfigurationStrings.MaxBufferPoolSize] = value; } 
        }
 
        [ConfigurationProperty(ConfigurationStrings.MaxReceivedMessageSize, DefaultValue = TransportDefaults.MaxReceivedMessageSize)] 
        [LongValidator(MinValue = 1)]
        public long MaxReceivedMessageSize 
        {
            get { return (long)base[ConfigurationStrings.MaxReceivedMessageSize]; }
            set { base[ConfigurationStrings.MaxReceivedMessageSize] = value; }
        } 

        [ConfigurationProperty(ConfigurationStrings.MessageEncoding, DefaultValue = BasicHttpBindingDefaults.MessageEncoding)] 
        [ServiceModelEnumValidator(typeof(WSMessageEncodingHelper))] 
        public WSMessageEncoding MessageEncoding
        { 
            get {return (WSMessageEncoding) base[ConfigurationStrings.MessageEncoding]; }
            set {base[ConfigurationStrings.MessageEncoding] = value; }
        }
 
        [ConfigurationProperty(ConfigurationStrings.ProxyAddress, DefaultValue = HttpTransportDefaults.ProxyAddress)]
        public Uri ProxyAddress 
        { 
            get {return (Uri) base[ConfigurationStrings.ProxyAddress]; }
            set {base[ConfigurationStrings.ProxyAddress] = value; } 
        }

        [ConfigurationProperty(ConfigurationStrings.ReaderQuotas)]
        public XmlDictionaryReaderQuotasElement ReaderQuotas 
        {
            get { return (XmlDictionaryReaderQuotasElement) base[ConfigurationStrings.ReaderQuotas]; } 
        } 

        [ConfigurationProperty(ConfigurationStrings.Security)] 
        public BasicHttpSecurityElement Security
        {
            get { return (BasicHttpSecurityElement)base[ConfigurationStrings.Security]; }
        } 

        [ConfigurationProperty(ConfigurationStrings.TextEncoding, DefaultValue = TextEncoderDefaults.EncodingString)] 
        [TypeConverter(typeof(EncodingConverter))] 
        public Encoding TextEncoding
        { 
            get {return (Encoding) base[ConfigurationStrings.TextEncoding]; }
            set {base[ConfigurationStrings.TextEncoding] = value; }
        }
 
        [ConfigurationProperty(ConfigurationStrings.TransferMode, DefaultValue = BasicHttpBindingDefaults.TransferMode)]
        [ServiceModelEnumValidator(typeof(TransferModeHelper))] 
        public TransferMode TransferMode 
        {
            get {return (TransferMode) base[ConfigurationStrings.TransferMode]; } 
            set {base[ConfigurationStrings.TransferMode] = value; }
        }

        [ConfigurationProperty(ConfigurationStrings.UseDefaultWebProxy, DefaultValue = HttpTransportDefaults.UseDefaultWebProxy)] 
        public bool UseDefaultWebProxy
        { 
            get { return (bool)base[ConfigurationStrings.UseDefaultWebProxy]; } 
            set { base[ConfigurationStrings.UseDefaultWebProxy] = value; }
        } 

        protected internal override void InitializeFrom(Binding binding)
        {
            base.InitializeFrom(binding); 
            BasicHttpBinding bpBinding = (BasicHttpBinding)binding;
 
            this.BypassProxyOnLocal = bpBinding.BypassProxyOnLocal; 
            this.HostNameComparisonMode = bpBinding.HostNameComparisonMode;
            this.MaxBufferSize = bpBinding.MaxBufferSize; 
            this.MaxBufferPoolSize = bpBinding.MaxBufferPoolSize;
            this.MaxReceivedMessageSize = bpBinding.MaxReceivedMessageSize;
            this.MessageEncoding = bpBinding.MessageEncoding;
            if (bpBinding.ProxyAddress != null) 
                this.ProxyAddress = bpBinding.ProxyAddress;
            this.TextEncoding = bpBinding.TextEncoding; 
            this.TransferMode = bpBinding.TransferMode; 
            this.UseDefaultWebProxy = bpBinding.UseDefaultWebProxy;
            this.AllowCookies = bpBinding.AllowCookies; 
            this.Security.InitializeFrom(bpBinding.Security);
            this.ReaderQuotas.InitializeFrom(bpBinding.ReaderQuotas);
        }
 
        protected override void OnApplyConfiguration(Binding binding)
        { 
            BasicHttpBinding bpBinding = (BasicHttpBinding) binding; 

            bpBinding.BypassProxyOnLocal = this.BypassProxyOnLocal; 
            bpBinding.HostNameComparisonMode = this.HostNameComparisonMode;
            bpBinding.MaxBufferPoolSize = this.MaxBufferPoolSize;
            bpBinding.MaxReceivedMessageSize = this.MaxReceivedMessageSize;
            bpBinding.MessageEncoding = this.MessageEncoding; 
            bpBinding.TextEncoding = this.TextEncoding;
            bpBinding.TransferMode = this.TransferMode; 
            bpBinding.UseDefaultWebProxy = this.UseDefaultWebProxy; 
            bpBinding.AllowCookies = this.AllowCookies;
            if (this.ProxyAddress != null) 
            {
                bpBinding.ProxyAddress = this.ProxyAddress;
            }
            PropertyInformationCollection propertyInfo = this.ElementInformation.Properties; 
            if (propertyInfo[ConfigurationStrings.MaxBufferSize].ValueOrigin != PropertyValueOrigin.Default)
            { 
                bpBinding.MaxBufferSize = this.MaxBufferSize; 
            }
            this.Security.ApplyConfiguration(bpBinding.Security); 
            this.ReaderQuotas.ApplyConfiguration(bpBinding.ReaderQuotas);
        }
    }
 
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK