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
- CodeComment.cs
- MailSettingsSection.cs
- AuthenticationManager.cs
- Command.cs
- GuidConverter.cs
- DateTimeSerializationSection.cs
- LinkLabel.cs
- UTF7Encoding.cs
- DataRecordInternal.cs
- TextElementEditingBehaviorAttribute.cs
- WithParamAction.cs
- NetDataContractSerializer.cs
- TimeSpanValidatorAttribute.cs
- FrameworkElementFactory.cs
- ArrangedElement.cs
- CompilerCollection.cs
- RTTrackingProfile.cs
- IisTraceWebEventProvider.cs
- EndpointDiscoveryMetadataCD1.cs
- EntityCollection.cs
- SqlTrackingWorkflowInstance.cs
- DataIdProcessor.cs
- DataRowView.cs
- ListControlConvertEventArgs.cs
- FixedDocumentSequencePaginator.cs
- GridViewRowCollection.cs
- ByteAnimationUsingKeyFrames.cs
- DefaultBinder.cs
- InstanceView.cs
- ColorTransform.cs
- ClockController.cs
- RootBuilder.cs
- DbDeleteCommandTree.cs
- AssertFilter.cs
- SizeIndependentAnimationStorage.cs
- hebrewshape.cs
- FormViewInsertedEventArgs.cs
- PaperSize.cs
- PartialCachingControl.cs
- UserControl.cs
- SQLBytes.cs
- EmbeddedMailObjectCollectionEditor.cs
- SequenceRange.cs
- PeerEndPoint.cs
- FlowDocumentScrollViewer.cs
- DynamicVirtualDiscoSearcher.cs
- Table.cs
- TypeConverterMarkupExtension.cs
- Relationship.cs
- WsatServiceAddress.cs
- _FixedSizeReader.cs
- DbConnectionOptions.cs
- WindowsComboBox.cs
- PropertyValidationContext.cs
- ISessionStateStore.cs
- CatalogPartChrome.cs
- ProcessHostServerConfig.cs
- FormViewModeEventArgs.cs
- FormViewModeEventArgs.cs
- AxHostDesigner.cs
- AuthenticationServiceManager.cs
- NavigationProgressEventArgs.cs
- InertiaExpansionBehavior.cs
- AnimationTimeline.cs
- PropagatorResult.cs
- AnonymousIdentificationModule.cs
- SmiConnection.cs
- DurableInstance.cs
- SizeValueSerializer.cs
- HGlobalSafeHandle.cs
- TextRangeProviderWrapper.cs
- TransformCollection.cs
- ExclusiveNamedPipeTransportManager.cs
- wgx_commands.cs
- DispatchChannelSink.cs
- Sql8ConformanceChecker.cs
- StrokeDescriptor.cs
- XmlSchemaSimpleTypeRestriction.cs
- XmlSchemaDatatype.cs
- Viewport3DAutomationPeer.cs
- TreeWalker.cs
- InheritanceContextChangedEventManager.cs
- TypedColumnHandler.cs
- Triplet.cs
- __FastResourceComparer.cs
- NetworkAddressChange.cs
- OrderedDictionary.cs
- SamlSecurityTokenAuthenticator.cs
- NotImplementedException.cs
- XmlQuerySequence.cs
- MergeFailedEvent.cs
- HwndProxyElementProvider.cs
- MemberExpression.cs
- CodeDirectiveCollection.cs
- LinqDataView.cs
- RegistrationContext.cs
- UInt64.cs
- ScaleTransform.cs
- QilNode.cs
- HwndStylusInputProvider.cs