public override void Load()
{
string dbConnectionType = ConfigurationManager.AppSettings["dbConnectionType"];
if (string.IsNullOrWhiteSpace(dbConnectionType))
{
throw new ConfigurationErrorsException("You need to specify value for 'dbConnectionType' key inside <appSettings>");
}
string connectionString = ConfigurationManager.AppSettings["dbConnectionString"];
if (string.IsNullOrWhiteSpace(connectionString))
{
throw new ConfigurationErrorsException("You need to specify value for 'dbConnectionString' key inside <appSettings>");
}
connectionString = connectionString.Replace("$DbRoot$", GetDbRootFolder());
Type t = typeof(IDbConnection).Assembly.GetType(dbConnectionType, false);
if (t == null)
{
throw new ConfigurationErrorsException(String.Format("Unable to create type '{0}' from assembly '{1}'", dbConnectionType, typeof(IDbConnection).Assembly.FullName));
}
if (!typeof(IDbConnection).IsAssignableFrom(t))
{
throw new ConfigurationErrorsException(String.Format("Type '{0}' must implement System.Data.IDbConnection interface", dbConnectionType));
}
Kernel.Bind<IDbConnection>().To(t).WithConstructorArgument("connectionString", connectionString);
}