public abstract class ConnectionProvider : IConnectionProvider, IDisposable { private string connString; private IDriver driver; private bool _isAlreadyDisposed; protected virtual string ConnectionString { get { return this.connString; } } public IDriver Driver { get { return this.driver; } } static ConnectionProvider() { } ~ConnectionProvider() { this.Dispose(false); } public virtual void CloseConnection(IDbConnection conn) { try { conn.Close(); } catch (Exception ex) { throw new ADOException("Could not close " + conn.GetType().ToString() + " connection", ex); } } public virtual void Configure(IDictionary settings) { this.connString = settings[(object)"hibernate.connection.connection_string"] as string; if (this.connString == null) this.connString = this.GetNamedConnectionString(settings); if (this.connString == null) throw new HibernateException("Could not find connection string setting (set hibernate.connection.connection_string or hibernate.connection.connection_string_name property)"); this.ConfigureDriver(settings); } protected virtual string GetNamedConnectionString(IDictionary settings) { string index = settings[(object)"hibernate.connection.connection_string_name"] as string; if (index == null) return (string)null; ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings[index]; if (connectionStringSettings == null) throw new HibernateException(string.Format("Could not find named connection string {0}", (object)index)); else return connectionStringSettings.ConnectionString; } protected virtual void ConfigureDriver(IDictionary settings) { string name = settings[(object)"hibernate.connection.driver_class"] as string; if (name == null) throw new HibernateException("The hibernate.connection.driver_class must be specified in the NHibernate configuration section."); try { this.driver = (IDriver)Activator.CreateInstance(ReflectHelper.ClassForName(name)); this.driver.Configure(settings); // error in these line } catch (Exception ex) { throw new HibernateException("Could not create the driver from " + name + ".", ex); } } public abstract IDbConnection GetConnection(); public void Dispose() { this.Dispose(true); } protected virtual void Dispose(bool isDisposing) { if (this._isAlreadyDisposed) return; if (isDisposing) this._isAlreadyDisposed = true; GC.SuppressFinalize((object)this); } }
this.driver.Configure
IDictionary
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)