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
|
//------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------
namespace System.ServiceModel.Configuration
{
using System.ComponentModel;
using System.Configuration;
using System.Runtime;
using System.ServiceModel;
using System.ServiceModel.Channels;
public abstract partial class ConnectionOrientedTransportElement : TransportElement
{
internal ConnectionOrientedTransportElement()
{
}
[ConfigurationProperty(ConfigurationStrings.ConnectionBufferSize, DefaultValue = ConnectionOrientedTransportDefaults.ConnectionBufferSize)]
[IntegerValidator(MinValue = 1)]
public int ConnectionBufferSize
{
get { return (int)base[ConfigurationStrings.ConnectionBufferSize]; }
set { base[ConfigurationStrings.ConnectionBufferSize] = value; }
}
[ConfigurationProperty(ConfigurationStrings.HostNameComparisonMode, DefaultValue = ConnectionOrientedTransportDefaults.HostNameComparisonMode)]
[ServiceModelEnumValidatorAttribute(typeof(HostNameComparisonModeHelper))]
public HostNameComparisonMode HostNameComparisonMode
{
get { return (HostNameComparisonMode)base[ConfigurationStrings.HostNameComparisonMode]; }
set { base[ConfigurationStrings.HostNameComparisonMode] = value; }
}
[ConfigurationProperty(ConfigurationStrings.ChannelInitializationTimeout, DefaultValue = ConnectionOrientedTransportDefaults.ChannelInitializationTimeoutString)]
[TypeConverter(typeof(TimeSpanOrInfiniteConverter))]
[ServiceModelTimeSpanValidator(MinValueString = ConfigurationStrings.TimeSpanOneTick)]
public TimeSpan ChannelInitializationTimeout
{
get { return (TimeSpan)base[ConfigurationStrings.ChannelInitializationTimeout]; }
set { base[ConfigurationStrings.ChannelInitializationTimeout] = 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.MaxPendingConnections, DefaultValue = ConnectionOrientedTransportDefaults.MaxPendingConnectionsConst)]
[IntegerValidator(MinValue = 0)]
public int MaxPendingConnections
{
get { return (int)base[ConfigurationStrings.MaxPendingConnections]; }
set { base[ConfigurationStrings.MaxPendingConnections] = value; }
}
[ConfigurationProperty(ConfigurationStrings.MaxOutputDelay, DefaultValue = ConnectionOrientedTransportDefaults.MaxOutputDelayString)]
[TypeConverter(typeof(TimeSpanOrInfiniteConverter))]
[ServiceModelTimeSpanValidator(MinValueString = ConfigurationStrings.TimeSpanZero)]
public TimeSpan MaxOutputDelay
{
get { return (TimeSpan)base[ConfigurationStrings.MaxOutputDelay]; }
set { base[ConfigurationStrings.MaxOutputDelay] = value; }
}
[ConfigurationProperty(ConfigurationStrings.MaxPendingAccepts, DefaultValue = ConnectionOrientedTransportDefaults.MaxPendingAcceptsConst)]
[IntegerValidator(MinValue = 0)]
public int MaxPendingAccepts
{
get { return (int)base[ConfigurationStrings.MaxPendingAccepts]; }
set { base[ConfigurationStrings.MaxPendingAccepts] = value; }
}
[ConfigurationProperty(ConfigurationStrings.TransferMode, DefaultValue = ConnectionOrientedTransportDefaults.TransferMode)]
[ServiceModelEnumValidator(typeof(TransferModeHelper))]
public TransferMode TransferMode
{
get { return (TransferMode)base[ConfigurationStrings.TransferMode]; }
set { base[ConfigurationStrings.TransferMode] = value; }
}
public override void ApplyConfiguration(BindingElement bindingElement)
{
base.ApplyConfiguration(bindingElement);
ConnectionOrientedTransportBindingElement binding = (ConnectionOrientedTransportBindingElement)bindingElement;
binding.ConnectionBufferSize = this.ConnectionBufferSize;
binding.HostNameComparisonMode = this.HostNameComparisonMode;
binding.ChannelInitializationTimeout = this.ChannelInitializationTimeout;
PropertyInformationCollection propertyInfo = this.ElementInformation.Properties;
if (propertyInfo[ConfigurationStrings.MaxBufferSize].ValueOrigin != PropertyValueOrigin.Default)
{
binding.MaxBufferSize = this.MaxBufferSize;
}
if (this.MaxPendingConnections != ConnectionOrientedTransportDefaults.MaxPendingConnectionsConst)
{
binding.MaxPendingConnections = this.MaxPendingConnections;
}
binding.MaxOutputDelay = this.MaxOutputDelay;
if (this.MaxPendingAccepts != ConnectionOrientedTransportDefaults.MaxPendingAcceptsConst)
{
binding.MaxPendingAccepts = this.MaxPendingAccepts;
}
binding.TransferMode = this.TransferMode;
}
public override void CopyFrom(ServiceModelExtensionElement from)
{
base.CopyFrom(from);
ConnectionOrientedTransportElement source = (ConnectionOrientedTransportElement)from;
#pragma warning suppress 56506 // [....], base.CopyFrom() validates the argument
this.ConnectionBufferSize = source.ConnectionBufferSize;
this.HostNameComparisonMode = source.HostNameComparisonMode;
this.ChannelInitializationTimeout = source.ChannelInitializationTimeout;
this.MaxBufferSize = source.MaxBufferSize;
this.MaxPendingConnections = source.MaxPendingConnections;
this.MaxOutputDelay = source.MaxOutputDelay;
this.MaxPendingAccepts = source.MaxPendingAccepts;
this.TransferMode = source.TransferMode;
}
protected internal override void InitializeFrom(BindingElement bindingElement)
{
base.InitializeFrom(bindingElement);
ConnectionOrientedTransportBindingElement binding = (ConnectionOrientedTransportBindingElement)bindingElement;
SetPropertyValueIfNotDefaultValue(ConfigurationStrings.ConnectionBufferSize, binding.ConnectionBufferSize);
SetPropertyValueIfNotDefaultValue(ConfigurationStrings.HostNameComparisonMode, binding.HostNameComparisonMode);
SetPropertyValueIfNotDefaultValue(ConfigurationStrings.ChannelInitializationTimeout, binding.ChannelInitializationTimeout);
SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxBufferSize, binding.MaxBufferSize);
if (binding.IsMaxPendingConnectionsSet)
{
ConfigurationProperty maxPendingConnectionsProperty = this.Properties[ConfigurationStrings.MaxPendingConnections];
SetPropertyValue(maxPendingConnectionsProperty, binding.MaxPendingConnections, /*ignoreLocks = */ false);
}
SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxOutputDelay, binding.MaxOutputDelay);
if (binding.IsMaxPendingAcceptsSet)
{
ConfigurationProperty maxPendingAcceptsProperty = this.Properties[ConfigurationStrings.MaxPendingAccepts];
SetPropertyValue(maxPendingAcceptsProperty, binding.MaxPendingAccepts, /*ignoreLocks = */ false);
}
SetPropertyValueIfNotDefaultValue(ConfigurationStrings.TransferMode, binding.TransferMode);
}
}
}
|