| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- //------------------------------------------------------------
- // Copyright (c) Microsoft Corporation. All rights reserved.
- //------------------------------------------------------------
- namespace System.ServiceModel.Channels
- {
- using System.ComponentModel;
- using System.Runtime;
- using System.ServiceModel;
- public class ChannelPoolSettings
- {
- TimeSpan idleTimeout;
- TimeSpan leaseTimeout;
- int maxOutboundChannelsPerEndpoint;
- public ChannelPoolSettings()
- {
- this.idleTimeout = OneWayDefaults.IdleTimeout;
- this.leaseTimeout = OneWayDefaults.LeaseTimeout;
- this.maxOutboundChannelsPerEndpoint = OneWayDefaults.MaxOutboundChannelsPerEndpoint;
- }
- ChannelPoolSettings(ChannelPoolSettings poolToBeCloned)
- {
- this.idleTimeout = poolToBeCloned.idleTimeout;
- this.leaseTimeout = poolToBeCloned.leaseTimeout;
- this.maxOutboundChannelsPerEndpoint = poolToBeCloned.maxOutboundChannelsPerEndpoint;
- }
- [DefaultValue(typeof(TimeSpan), OneWayDefaults.IdleTimeoutString)]
- public TimeSpan IdleTimeout
- {
- get
- {
- return this.idleTimeout;
- }
- set
- {
- if (value < TimeSpan.Zero)
- {
- throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("value", value,
- SR.GetString(SR.SFxTimeoutOutOfRange0)));
- }
- if (TimeoutHelper.IsTooLarge(value))
- {
- throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("value", value,
- SR.GetString(SR.SFxTimeoutOutOfRangeTooBig)));
- }
- this.idleTimeout = value;
- }
- }
- [DefaultValue(typeof(TimeSpan), OneWayDefaults.LeaseTimeoutString)]
- public TimeSpan LeaseTimeout
- {
- get
- {
- return leaseTimeout;
- }
- set
- {
- if (value < TimeSpan.Zero)
- {
- throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("value", value,
- SR.GetString(SR.SFxTimeoutOutOfRange0)));
- }
- if (TimeoutHelper.IsTooLarge(value))
- {
- throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("value", value,
- SR.GetString(SR.SFxTimeoutOutOfRangeTooBig)));
- }
- this.leaseTimeout = value;
- }
- }
- [DefaultValue(OneWayDefaults.MaxOutboundChannelsPerEndpoint)]
- public int MaxOutboundChannelsPerEndpoint
- {
- get
- {
- return this.maxOutboundChannelsPerEndpoint;
- }
- set
- {
- if (value <= 0)
- {
- throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("value", value,
- SR.GetString(SR.ValueMustBePositive)));
- }
- this.maxOutboundChannelsPerEndpoint = value;
- }
- }
- internal ChannelPoolSettings Clone()
- {
- return new ChannelPoolSettings(this);
- }
- internal bool IsMatch(ChannelPoolSettings channelPoolSettings)
- {
- if (channelPoolSettings == null)
- {
- return false;
- }
- if (this.idleTimeout != channelPoolSettings.idleTimeout)
- {
- return false;
- }
- if (this.leaseTimeout != channelPoolSettings.leaseTimeout)
- {
- return false;
- }
- if (this.maxOutboundChannelsPerEndpoint != channelPoolSettings.maxOutboundChannelsPerEndpoint)
- {
- return false;
- }
- return true;
- }
- internal bool InternalShouldSerialize()
- {
- return (this.maxOutboundChannelsPerEndpoint != OneWayDefaults.MaxOutboundChannelsPerEndpoint
- || this.idleTimeout != OneWayDefaults.IdleTimeout
- || this.leaseTimeout != OneWayDefaults.LeaseTimeout);
- }
- }
- }
|