1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
|
//------------------------------------------------------------------------------
// 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.ListenBacklogConst)]
[IntegerValidator(MinValue = 0)]
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.MaxPendingConnectionsConst)]
[IntegerValidator(MinValue = 0)]
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;
SetPropertyValueIfNotDefaultValue(ConfigurationStrings.TransactionFlow, nptBinding.TransactionFlow);
SetPropertyValueIfNotDefaultValue(ConfigurationStrings.TransferMode, nptBinding.TransferMode);
SetPropertyValueIfNotDefaultValue(ConfigurationStrings.TransactionProtocol, nptBinding.TransactionProtocol);
SetPropertyValueIfNotDefaultValue(ConfigurationStrings.HostNameComparisonMode, nptBinding.HostNameComparisonMode);
SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxBufferPoolSize, nptBinding.MaxBufferPoolSize);
SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxBufferSize, nptBinding.MaxBufferSize);
if (nptBinding.IsMaxConnectionsSet)
{
ConfigurationProperty maxConnectionsProperty = this.Properties[ConfigurationStrings.MaxConnections];
SetPropertyValue(maxConnectionsProperty, nptBinding.MaxConnections, false /*ignore locks*/);
}
SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxReceivedMessageSize, nptBinding.MaxReceivedMessageSize);
if (nptBinding.IsListenBacklogSet)
{
ConfigurationProperty listenBacklogProperty = this.Properties[ConfigurationStrings.ListenBacklog];
SetPropertyValue(listenBacklogProperty, nptBinding.ListenBacklog, false /*ignore locks*/);
}
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;
PropertyInformationCollection propertyInfo = this.ElementInformation.Properties;
nptBinding.TransactionFlow = this.TransactionFlow;
nptBinding.TransferMode = this.TransferMode;
nptBinding.TransactionProtocol = this.TransactionProtocol;
nptBinding.HostNameComparisonMode = this.HostNameComparisonMode;
if (this.ListenBacklog != TcpTransportDefaults.ListenBacklogConst)
{
nptBinding.ListenBacklog = this.ListenBacklog;
}
nptBinding.MaxBufferPoolSize = this.MaxBufferPoolSize;
if (propertyInfo[ConfigurationStrings.MaxBufferSize].ValueOrigin != PropertyValueOrigin.Default)
{
nptBinding.MaxBufferSize = this.MaxBufferSize;
}
if (this.MaxConnections != 0)
{
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);
}
}
}
|