public string GetAppSettingString(string key) { Contract.Requires(!string.IsNullOrEmpty(key), string.Format("Key with named {0} is null or empty", key)); return(CatchExceptionHelper.TryCatchFunction( () => ConfigurationManager.AppSettings[key], Logger )); }
public T GetSection <T>(string sectionName) { Contract.Requires(!string.IsNullOrEmpty(sectionName), "SectionName [" + sectionName + "] is null or empty"); return(CatchExceptionHelper.TryCatchFunction( () => (T)ConfigurationManager.GetSection(sectionName), Logger )); }
public Configuration BuildConfiguration(string connectionString, string sessionFactoryName) { Contract.Requires(!string.IsNullOrEmpty(connectionString), "ConnectionString is null or empty"); Contract.Requires(!string.IsNullOrEmpty(sessionFactoryName), "SessionFactory name is null or empty"); Contract.Requires(!string.IsNullOrEmpty(_databaseSchema), "Database Schema is null or empty"); Contract.Requires(_configurator != null, "Configurator is null"); return(CatchExceptionHelper.TryCatchFunction( () => { DomainTypes = GetTypeOfEntities(_assemblies); if (DomainTypes == null) { throw new Exception("Type of domains is null"); } var configure = new Configuration(); configure.SessionFactoryName(sessionFactoryName); configure.Proxy(p => p.ProxyFactoryFactory <ProxyFactoryFactory>()); configure.DataBaseIntegration(db => GetDatabaseIntegration(db, connectionString)); if (_configurator.GetAppSettingString("IsCreateNewDatabase").ConvertToBoolean()) { configure.SetProperty("hbm2ddl.auto", "create-drop"); } configure.Properties.Add("default_schema", _databaseSchema); configure.AddDeserializedMapping(GetMapping(), _configurator.GetAppSettingString("DocumentFileName")); SchemaMetadataUpdater.QuoteTableAndColumns(configure); return configure; }, Logger)); }