| | | 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 sealed class TcpConnectionPoolSettingsElement : ServiceModelConfigurationElement |
| | | 11 | | { |
| | | 12 | | [ConfigurationProperty(ConfigurationStrings.IdleTimeout, DefaultValue = ConnectionOrientedTransportDefaults.Idle |
| | | 13 | | public TimeSpan IdleTimeout |
| | | 14 | | { |
| | 2 | 15 | | get { return (TimeSpan)base[ConfigurationStrings.IdleTimeout]; } |
| | 0 | 16 | | set { base[ConfigurationStrings.IdleTimeout] = value; } |
| | | 17 | | } |
| | | 18 | | |
| | | 19 | | [ConfigurationProperty(ConfigurationStrings.MaxOutboundConnectionsPerEndpoint, DefaultValue = ConnectionOriented |
| | | 20 | | [IntegerValidator(MinValue = 0)] |
| | | 21 | | public int MaxOutboundConnectionsPerEndpoint |
| | | 22 | | { |
| | 2 | 23 | | get { return (int)base[ConfigurationStrings.MaxOutboundConnectionsPerEndpoint]; } |
| | 0 | 24 | | set { base[ConfigurationStrings.MaxOutboundConnectionsPerEndpoint] = value; } |
| | | 25 | | } |
| | | 26 | | |
| | | 27 | | internal void ApplyConfiguration(TcpConnectionPoolSettings settings) |
| | | 28 | | { |
| | 2 | 29 | | if (null == settings) |
| | | 30 | | { |
| | 0 | 31 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(settings)); |
| | | 32 | | } |
| | | 33 | | |
| | 2 | 34 | | settings.IdleTimeout = IdleTimeout; |
| | 2 | 35 | | settings.MaxOutboundConnectionsPerEndpoint = MaxOutboundConnectionsPerEndpoint; |
| | 2 | 36 | | } |
| | | 37 | | |
| | | 38 | | internal void InitializeFrom(TcpConnectionPoolSettings settings) |
| | | 39 | | { |
| | 0 | 40 | | if (null == settings) |
| | | 41 | | { |
| | 0 | 42 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(settings)); |
| | | 43 | | } |
| | | 44 | | |
| | 0 | 45 | | SetPropertyValueIfNotDefaultValue(ConfigurationStrings.IdleTimeout, settings.IdleTimeout); |
| | 0 | 46 | | SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxOutboundConnectionsPerEndpoint, settings.MaxOutbou |
| | 0 | 47 | | } |
| | | 48 | | |
| | | 49 | | internal void CopyFrom(TcpConnectionPoolSettingsElement source) |
| | | 50 | | { |
| | 0 | 51 | | if (source == null) |
| | | 52 | | { |
| | 0 | 53 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(source)); |
| | | 54 | | } |
| | | 55 | | |
| | | 56 | | //this.GroupName = source.GroupName; |
| | 0 | 57 | | IdleTimeout = source.IdleTimeout; |
| | | 58 | | //this.LeaseTimeout = source.LeaseTimeout; |
| | 0 | 59 | | MaxOutboundConnectionsPerEndpoint = source.MaxOutboundConnectionsPerEndpoint; |
| | 0 | 60 | | } |
| | | 61 | | } |
| | | 62 | | } |