| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | using System; |
| | | 5 | | using System.Configuration; |
| | | 6 | | using CoreWCF.Channels; |
| | | 7 | | |
| | | 8 | | namespace CoreWCF.Configuration |
| | | 9 | | { |
| | | 10 | | public abstract class ConnectionOrientedTransportElement : TransportElement |
| | | 11 | | { |
| | 2 | 12 | | internal ConnectionOrientedTransportElement() |
| | | 13 | | { |
| | 2 | 14 | | } |
| | | 15 | | |
| | | 16 | | [ConfigurationProperty(ConfigurationStrings.ConnectionBufferSize, DefaultValue = ConnectionOrientedTransportDefa |
| | | 17 | | [IntegerValidator(MinValue = 1)] |
| | | 18 | | public int ConnectionBufferSize |
| | | 19 | | { |
| | 2 | 20 | | get { return (int)base[ConfigurationStrings.ConnectionBufferSize]; } |
| | 0 | 21 | | set { base[ConfigurationStrings.ConnectionBufferSize] = value; } |
| | | 22 | | } |
| | | 23 | | |
| | | 24 | | [ConfigurationProperty(ConfigurationStrings.HostNameComparisonMode, DefaultValue = ConnectionOrientedTransportDe |
| | | 25 | | public HostNameComparisonMode HostNameComparisonMode |
| | | 26 | | { |
| | 2 | 27 | | get { return (HostNameComparisonMode)base[ConfigurationStrings.HostNameComparisonMode]; } |
| | 0 | 28 | | set { base[ConfigurationStrings.HostNameComparisonMode] = value; } |
| | | 29 | | } |
| | | 30 | | |
| | | 31 | | [ConfigurationProperty(ConfigurationStrings.ChannelInitializationTimeout, DefaultValue = ConnectionOrientedTrans |
| | | 32 | | public TimeSpan ChannelInitializationTimeout |
| | | 33 | | { |
| | 2 | 34 | | get { return (TimeSpan)base[ConfigurationStrings.ChannelInitializationTimeout]; } |
| | 0 | 35 | | set { base[ConfigurationStrings.ChannelInitializationTimeout] = value; } |
| | | 36 | | } |
| | | 37 | | |
| | | 38 | | [ConfigurationProperty(ConfigurationStrings.MaxBufferSize, DefaultValue = TransportDefaults.MaxBufferSize)] |
| | | 39 | | [IntegerValidator(MinValue = 1)] |
| | | 40 | | public int MaxBufferSize |
| | | 41 | | { |
| | 1 | 42 | | get { return (int)base[ConfigurationStrings.MaxBufferSize]; } |
| | 0 | 43 | | set { base[ConfigurationStrings.MaxBufferSize] = value; } |
| | | 44 | | } |
| | | 45 | | |
| | | 46 | | [ConfigurationProperty(ConfigurationStrings.MaxPendingConnections, DefaultValue = ConnectionOrientedTransportDef |
| | | 47 | | [IntegerValidator(MinValue = 0)] |
| | | 48 | | public int MaxPendingConnections |
| | | 49 | | { |
| | 3 | 50 | | get { return (int)base[ConfigurationStrings.MaxPendingConnections]; } |
| | 0 | 51 | | set { base[ConfigurationStrings.MaxPendingConnections] = value; } |
| | | 52 | | } |
| | | 53 | | |
| | | 54 | | [ConfigurationProperty(ConfigurationStrings.MaxOutputDelay, DefaultValue = ConnectionOrientedTransportDefaults.M |
| | | 55 | | public TimeSpan MaxOutputDelay |
| | | 56 | | { |
| | 2 | 57 | | get { return (TimeSpan)base[ConfigurationStrings.MaxOutputDelay]; } |
| | 0 | 58 | | set { base[ConfigurationStrings.MaxOutputDelay] = value; } |
| | | 59 | | } |
| | | 60 | | |
| | | 61 | | [ConfigurationProperty(ConfigurationStrings.MaxPendingAccepts, DefaultValue = ConnectionOrientedTransportDefault |
| | | 62 | | [IntegerValidator(MinValue = 0)] |
| | | 63 | | public int MaxPendingAccepts |
| | | 64 | | { |
| | 3 | 65 | | get { return (int)base[ConfigurationStrings.MaxPendingAccepts]; } |
| | 0 | 66 | | set { base[ConfigurationStrings.MaxPendingAccepts] = value; } |
| | | 67 | | } |
| | | 68 | | |
| | | 69 | | [ConfigurationProperty(ConfigurationStrings.TransferMode, DefaultValue = ConnectionOrientedTransportDefaults.Tra |
| | | 70 | | public TransferMode TransferMode |
| | | 71 | | { |
| | 2 | 72 | | get { return (TransferMode)base[ConfigurationStrings.TransferMode]; } |
| | 0 | 73 | | set { base[ConfigurationStrings.TransferMode] = value; } |
| | | 74 | | } |
| | | 75 | | |
| | | 76 | | public override void ApplyConfiguration(BindingElement bindingElement) |
| | | 77 | | { |
| | 2 | 78 | | base.ApplyConfiguration(bindingElement); |
| | 2 | 79 | | ConnectionOrientedTransportBindingElement binding = (ConnectionOrientedTransportBindingElement)bindingElemen |
| | 2 | 80 | | binding.ConnectionBufferSize = ConnectionBufferSize; |
| | 2 | 81 | | binding.HostNameComparisonMode = HostNameComparisonMode; |
| | 2 | 82 | | binding.ChannelInitializationTimeout = ChannelInitializationTimeout; |
| | 2 | 83 | | PropertyInformationCollection propertyInfo = ElementInformation.Properties; |
| | 2 | 84 | | if (propertyInfo[ConfigurationStrings.MaxBufferSize].ValueOrigin != PropertyValueOrigin.Default) |
| | | 85 | | { |
| | 1 | 86 | | binding.MaxBufferSize = MaxBufferSize; |
| | | 87 | | } |
| | 2 | 88 | | if (MaxPendingConnections != ConnectionOrientedTransportDefaults.MaxPendingConnectionsConst) |
| | | 89 | | { |
| | 1 | 90 | | binding.MaxPendingConnections = MaxPendingConnections; |
| | | 91 | | } |
| | 2 | 92 | | binding.MaxOutputDelay = MaxOutputDelay; |
| | 2 | 93 | | if (MaxPendingAccepts != ConnectionOrientedTransportDefaults.MaxPendingAcceptsConst) |
| | | 94 | | { |
| | 1 | 95 | | binding.MaxPendingAccepts = MaxPendingAccepts; |
| | | 96 | | } |
| | 2 | 97 | | binding.TransferMode = TransferMode; |
| | 2 | 98 | | } |
| | | 99 | | |
| | | 100 | | public override void CopyFrom(ServiceModelExtensionElement from) |
| | | 101 | | { |
| | 0 | 102 | | base.CopyFrom(from); |
| | | 103 | | |
| | 0 | 104 | | ConnectionOrientedTransportElement source = (ConnectionOrientedTransportElement)from; |
| | 0 | 105 | | ConnectionBufferSize = source.ConnectionBufferSize; |
| | 0 | 106 | | HostNameComparisonMode = source.HostNameComparisonMode; |
| | 0 | 107 | | ChannelInitializationTimeout = source.ChannelInitializationTimeout; |
| | 0 | 108 | | MaxBufferSize = source.MaxBufferSize; |
| | 0 | 109 | | MaxPendingConnections = source.MaxPendingConnections; |
| | 0 | 110 | | MaxOutputDelay = source.MaxOutputDelay; |
| | 0 | 111 | | MaxPendingAccepts = source.MaxPendingAccepts; |
| | 0 | 112 | | TransferMode = source.TransferMode; |
| | 0 | 113 | | } |
| | | 114 | | |
| | | 115 | | protected internal override void InitializeFrom(BindingElement bindingElement) |
| | | 116 | | { |
| | 0 | 117 | | base.InitializeFrom(bindingElement); |
| | 0 | 118 | | ConnectionOrientedTransportBindingElement binding = (ConnectionOrientedTransportBindingElement)bindingElemen |
| | 0 | 119 | | SetPropertyValueIfNotDefaultValue(ConfigurationStrings.ConnectionBufferSize, binding.ConnectionBufferSize); |
| | 0 | 120 | | SetPropertyValueIfNotDefaultValue(ConfigurationStrings.HostNameComparisonMode, binding.HostNameComparisonMod |
| | 0 | 121 | | SetPropertyValueIfNotDefaultValue(ConfigurationStrings.ChannelInitializationTimeout, binding.ChannelInitiali |
| | 0 | 122 | | SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxBufferSize, binding.MaxBufferSize); |
| | 0 | 123 | | if (binding.MaxPendingConnections > 0) |
| | | 124 | | { |
| | 0 | 125 | | ConfigurationProperty maxPendingConnectionsProperty = Properties[ConfigurationStrings.MaxPendingConnecti |
| | 0 | 126 | | SetPropertyValue(maxPendingConnectionsProperty, binding.MaxPendingConnections, /*ignoreLocks = */ false) |
| | | 127 | | } |
| | 0 | 128 | | SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxOutputDelay, binding.MaxOutputDelay); |
| | 0 | 129 | | if (binding.MaxPendingAccepts > 0) |
| | | 130 | | { |
| | 0 | 131 | | ConfigurationProperty maxPendingAcceptsProperty = Properties[ConfigurationStrings.MaxPendingAccepts]; |
| | 0 | 132 | | SetPropertyValue(maxPendingAcceptsProperty, binding.MaxPendingAccepts, /*ignoreLocks = */ false); |
| | | 133 | | } |
| | 0 | 134 | | SetPropertyValueIfNotDefaultValue(ConfigurationStrings.TransferMode, binding.TransferMode); |
| | 0 | 135 | | } |
| | | 136 | | } |
| | | 137 | | } |