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
- FrameworkReadOnlyPropertyMetadata.cs
- AssociationSet.cs
- EllipseGeometry.cs
- EntityDataReader.cs
- PageHandlerFactory.cs
- StringToken.cs
- XmlCharCheckingWriter.cs
- KnownAssemblyEntry.cs
- COM2IManagedPerPropertyBrowsingHandler.cs
- DateTimeStorage.cs
- HostedNamedPipeTransportManager.cs
- KnownTypesHelper.cs
- HMACMD5.cs
- SelectionEditor.cs
- SystemColors.cs
- ServiceHostingEnvironmentSection.cs
- DragDrop.cs
- CompositeActivityCodeGenerator.cs
- RoleGroup.cs
- LogWriteRestartAreaAsyncResult.cs
- AppDomainUnloadedException.cs
- DataProviderNameConverter.cs
- RangeValidator.cs
- MSAAEventDispatcher.cs
- StructuralType.cs
- WindowsMenu.cs
- FormViewCommandEventArgs.cs
- CustomErrorCollection.cs
- SingleConverter.cs
- ZoneMembershipCondition.cs
- DataGridViewCheckBoxCell.cs
- WCFBuildProvider.cs
- SplineKeyFrames.cs
- CompilationLock.cs
- HostProtectionException.cs
- TemplateKey.cs
- DefaultAsyncDataDispatcher.cs
- objectquery_tresulttype.cs
- WmlCommandAdapter.cs
- BaseHashHelper.cs
- QueueNameHelper.cs
- TrackingMemoryStream.cs
- HelloOperation11AsyncResult.cs
- SystemBrushes.cs
- CodeAttributeDeclaration.cs
- EncoderFallback.cs
- ComponentDesigner.cs
- ListSourceHelper.cs
- Evaluator.cs
- NamespaceMapping.cs
- TagPrefixInfo.cs
- InstanceKey.cs
- TreeWalkHelper.cs
- DataObjectCopyingEventArgs.cs
- NavigationWindow.cs
- StringUtil.cs
- Line.cs
- ButtonChrome.cs
- Button.cs
- AnnotationResource.cs
- BooleanConverter.cs
- BaseValidator.cs
- MessageSmuggler.cs
- XamlVector3DCollectionSerializer.cs
- Operand.cs
- BamlLocalizer.cs
- OleAutBinder.cs
- SystemIPGlobalStatistics.cs
- ToolStripHighContrastRenderer.cs
- RuntimeWrappedException.cs
- TextFormatter.cs
- HeaderUtility.cs
- Single.cs
- IProvider.cs
- PolicyVersionConverter.cs
- TraceHandlerErrorFormatter.cs
- WindowsRichEdit.cs
- ListViewDataItem.cs
- WebConvert.cs
- HealthMonitoringSection.cs
- RuntimeComponentFilter.cs
- EntityCommandDefinition.cs
- KernelTypeValidation.cs
- EntityDataSourceDataSelectionPanel.cs
- SmiRequestExecutor.cs
- AsyncResult.cs
- MetadataLocation.cs
- InfoCardRSAPKCS1KeyExchangeDeformatter.cs
- AmbiguousMatchException.cs
- ITextView.cs
- OdbcConnection.cs
- WebSysDescriptionAttribute.cs
- ResourceProperty.cs
- TabControl.cs
- CheckBox.cs
- EtwTrackingBehavior.cs
- DbDataSourceEnumerator.cs
- StreamGeometry.cs
- ProxyWebPartConnectionCollection.cs
- HashRepartitionEnumerator.cs