mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-19 01:31:17 -10:00
Adding reference source for System.Data System.Data.DataSetExtensions System.Data.Entity System.Data.Entity.Design System.Data.Linq System.Data.SqlXml System.ServiceModel System.ServiceModel.Activation System.ServiceModel.Activities System.ServiceModel.Channels System.ServiceModel.Discovery System.ServiceModel.Internals System.ServiceModel.Routing System.ServiceModel.WasHosting System.ServiceModel.Web System.Web System.Web.ApplicationServices System.Web.DynamicData System.Web.Entity System.Web.Entity.Design System.Web.Extensions System.Web.Mobile System.Web.Routing System.Web.Services System.Xml System.Xml.Linq
91 lines
2.8 KiB
C#
91 lines
2.8 KiB
C#
//----------------------------------------------------------------------------
|
|
// 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<string, List<ConnectionPool>> registry;
|
|
|
|
protected ConnectionPoolRegistry()
|
|
{
|
|
registry = new Dictionary<string, List<ConnectionPool>>();
|
|
}
|
|
|
|
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<ConnectionPool> 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<ConnectionPool>();
|
|
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<ConnectionPool> 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);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|