/// <summary> /// The class constructor. </summary> /// <param name="fileconfig">Database config filepath.</param> public DBConfig(string fileconfig) { //reset the flag isInitialized = false; try { //Change ConfigurationManager file to the DBConfig Path. DBconfigMap = new ExeConfigurationFileMap(); DBconfigMap.ExeConfigFilename = fileconfig; DBconfigFile = ConfigurationManager.OpenMappedExeConfiguration(DBconfigMap, ConfigurationUserLevel.None); //Open the server definitions in the DB config file. //MainServer = new ServerSect("ServerMain", DBconfigFile); MainServer = (ServerSect)DBconfigFile.GetSection("ServerMain"); //BackupServer = new ServerSect("ServerBackup", DBconfigFile); BackupServer = (ServerSect)DBconfigFile.GetSection("ServerBackup"); //Initialize the History Object Config. //HistMaster = new HistoricsSett("HistoricsMaster", DBconfigFile); HistMaster = (HistoricsSett)DBconfigFile.GetSection("HistoricsMaster"); HistBackup = (HistoricsSett)DBconfigFile.GetSection("HistoricsBackup"); if ((MainServer != null) && (HistMaster != null)) { isInitialized = true; } } catch (Exception e) { MessageBox.Show(e.Message); } }
/// <summary> /// The class constructor. /// Requires to specify the section to be opened. </summary> /// <param name="sect"> Section to Open in the Config File.</param> /// <param name="DBconfigFile"> Configuration file mapped.</param> public ServerSect(string sect, Configuration DBconfigFile) { settings = DBconfigFile.GetSection(sect) as ServerSect; }
/// <summary> /// The class default constructor. </summary> public ServerSect() { settings = null; }