Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Channels / ConnectionPoolRegistry.cs / 1 / ConnectionPoolRegistry.cs
//---------------------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //--------------------------------------------------------------------------- namespace System.ServiceModel.Channels { using System.Diagnostics; using System.ServiceModel; using System.Collections.Generic; using System.ServiceModel.Diagnostics; abstract class ConnectionPoolRegistry { Dictionary> registry; protected ConnectionPoolRegistry() { registry = new Dictionary >(); } object ThisLock { get { return this.registry; } } // NOTE: performs the open on the pool for you public ConnectionPool Lookup(IConnectionOrientedTransportChannelFactorySettings settings) { ConnectionPool result = null; string key = settings.ConnectionPoolGroupName; lock (ThisLock) { List registryEntry = null; if (registry.TryGetValue(key, out registryEntry)) { for (int i = 0; i < registryEntry.Count; i++) { if (registryEntry[i].IsCompatible(settings) && registryEntry[i].TryOpen()) { result = registryEntry[i]; break; } } } else { registryEntry = new List (); registry.Add(key, registryEntry); } if (result == null) { result = CreatePool(settings); registryEntry.Add(result); } } return result; } protected abstract ConnectionPool CreatePool(IConnectionOrientedTransportChannelFactorySettings settings); public void Release(ConnectionPool pool, TimeSpan timeout) { lock (ThisLock) { if (pool.Close(timeout)) { List registryEntry = registry[pool.Name]; for (int i = 0; i < registryEntry.Count; i++) { if (object.ReferenceEquals(registryEntry[i], pool)) { registryEntry.RemoveAt(i); break; } } if (registryEntry.Count == 0) { registry.Remove(pool.Name); } } } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- PrePrepareMethodAttribute.cs
- RootBuilder.cs
- TimerElapsedEvenArgs.cs
- SelectionEditor.cs
- EmissiveMaterial.cs
- NonBatchDirectoryCompiler.cs
- Options.cs
- _NegoState.cs
- DefinitionBase.cs
- filewebresponse.cs
- Propagator.ExtentPlaceholderCreator.cs
- SignedInfo.cs
- DescendentsWalker.cs
- Converter.cs
- ExtendedProperty.cs
- ValidationErrorInfo.cs
- PipelineDeploymentState.cs
- ByteArrayHelperWithString.cs
- XmlSchemaValidator.cs
- WebEventCodes.cs
- Emitter.cs
- TreeViewItem.cs
- Pens.cs
- WithStatement.cs
- VariableAction.cs
- XamlPointCollectionSerializer.cs
- ImageListImage.cs
- CodeTypeOfExpression.cs
- OledbConnectionStringbuilder.cs
- ItemMap.cs
- ProfileEventArgs.cs
- FlowDocument.cs
- StructuralType.cs
- NativeMethods.cs
- WebPartPersonalization.cs
- FieldToken.cs
- _CacheStreams.cs
- Component.cs
- DesignerGeometryHelper.cs
- SID.cs
- CodeTypeMember.cs
- JsonReader.cs
- DataSourceListEditor.cs
- DefaultEventAttribute.cs
- DSASignatureFormatter.cs
- VisualStyleInformation.cs
- PrivacyNoticeBindingElement.cs
- Panel.cs
- AmbientProperties.cs
- SignedXml.cs
- DataGridViewSelectedCellCollection.cs
- OleDbConnectionFactory.cs
- Duration.cs
- TypeUsageBuilder.cs
- StaticSiteMapProvider.cs
- MatrixAnimationUsingKeyFrames.cs
- DBAsyncResult.cs
- HtmlElement.cs
- OleDbRowUpdatingEvent.cs
- TemplateControlBuildProvider.cs
- PreProcessInputEventArgs.cs
- ExceptionUtil.cs
- NumberSubstitution.cs
- XmlElementCollection.cs
- ManifestBasedResourceGroveler.cs
- PagesChangedEventArgs.cs
- ObjectSecurity.cs
- SQLMembershipProvider.cs
- InteropBitmapSource.cs
- Ipv6Element.cs
- JavaScriptString.cs
- HyperLink.cs
- ConfigsHelper.cs
- TypeInformation.cs
- HashHelper.cs
- LateBoundBitmapDecoder.cs
- AddingNewEventArgs.cs
- MyContact.cs
- TakeQueryOptionExpression.cs
- Int32RectValueSerializer.cs
- GeometryModel3D.cs
- PropertyChangingEventArgs.cs
- DataSourceProvider.cs
- SmiEventSink_Default.cs
- BaseInfoTable.cs
- SqlDataSourceConfigureSelectPanel.cs
- KeyPressEvent.cs
- ObjectDataSourceFilteringEventArgs.cs
- XmlException.cs
- QueryOutputWriter.cs
- FixedSOMContainer.cs
- EndPoint.cs
- mediaeventshelper.cs
- RadialGradientBrush.cs
- SelectionList.cs
- XmlCharCheckingWriter.cs
- EntitySqlQueryBuilder.cs
- Socket.cs
- OdbcErrorCollection.cs
- AppDomainProtocolHandler.cs