本文整理汇总了C#中IConnectionPool类的典型用法代码示例。如果您正苦于以下问题:C# IConnectionPool类的具体用法?C# IConnectionPool怎么用?C# IConnectionPool使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IConnectionPool类属于命名空间,在下文中一共展示了IConnectionPool类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CreateConnection
{
public override IPooledDbConnection CreateConnection (IConnectionPool pool, DatabaseConnectionSettings settings, out string error)
{
SqlConnectionStringBuilder builder = null;
try {
if (settings.UseConnectionString) {
builder = new SqlConnectionStringBuilder (settings.ConnectionString);
} else {
builder = new SqlConnectionStringBuilder ();
builder.InitialCatalog = settings.Database;
builder.UserID = settings.Username;
builder.Password = settings.Password;
builder.DataSource = String.Concat (settings.Server, ",", settings.Port);
//builder.NetworkLibrary = "DBMSSOCN";
}
builder.Pooling = false;
SqlConnection connection = new SqlConnection (builder.ToString ());
connection.Open ();
error = null;
return new SqlServerPooledDbConnection (pool, connection);
} catch (Exception e) {
error = e.Message;
return null;
}
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:25,代码来源:SqlServerConnectionProvider.cs
示例2: CreateConnection
{
public override IPooledDbConnection CreateConnection (IConnectionPool pool, DatabaseConnectionSettings settings, out string error)
{
string connStr = null;
try {
if (settings.UseConnectionString) {
connStr = settings.ConnectionString;
} else {
//User ID=root;Password=myPassword;Host=localhost;Port=5432;Database=myDataBase;Pooling=true;Min Pool Size=0;Max Pool Size=100;Connection Lifetime=0;
if (settings.Port > 0)
connStr = String.Format ("User ID={0};Password={1};Host={2};Port={3};Database={4};",
settings.Username, settings.Password, settings.Server, settings.Port, settings.Database);
else
connStr = String.Format ("User ID={0};Password={1};Host={2};Database={3};",
settings.Username, settings.Password, settings.Server, settings.Database);
}
connStr = SetConnectionStringParameter (connStr, String.Empty, "Pooling", "false");
NpgsqlConnection connection = new NpgsqlConnection (connStr);
connection.Open ();
error = null;
return new NpgsqlPooledDbConnection (pool, connection);
} catch (Exception e) {
error = e.Message;
return null;
}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:27,代码来源:NpgsqlConnectionProvider.cs
示例3: SealedVirtualCluster
public SealedVirtualCluster(VirtualCluster cluster, IConnectionPool pool, TestableDateTimeProvider dateTimeProvider)
{
this._cluster = cluster;
this._connectionPool = pool;
this._connection = new VirtualClusterConnection(cluster, dateTimeProvider);
this._dateTimeProvider = dateTimeProvider;
}
开发者ID:RossLieberman,项目名称:NEST,代码行数:7,代码来源:SealedVirtualCluster.cs
示例4: AbstractSchemaProvider
protected AbstractSchemaProvider (IConnectionPool connectionPool)
{
if (connectionPool == null)
throw new ArgumentNullException ("connectionPool");
this.connectionPool = connectionPool;
}
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:7,代码来源:AbstractSchemaProvider.cs
示例5: CreateConnection
public override IPooledDbConnection CreateConnection(IConnectionPool pool,
DatabaseConnectionSettings settings,
out string error)
{
string connStr = null;
try {
if (settings.UseConnectionString) {
connStr = settings.ConnectionString;
} else {
//"mongodb://[username:[email protected]]hostname[:port][/[database][?options]]"
//Default port is 27017.
if(!string.IsNullOrEmpty(settings.Username) && !string.IsNullOrEmpty(settings.Password)) {
connStr = String.Format("mongodb://{3}:{4}@{0}:{1}/{2}",
settings.Server, settings.Port, settings.Database, settings.Username, settings.Password);
} else {
connStr = String.Format("mongodb://{0}:{1}/{2}",
settings.Server, settings.Port, settings.Database);
}
}
MongoDbConnection connection = new MongoDbConnection(connStr, settings.Database);
connection.Open();
error = null;
return new MongoDbPooledDbConnection (pool, connection);
} catch (Exception e) {
error = e.Message;
return null;
}
}
开发者ID:schamane,项目名称:monodevelop-mongodb-provider,代码行数:29,代码来源:MongoDbConnectionProvider.cs
示例6: MongoDbSchemaProvider
public MongoDbSchemaProvider(IConnectionPool connectionPool)
: base(connectionPool)
{
AddSupportedSchemaActions (SchemaType.Database, SchemaActions.All);
AddSupportedSchemaActions (SchemaType.Table, SchemaActions.Create | SchemaActions.Drop | SchemaActions.Rename | SchemaActions.Schema);
AddSupportedSchemaActions (SchemaType.User, SchemaActions.None);
}
开发者ID:schamane,项目名称:monodevelop-mongodb-provider,代码行数:7,代码来源:MongoDbSchemaProvider.cs
示例7: CreateConnection
{
public override IPooledDbConnection CreateConnection (IConnectionPool pool,
DatabaseConnectionSettings settings,
out string error)
{
string connStr = null;
try {
if (settings.UseConnectionString) {
connStr = settings.ConnectionString;
} else {
//"Server=Server;Port=1234;Database=Test;Uid=UserName;Pwd=asdasd;"
//Default port is 3306. Enter value -1 to use a named pipe connection.
if (settings.Port > 0)
connStr = String.Format ("Server={0};Port={1};Database={2};Uid={3};Pwd={4};",
settings.Server, settings.Port, settings.Database, settings.Username, settings.Password);
else
connStr = String.Format ("Server={0};Database={2};Uid={3};Pwd={3};",
settings.Server, settings.Database, settings.Username, settings.Password);
}
connStr = SetConnectionStringParameter (connStr, String.Empty, "Pooling", "false");
MySqlConnection connection = new MySqlConnection (connStr);
connection.Open ();
error = null;
return new MySqlPooledDbConnection (pool, connection);
} catch (Exception e) {
error = e.Message;
return null;
}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:30,代码来源:MySqlConnectionProvider.cs
示例8: AbstractSchemaProvider
protected AbstractSchemaProvider (IConnectionPool connectionPool)
{
if (connectionPool == null)
throw new ArgumentNullException ("connectionPool");
this.connectionPool = connectionPool;
this.supportedActions = new Dictionary<SchemaType, SchemaActions> ();
}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:8,代码来源:AbstractSchemaProvider.cs
示例9: Node
public Node(string host, int port, IConnectionPool masterConnectionPool, params IConnectionPool[] slaveConnectionPools)
{
Host = host;
Port = port;
_masterConnectionPool = masterConnectionPool;
_slaveConnectionPools = slaveConnectionPools;
}
开发者ID:searbe,项目名称:redis-client,代码行数:8,代码来源:Node.cs
示例10: VirtualizedCluster
public VirtualizedCluster(VirtualCluster cluster, IConnectionPool pool, TestableDateTimeProvider dateTimeProvider, ConnectionSettings settings)
{
this._dateTimeProvider = dateTimeProvider;
this._settings = settings;
this._fixedRequestPipeline = new FixedPipelineFactory(settings, this._dateTimeProvider);
this._cluster = cluster;
this._connectionPool = pool;
}
开发者ID:mstoli,项目名称:elasticsearch-net,代码行数:9,代码来源:VirtualizedCluster.cs
示例11: Setup
public void Setup()
{
var mockConnection = new Mock<IConnection>();
mockConnection.SetupGet(x => x.IsAuthenticated).Returns(false);
var mockConnectionPool = new Mock<IConnectionPool>();
mockConnectionPool.Setup(x => x.Acquire()).Returns(mockConnection.Object);
_connectionPool = mockConnectionPool.Object;
}
开发者ID:brantburnett,项目名称:couchbase-net-client,代码行数:10,代码来源:SaslAuthenticationTests.cs
示例12: PostgresQueryManager
public PostgresQueryManager(
IConnectionPool connections,
Func<NpgsqlConnection, NpgsqlTransaction, IPostgresDatabaseQuery> queryFactory)
{
Contract.Requires(connections != null);
Contract.Requires(queryFactory != null);
this.Connections = connections;
this.QueryFactory = queryFactory;
}
开发者ID:dstimac,项目名称:revenj,代码行数:10,代码来源:PostgresQueryManager.cs
示例13: AssertCreateView
public void AssertCreateView(IConnectionPool pool)
{
/**
*/
var threads = Enumerable.Range(0, 50)
.Select(i => CreateReadAndUpdateThread(pool))
.ToList();
foreach (var t in threads) t.Start();
foreach (var t in threads) t.Join();
}
开发者ID:emohebi,项目名称:elasticsearch-net,代码行数:11,代码来源:VolatileUpdates.doc.cs
示例14: CreateReadAndUpdateThread
public Thread CreateReadAndUpdateThread(IConnectionPool pool) => new Thread(() =>
{
for (var i = 0; i < 1000; i++)
foreach (var v in CallGetNext(pool))
{
if (this.Random.Next(10) % 2 == 0)
{
pool.Reseed(Update);
}
}
});
开发者ID:emohebi,项目名称:elasticsearch-net,代码行数:11,代码来源:VolatileUpdates.doc.cs
示例15: CreateThreadCallingGetNext
public Thread CreateThreadCallingGetNext(IConnectionPool pool, ConcurrentBag<int> startingPositions) => new Thread(() =>
{
/** CallGetNext is a generator that calls GetNext() indefinitely using a local cursor */
var seenPorts = CallGetNext(pool).Take(NumberOfNodes * 10).ToList();
var startPosition = seenPorts.First();
startingPositions.Add(startPosition);
//first seenNode is e.g 9202 then start counting at 2;
var i = (startPosition - 9200) % NumberOfNodes;
foreach (var port in seenPorts)
port.Should().Be(9200 + (i++ % NumberOfNodes));
});
开发者ID:RossLieberman,项目名称:NEST,代码行数:11,代码来源:RoundRobin.doc.cs
示例16: SqliteSchemaProvider
public SqliteSchemaProvider (IConnectionPool connectionPool)
: base (connectionPool)
{
AddSupportedSchemaActions (SchemaType.Database, SchemaActions.Create | SchemaActions.Drop | SchemaActions.Schema);
AddSupportedSchemaActions (SchemaType.Table, SchemaActions.Create | SchemaActions.Drop | SchemaActions.Rename | SchemaActions.Schema);
AddSupportedSchemaActions (SchemaType.View, SchemaActions.Create | SchemaActions.Drop | SchemaActions.Schema);
AddSupportedSchemaActions (SchemaType.TableColumn, SchemaActions.All);
AddSupportedSchemaActions (SchemaType.ProcedureParameter, SchemaActions.Schema);
AddSupportedSchemaActions (SchemaType.Trigger, SchemaActions.All);
AddSupportedSchemaActions (SchemaType.PrimaryKeyConstraint, SchemaActions.Create | SchemaActions.Schema);
AddSupportedSchemaActions (SchemaType.CheckConstraint, SchemaActions.Create | SchemaActions.Schema);
AddSupportedSchemaActions (SchemaType.UniqueConstraint, SchemaActions.Create | SchemaActions.Schema);
AddSupportedSchemaActions (SchemaType.Constraint, SchemaActions.Create | SchemaActions.Schema);
}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:14,代码来源:SqliteSchemaProvider.cs
示例17: TestFixtureSetUp
public void TestFixtureSetUp()
{
var ipEndpoint = UriExtensions.GetEndPoint(Address);
var connectionPoolConfig = new PoolConfiguration();
_connectionPool = new ConnectionPool<EapConnection>(connectionPoolConfig, ipEndpoint);
_ioStrategy = new DefaultIOStrategy(_connectionPool);
}
开发者ID:WhallaLabs,项目名称:couchbase-net-client,代码行数:7,代码来源:SaslListMechanismTests.cs
示例18: TestFixtureSetUp
public void TestFixtureSetUp()
{
var ipEndpoint = UriExtensions.GetEndPoint(_address);
var connectionPoolConfig = new PoolConfiguration { UseSsl = false };
_connectionPool = new ConnectionPool<Connection>(connectionPoolConfig, ipEndpoint);
_ioService = new PooledIOService(_connectionPool);
}
开发者ID:orangeloop,项目名称:couchbase-net-client,代码行数:7,代码来源:SaslFactoryTests.cs
示例19: OneTimeSetUp
public void OneTimeSetUp()
{
var ipEndpoint = UriExtensions.GetEndPoint(_address);
var connectionPoolConfig = new PoolConfiguration();
_connectionPool = new ConnectionPool<Connection>(connectionPoolConfig, ipEndpoint);
_ioService = new PooledIOService(_connectionPool);
}
开发者ID:brantburnett,项目名称:couchbase-net-client,代码行数:7,代码来源:SaslListMechanismTests.cs
示例20: SetUp
public void SetUp()
{
var ipEndpoint = UriExtensions.GetEndPoint(Address);
var factory = DefaultConnectionFactory.GetDefault();
_configuration = new PoolConfiguration(MaxSize, MinSize, WaitTimeout, RecieveTimeout, ShutdownTimeout, SendTimeout);
_connectionPool = new DefaultConnectionPool(_configuration, ipEndpoint, factory);
_connectionPool.Initialize();
}
开发者ID:WhallaLabs,项目名称:couchbase-net-client,代码行数:8,代码来源:DefaultConnectionPoolTests.cs
注:本文中的IConnectionPool类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论