public static void Initialize(IDatabaseConnectionConfigurationStorage configurationsStorage) { if (!Initialized) { Initialized = true; _configurationsStorage = configurationsStorage; } else { throw new InvalidOperationException("The DatabaseConnectionManager is already initialized"); } }
public static void InitializeDatabaseAccessClasses(IDataContextHandler dataContextHandler, IDatabaseConnectionConfigurationStorage configurationStorage, IDatabaseConnectionConfigurator connectionConfigurator, params Type[] dbContextTypes) { DatabaseConnectionConfigurationStorage = configurationStorage; DatabaseConnectionConfigurator = connectionConfigurator; DataContextManager.Initialize(dataContextHandler); DatabaseConnectionManager.Initialize(configurationStorage); foreach (var dbType in dbContextTypes) { dataContextHandler.RegisterDataContextType(dbType); } }
public static bool CheckDatabaseConnection(string connectionId, IDatabaseConnectionConfigurationStorage configurationStorage, Func <DatabaseConnectionConfiguration, bool> validateConfigFunc, bool showConfigurationInterface) { try { if (!DatabaseConnectionManager.Initialized) { DatabaseConnectionManager.Initialize(configurationStorage); } var config = DatabaseConnectionManager.GetConfiguration(connectionId); if (!validateConfigFunc(config)) { return(showConfigurationInterface && Configure(connectionId, validateConfigFunc)); } } catch (Exception e) { return(showConfigurationInterface && Configure(connectionId, validateConfigFunc)); } return(true); }
public static bool InitializeDatabaseAccessClasses(IDataContextHandler dataContextHandler, IDatabaseConnectionConfigurationStorage configurationStorage, bool showConfigurationInterface, params Type[] dbContextTypes) { DataContextManager.Initialize(dataContextHandler); foreach (var dbType in dbContextTypes) { dataContextHandler.RegisterDataContextType(dbType); if (!DatabaseConnectionConfigurator.CheckDatabaseConnection(dbType.Name, configurationStorage, (conf) => dataContextHandler.CheckConnectionForDataContext(dbType, conf), showConfigurationInterface)) { return(false); } } return(true); }