NetTcpBindingElement.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 / NetTcpBindingElement.cs / 1 / NetTcpBindingElement.cs

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

namespace System.ServiceModel.Configuration 
{
    using System.ComponentModel; 
    using System.Configuration; 
    using System.ServiceModel;
    using System.Globalization; 
    using System.ServiceModel.Security;
    using System.ServiceModel.Channels;
    using System.Net.Security;
    using System.Net.Sockets; 

    public partial class NetTcpBindingElement : StandardBindingElement 
    { 
        public NetTcpBindingElement(string name)
            : base(name) 
        {
        }

        public NetTcpBindingElement() 
            : this(null)
        { 
        } 

        protected override Type BindingElementType 
        {
            get { return typeof(NetTcpBinding); }
        }
 
        [ConfigurationProperty(ConfigurationStrings.TransactionFlow, DefaultValue = TransactionFlowDefaults.Transactions)]
        public bool TransactionFlow 
        { 
            get {return (bool) base[ConfigurationStrings.TransactionFlow]; }
            set {base[ConfigurationStrings.TransactionFlow] = value; } 
        }

        [ConfigurationProperty(ConfigurationStrings.TransferMode, DefaultValue = ConnectionOrientedTransportDefaults.TransferMode)]
        [ServiceModelEnumValidator(typeof(TransferModeHelper))] 
        public TransferMode TransferMode
        { 
            get { return (TransferMode)base[ConfigurationStrings.TransferMode]; } 
            set { base[ConfigurationStrings.TransferMode] = value; }
        } 

        [ConfigurationProperty(ConfigurationStrings.TransactionProtocol, DefaultValue = TransactionFlowDefaults.TransactionProtocolString)]
        [TypeConverter(typeof(TransactionProtocolConverter))]
        public TransactionProtocol TransactionProtocol 
        {
            get { return (TransactionProtocol)base[ConfigurationStrings.TransactionProtocol]; } 
            set { base[ConfigurationStrings.TransactionProtocol] = value; } 
        }
 
        [ConfigurationProperty(ConfigurationStrings.HostNameComparisonMode, DefaultValue = ConnectionOrientedTransportDefaults.HostNameComparisonMode)]
        [ServiceModelEnumValidator(typeof(HostNameComparisonModeHelper))]
        public HostNameComparisonMode HostNameComparisonMode
        { 
            get {return (HostNameComparisonMode) base[ConfigurationStrings.HostNameComparisonMode]; }
            set {base[ConfigurationStrings.HostNameComparisonMode] = value; } 
        } 

        [ConfigurationProperty(ConfigurationStrings.ListenBacklog, DefaultValue = TcpTransportDefaults.ListenBacklog)] 
        [IntegerValidator(MinValue = 1)]
        public int ListenBacklog
        {
            get { return (int)base[ConfigurationStrings.ListenBacklog]; } 
            set { base[ConfigurationStrings.ListenBacklog] = 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.MaxBufferSize, DefaultValue = TransportDefaults.MaxBufferSize)] 
        [IntegerValidator(MinValue = 1)]
        public int MaxBufferSize 
        {
            get {return (int) base[ConfigurationStrings.MaxBufferSize]; }
            set {base[ConfigurationStrings.MaxBufferSize] = value; }
        } 

        [ConfigurationProperty(ConfigurationStrings.MaxConnections, DefaultValue = ConnectionOrientedTransportDefaults.MaxPendingConnections)] 
        [IntegerValidator(MinValue = 1)] 
        public int MaxConnections
        { 
            get {return (int) base[ConfigurationStrings.MaxConnections]; }
            set {base[ConfigurationStrings.MaxConnections] = 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.PortSharingEnabled, DefaultValue = TcpTransportDefaults.PortSharingEnabled)] 
        public bool PortSharingEnabled
        { 
            get { return (bool)base[ConfigurationStrings.PortSharingEnabled]; } 
            set { base[ConfigurationStrings.PortSharingEnabled] = value; }
        } 

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

        protected internal override void InitializeFrom(Binding binding)
        {
            base.InitializeFrom(binding); 
            NetTcpBinding nptBinding = (NetTcpBinding) binding;
 
            this.TransactionFlow = nptBinding.TransactionFlow; 
            this.TransferMode = nptBinding.TransferMode;
            this.TransactionProtocol = nptBinding.TransactionProtocol; 
            this.HostNameComparisonMode = nptBinding.HostNameComparisonMode;
            this.MaxBufferPoolSize = nptBinding.MaxBufferPoolSize;
            this.MaxBufferSize = nptBinding.MaxBufferSize;
            this.MaxConnections = nptBinding.MaxConnections; 
            this.MaxReceivedMessageSize = nptBinding.MaxReceivedMessageSize;
            this.ListenBacklog = nptBinding.ListenBacklog; 
            this.ReliableSession.InitializeFrom(nptBinding.ReliableSession); 
            this.Security.InitializeFrom(nptBinding.Security);
            this.ReaderQuotas.InitializeFrom(nptBinding.ReaderQuotas); 
        }

        protected override void OnApplyConfiguration(Binding binding)
        { 
            NetTcpBinding nptBinding = (NetTcpBinding) binding;
 
            nptBinding.TransactionFlow = this.TransactionFlow; 
            nptBinding.TransferMode = this.TransferMode;
            nptBinding.TransactionProtocol = this.TransactionProtocol; 
            nptBinding.HostNameComparisonMode = this.HostNameComparisonMode;
            nptBinding.ListenBacklog = this.ListenBacklog;
            nptBinding.MaxBufferPoolSize = this.MaxBufferPoolSize;
            PropertyInformationCollection propertyInfo = this.ElementInformation.Properties; 
            if (propertyInfo[ConfigurationStrings.MaxBufferSize].ValueOrigin != PropertyValueOrigin.Default)
            { 
                nptBinding.MaxBufferSize = this.MaxBufferSize; 
            }
            nptBinding.MaxConnections = this.MaxConnections; 
            nptBinding.MaxReceivedMessageSize = this.MaxReceivedMessageSize;
            nptBinding.PortSharingEnabled = this.PortSharingEnabled;
            this.ReliableSession.ApplyConfiguration(nptBinding.ReliableSession);
            this.Security.ApplyConfiguration(nptBinding.Security); 
            this.ReaderQuotas.ApplyConfiguration(nptBinding.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