protected override FdoConnection CreateConnection(string provider, string connStr, string configPath, ref string name)
{
IFdoConnectionManager connMgr = ServiceManager.Instance.GetService<IFdoConnectionManager>();
//Try to find by name first
FdoConnection conn = null;
conn = connMgr.GetConnection(name);
//Named connection matches all the details
if (conn != null)
{
if (conn.Provider == provider && conn.ConnectionString == connStr)
return conn;
}
//Then to find matching open connection
foreach (string connName in connMgr.GetConnectionNames())
{
FdoConnection c = connMgr.GetConnection(connName);
if (c.Provider == provider && c.ConnectionString == connStr)
{
name = connName;
return c;
}
}
//Make a new connection
LoggingService.Info(ResourceService.GetString("INFO_REFERENCED_CONNECTION_NOT_FOUND"));
conn = new FdoConnection(provider, connStr);
if (!string.IsNullOrEmpty(configPath) && System.IO.File.Exists(configPath))
conn.SetConfiguration(configPath);
connMgr.AddConnection(name, conn);
return conn;
}