/*
* Namespace Summary
* Copyright (C) 2005+ Bogdan Damian Constantin
* E-Mail: damianbcpetro@gmail.com
* WEB: http://www.sourceforge.net/projects/dataholder
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License 2.1 or later, as
* published by the Free Software Foundation. See the included License.txt
* or http://www.gnu.org/copyleft/lesser.html for details.
*
*/
using System;
using System.Data;
using System.Collections;
namespace DataHolder.DataPersistence.DBAProvider{
/// <summary>
/// Summary description for ConnectionManager.
/// </summary>
public class ConnectionManager
{
Hashtable _Connections = new Hashtable(1);
public ConnectionManager()
{
//
// TODO: Add constructor logic here
//
}
public void AddConnection(string Name, string ConnectionString, CommandProvider p_CommandProvider)
{
_Connections.Add(Name, new ConnectionDefinition(ConnectionString, p_CommandProvider));
}
public ConnectionDefinition this[string Name]
{
get
{
return (ConnectionDefinition)_Connections[Name];
}
}
public IDbConnection GetConnection(string Name)
{
return ((ConnectionDefinition)_Connections[Name]).GetConnection();
}
}
public class ConnectionDefinition
{
string _ConnectionString;
CommandProvider _CommandProvider;
public ConnectionDefinition(string p_conectionstring, CommandProvider p_Commandprovider)
{
_ConnectionString = p_conectionstring;
_CommandProvider = p_Commandprovider;
}
public string ConnectionString
{
get
{
return _ConnectionString;
}
}
public CommandProvider CommandProvider
{
get
{
return _CommandProvider;
}
}
public IDbConnection GetConnection()
{
return _CommandProvider.GetConnection(_ConnectionString);
}
}
}
|