本文整理汇总了C#中IConnectionPool类的典型用法代码示例。如果您正苦于以下问题:C# IConnectionPool类的具体用法?C# IConnectionPool怎么用?C# IConnectionPool使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IConnectionPool类属于命名空间,在下文中一共展示了IConnectionPool类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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;
}
示例4: AbstractSchemaProvider
protected AbstractSchemaProvider (IConnectionPool connectionPool)
{
if (connectionPool == null)
throw new ArgumentNullException ("connectionPool");
this.connectionPool = connectionPool;
}
示例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;
}
}
示例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);
}
示例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;
}
示例8: AbstractSchemaProvider
protected AbstractSchemaProvider (IConnectionPool connectionPool)
{
if (connectionPool == null)
throw new ArgumentNullException ("connectionPool");
this.connectionPool = connectionPool;
this.supportedActions = new Dictionary<SchemaType, SchemaActions> ();
}
示例9: Node
public Node(string host, int port, IConnectionPool masterConnectionPool, params IConnectionPool[] slaveConnectionPools)
{
Host = host;
Port = port;
_masterConnectionPool = masterConnectionPool;
_slaveConnectionPools = slaveConnectionPools;
}
示例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;
}
示例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;
}
示例12: TestFixtureSetUp
public void TestFixtureSetUp()
{
var ipEndpoint = UriExtensions.GetEndPoint(Address);
var connectionPoolConfig = new PoolConfiguration();
_connectionPool = new ConnectionPool<EapConnection>(connectionPoolConfig, ipEndpoint);
_ioStrategy = new DefaultIOStrategy(_connectionPool);
}
示例13: 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);
}
示例14: OneTimeSetUp
public void OneTimeSetUp()
{
var ipEndpoint = UriExtensions.GetEndPoint(_address);
var connectionPoolConfig = new PoolConfiguration();
_connectionPool = new ConnectionPool<Connection>(connectionPoolConfig, ipEndpoint);
_ioService = new PooledIOService(_connectionPool);
}
示例15: 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();
}