ChannelPoolSettingsElement.cs 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. //------------------------------------------------------------------------------
  2. // Copyright (c) Microsoft Corporation. All rights reserved.
  3. //------------------------------------------------------------------------------
  4. namespace System.ServiceModel.Configuration
  5. {
  6. using System.ComponentModel;
  7. using System.Configuration;
  8. using System.Runtime;
  9. using System.ServiceModel.Channels;
  10. public sealed partial class ChannelPoolSettingsElement : ServiceModelConfigurationElement
  11. {
  12. public ChannelPoolSettingsElement()
  13. {
  14. }
  15. [ConfigurationProperty(ConfigurationStrings.IdleTimeout, DefaultValue = OneWayDefaults.IdleTimeoutString)]
  16. [TypeConverter(typeof(TimeSpanOrInfiniteConverter))]
  17. [ServiceModelTimeSpanValidator(MinValueString = ConfigurationStrings.TimeSpanZero)]
  18. public TimeSpan IdleTimeout
  19. {
  20. get { return (TimeSpan)base[ConfigurationStrings.IdleTimeout]; }
  21. set { base[ConfigurationStrings.IdleTimeout] = value; }
  22. }
  23. [ConfigurationProperty(ConfigurationStrings.LeaseTimeout, DefaultValue = OneWayDefaults.LeaseTimeoutString)]
  24. [TypeConverter(typeof(TimeSpanOrInfiniteConverter))]
  25. [ServiceModelTimeSpanValidator(MinValueString = ConfigurationStrings.TimeSpanZero)]
  26. public TimeSpan LeaseTimeout
  27. {
  28. get { return (TimeSpan)base[ConfigurationStrings.LeaseTimeout]; }
  29. set { base[ConfigurationStrings.LeaseTimeout] = value; }
  30. }
  31. [ConfigurationProperty(ConfigurationStrings.MaxOutboundChannelsPerEndpoint, DefaultValue = OneWayDefaults.MaxOutboundChannelsPerEndpoint)]
  32. [IntegerValidator(MinValue = 1)]
  33. public int MaxOutboundChannelsPerEndpoint
  34. {
  35. get { return (int)base[ConfigurationStrings.MaxOutboundChannelsPerEndpoint]; }
  36. set { base[ConfigurationStrings.MaxOutboundChannelsPerEndpoint] = value; }
  37. }
  38. internal void ApplyConfiguration(ChannelPoolSettings settings)
  39. {
  40. if (null == settings)
  41. {
  42. throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("settings");
  43. }
  44. settings.IdleTimeout = this.IdleTimeout;
  45. settings.LeaseTimeout = this.LeaseTimeout;
  46. settings.MaxOutboundChannelsPerEndpoint = this.MaxOutboundChannelsPerEndpoint;
  47. }
  48. internal void InitializeFrom(ChannelPoolSettings settings)
  49. {
  50. if (null == settings)
  51. {
  52. throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("settings");
  53. }
  54. SetPropertyValueIfNotDefaultValue(ConfigurationStrings.IdleTimeout, settings.IdleTimeout);
  55. SetPropertyValueIfNotDefaultValue(ConfigurationStrings.LeaseTimeout, settings.LeaseTimeout);
  56. SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxOutboundChannelsPerEndpoint, settings.MaxOutboundChannelsPerEndpoint);
  57. }
  58. internal void CopyFrom(ChannelPoolSettingsElement source)
  59. {
  60. if (null == source)
  61. {
  62. throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("source");
  63. }
  64. this.IdleTimeout = source.IdleTimeout;
  65. this.LeaseTimeout = source.LeaseTimeout;
  66. this.MaxOutboundChannelsPerEndpoint = source.MaxOutboundChannelsPerEndpoint;
  67. }
  68. }
  69. }