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
- CertificateReferenceElement.cs
- Matrix3DValueSerializer.cs
- ArrayTypeMismatchException.cs
- ToolStripPanelCell.cs
- LabelDesigner.cs
- ValidationSummary.cs
- InvalidEnumArgumentException.cs
- Expression.cs
- PaperSize.cs
- TextFindEngine.cs
- DecimalAverageAggregationOperator.cs
- ApplicationId.cs
- ObjectQuery.cs
- CryptoStream.cs
- Matrix3D.cs
- OrderedDictionary.cs
- MemberPath.cs
- StyleCollectionEditor.cs
- RelativeSource.cs
- ImplicitInputBrush.cs
- TypeBuilderInstantiation.cs
- DataGridCellClipboardEventArgs.cs
- UnsafeNativeMethodsPenimc.cs
- MergeFilterQuery.cs
- HierarchicalDataBoundControlAdapter.cs
- WindowsSlider.cs
- WebPartMenuStyle.cs
- TreePrinter.cs
- DispatcherHookEventArgs.cs
- ResourcePermissionBaseEntry.cs
- DomainUpDown.cs
- AlgoModule.cs
- DesignTimeTemplateParser.cs
- ServicesExceptionNotHandledEventArgs.cs
- ProgressBarBrushConverter.cs
- RowsCopiedEventArgs.cs
- Point3DAnimation.cs
- TreeNodeStyleCollection.cs
- RenderCapability.cs
- DirectoryInfo.cs
- PropertyDescriptorComparer.cs
- DesignerActionListCollection.cs
- IgnorePropertiesAttribute.cs
- VarRemapper.cs
- MappingMetadataHelper.cs
- XmlUtilWriter.cs
- ResourceReferenceExpressionConverter.cs
- HyperLink.cs
- DesigntimeLicenseContextSerializer.cs
- XmlSchemaComplexType.cs
- DecodeHelper.cs
- ExternalDataExchangeClient.cs
- XmlAttributes.cs
- EventDescriptor.cs
- SerTrace.cs
- EffectiveValueEntry.cs
- DataBinder.cs
- TraceListener.cs
- DataGridTableCollection.cs
- AdapterUtil.cs
- SimpleHandlerFactory.cs
- BuildProvider.cs
- WebPartUserCapability.cs
- ExcludePathInfo.cs
- PlatformCulture.cs
- HttpInputStream.cs
- PolicyStatement.cs
- Odbc32.cs
- sqlinternaltransaction.cs
- ComponentRenameEvent.cs
- DataGridViewCellFormattingEventArgs.cs
- VoiceChangeEventArgs.cs
- NotifyIcon.cs
- CodeExpressionStatement.cs
- InputProcessorProfilesLoader.cs
- BrowserCapabilitiesFactoryBase.cs
- ManagedIStream.cs
- Graphics.cs
- ListBase.cs
- DriveNotFoundException.cs
- DropShadowBitmapEffect.cs
- DbDataRecord.cs
- AppDomainShutdownMonitor.cs
- GroupItemAutomationPeer.cs
- BaseCodeDomTreeGenerator.cs
- GraphicsContext.cs
- QilInvokeLateBound.cs
- RequestCacheValidator.cs
- DescriptionCreator.cs
- MsmqIntegrationProcessProtocolHandler.cs
- CaseKeyBox.ViewModel.cs
- WebPartCollection.cs
- DataGridColumnCollection.cs
- JavaScriptObjectDeserializer.cs
- ExtenderProvidedPropertyAttribute.cs
- InternalConfigSettingsFactory.cs
- CodeDomDesignerLoader.cs
- Rectangle.cs
- InvalidAsynchronousStateException.cs
- ConstraintConverter.cs