Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Description / ServiceThrottlingBehavior.cs / 1 / ServiceThrottlingBehavior.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.ServiceModel.Description { using System.Collections.Generic; using System.ServiceModel.Channels; using System.ServiceModel.Dispatcher; using System.ServiceModel; using System.Xml; using System.Runtime.Serialization; using System.Collections.ObjectModel; public class ServiceThrottlingBehavior : IServiceBehavior { int calls = ServiceThrottle.DefaultMaxConcurrentCalls; int sessions = ServiceThrottle.DefaultMaxConcurrentSessions; int instances = Int32.MaxValue; bool maxInstanceSetExplicitly; public int MaxConcurrentCalls { get { return this.calls; } set { if (value <= 0) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.SFxThrottleLimitMustBeGreaterThanZero0))); this.calls = value; } } public int MaxConcurrentSessions { get { return this.sessions; } set { if (value <= 0) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.SFxThrottleLimitMustBeGreaterThanZero0))); this.sessions = value; } } public int MaxConcurrentInstances { get { if (this.maxInstanceSetExplicitly) { return this.instances; } else { //For V1: Default MaxConcurrentInstances should not enforce any throttle //But still it should not be set to Int32.MAX; //So compute default MaxInstances to be large enough to support MaxCalls & MaxSessions. this.instances = this.calls + this.sessions; if (this.instances < 0) { this.instances = Int32.MaxValue; } } return this.instances; } set { if (value <= 0) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.SFxThrottleLimitMustBeGreaterThanZero0))); this.instances = value; this.maxInstanceSetExplicitly = true; } } void IServiceBehavior.Validate(ServiceDescription description, ServiceHostBase serviceHostBase) { } void IServiceBehavior.AddBindingParameters(ServiceDescription description, ServiceHostBase serviceHostBase, Collectionendpoints, BindingParameterCollection parameters) { } void IServiceBehavior.ApplyDispatchBehavior(ServiceDescription description, ServiceHostBase serviceHostBase) { if (serviceHostBase == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("serviceHostBase")); ServiceThrottle serviceThrottle = serviceHostBase.ServiceThrottle; serviceThrottle.MaxConcurrentCalls = this.calls; serviceThrottle.MaxConcurrentSessions = this.sessions; serviceThrottle.MaxConcurrentInstances = this.MaxConcurrentInstances; for (int i=0; i
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- COMException.cs
- LicFileLicenseProvider.cs
- BulletedList.cs
- WebBrowserEvent.cs
- DataListItem.cs
- HostingEnvironmentException.cs
- TreeNodeStyleCollection.cs
- SoapIncludeAttribute.cs
- DateTimeOffset.cs
- StorageBasedPackageProperties.cs
- StyleCollection.cs
- DesignerSerializationVisibilityAttribute.cs
- Style.cs
- CharacterMetricsDictionary.cs
- TileBrush.cs
- GeometryModel3D.cs
- VectorCollection.cs
- DataTableTypeConverter.cs
- PieceDirectory.cs
- RightsManagementInformation.cs
- Inline.cs
- AllMembershipCondition.cs
- CommandDevice.cs
- AppLevelCompilationSectionCache.cs
- SQLByteStorage.cs
- DbDataReader.cs
- TextFormatterContext.cs
- HMACSHA256.cs
- TypeForwardedToAttribute.cs
- ResizeGrip.cs
- FileReservationCollection.cs
- SchemaNotation.cs
- BasicHttpMessageSecurityElement.cs
- XComponentModel.cs
- KerberosRequestorSecurityToken.cs
- DataGridViewTextBoxEditingControl.cs
- MobileControlsSection.cs
- CustomLineCap.cs
- PropertyContainer.cs
- WebScriptClientGenerator.cs
- SmiXetterAccessMap.cs
- GeneratedCodeAttribute.cs
- SearchExpression.cs
- DynamicDiscoSearcher.cs
- DummyDataSource.cs
- DataChangedEventManager.cs
- Wildcard.cs
- Semaphore.cs
- XmlTextEncoder.cs
- RemoteCryptoRsaServiceProvider.cs
- FileStream.cs
- MultipleViewProviderWrapper.cs
- TdsRecordBufferSetter.cs
- UInt32Converter.cs
- XPathNavigatorReader.cs
- SqlResolver.cs
- InputLangChangeEvent.cs
- BindableTemplateBuilder.cs
- OLEDB_Util.cs
- SelectionProviderWrapper.cs
- QEncodedStream.cs
- RewritingPass.cs
- Trace.cs
- WindowPattern.cs
- SingleTagSectionHandler.cs
- WinEventWrap.cs
- SpeechDetectedEventArgs.cs
- BooleanToSelectiveScrollingOrientationConverter.cs
- ObjectConverter.cs
- ScheduleChanges.cs
- listitem.cs
- WebServiceEnumData.cs
- GlyphManager.cs
- AssemblyUtil.cs
- WindowsToolbarItemAsMenuItem.cs
- TraceXPathNavigator.cs
- EpmAttributeNameBuilder.cs
- PropertyMetadata.cs
- DispatcherProcessingDisabled.cs
- LogEntryDeserializer.cs
- SessionStateSection.cs
- Monitor.cs
- Directory.cs
- TransformPatternIdentifiers.cs
- XmlReflectionImporter.cs
- AssemblyCollection.cs
- ObjectAnimationUsingKeyFrames.cs
- SchemaInfo.cs
- IntSecurity.cs
- AutomationPatternInfo.cs
- dbenumerator.cs
- DrawingContext.cs
- BitmapFrame.cs
- StringCollectionMarkupSerializer.cs
- SQLConvert.cs
- MulticastNotSupportedException.cs
- XMLUtil.cs
- MultipleViewPatternIdentifiers.cs
- ControlCollection.cs
- MgmtResManager.cs