1 //------------------------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation. All rights reserved.
3 //------------------------------------------------------------------------------
5 namespace System.ServiceModel.Configuration
7 using System.Configuration;
8 using System.ServiceModel.Dispatcher;
9 using System.ServiceModel.Description;
10 using System.ServiceModel;
12 public sealed partial class ServiceThrottlingElement : BehaviorExtensionElement
14 public ServiceThrottlingElement()
18 [ConfigurationProperty(ConfigurationStrings.MaxConcurrentCalls, DefaultValue = ServiceThrottle.DefaultMaxConcurrentCalls)]
19 [IntegerValidator(MinValue = 1)]
20 public int MaxConcurrentCalls
22 get { return (int)base[ConfigurationStrings.MaxConcurrentCalls]; }
23 set { base[ConfigurationStrings.MaxConcurrentCalls] = value; }
26 [ConfigurationProperty(ConfigurationStrings.MaxConcurrentSessions, DefaultValue = ServiceThrottle.DefaultMaxConcurrentSessions)]
27 [IntegerValidator(MinValue = 1)]
28 public int MaxConcurrentSessions
30 get { return (int)base[ConfigurationStrings.MaxConcurrentSessions]; }
31 set { base[ConfigurationStrings.MaxConcurrentSessions] = value; }
34 [ConfigurationProperty(ConfigurationStrings.MaxConcurrentInstances, DefaultValue = ServiceThrottle.DefaultMaxConcurrentCalls + ServiceThrottle.DefaultMaxConcurrentSessions)]
35 [IntegerValidator(MinValue = 1)]
36 public int MaxConcurrentInstances
38 get { return (int)base[ConfigurationStrings.MaxConcurrentInstances]; }
39 set { base[ConfigurationStrings.MaxConcurrentInstances] = value; }
42 public override void CopyFrom(ServiceModelExtensionElement from)
46 ServiceThrottlingElement source = (ServiceThrottlingElement)from;
47 #pragma warning suppress 56506 //[....]; base.CopyFrom() checks for 'from' being null
48 this.MaxConcurrentCalls = source.MaxConcurrentCalls;
49 this.MaxConcurrentSessions = source.MaxConcurrentSessions;
50 this.MaxConcurrentInstances = source.MaxConcurrentInstances;
53 protected internal override object CreateBehavior()
55 ServiceThrottlingBehavior behavior = new ServiceThrottlingBehavior();
57 PropertyInformationCollection propertyInfo = this.ElementInformation.Properties;
58 if (propertyInfo[ConfigurationStrings.MaxConcurrentCalls].ValueOrigin != PropertyValueOrigin.Default)
60 behavior.MaxConcurrentCalls = this.MaxConcurrentCalls;
63 if (propertyInfo[ConfigurationStrings.MaxConcurrentSessions].ValueOrigin != PropertyValueOrigin.Default)
65 behavior.MaxConcurrentSessions = this.MaxConcurrentSessions;
68 if (propertyInfo[ConfigurationStrings.MaxConcurrentInstances].ValueOrigin != PropertyValueOrigin.Default)
70 behavior.MaxConcurrentInstances = this.MaxConcurrentInstances;
76 public override Type BehaviorType
78 get { return typeof(ServiceThrottlingBehavior); }