コード例 #1
0
ファイル: DriverConfig.cs プロジェクト: ajw588/DriverCommApp
        /// <summary>
        /// The class constructor. </summary>
        ///  <param name="fileconfig">Database config filepath.</param>
        public DriverConfig(string fileconfig)
        {
            //Index for loops.
            int    i;
            string sectName;

            //Reset the flag
            isInitialized = false;

            try
            {
                DriverConfigMap = new ExeConfigurationFileMap();
                DriverConfigMap.ExeConfigFilename = fileconfig;
                DriverConfigFile = ConfigurationManager.OpenMappedExeConfiguration(DriverConfigMap, ConfigurationUserLevel.None);

                //Open the General definitions in the config file.
                //GenDriverConf = new GeneralDriver("GeneralDriver", DriverConfigFile);
                GenDriverConf = (GeneralDriver)DriverConfigFile.GetSection("GeneralDriver");

                //Variable to keep the General data.
                GeneralSett = new GenSettings();

                GeneralSett.cDrivers   = GenDriverConf.CountDrivers;
                GeneralSett.cDataAreas = GenDriverConf.CountDataAreas;

                DriversConf   = new DriverConf[GeneralSett.cDrivers];
                DataAreasConf = new DataAreaConf[GeneralSett.cDataAreas];

                //Get Drivers Info
                for (i = 1; i <= GeneralSett.cDrivers; i++)
                {
                    sectName = "Driver_" + i.ToString("00");
                    //DriversConf[i] = new DriverConf(sectName, DriverConfigFile);
                    DriversConf[(i - 1)] = (DriverConf)DriverConfigFile.GetSection(sectName);
                }

                //Get Data Areas Info
                for (i = 1; i <= GeneralSett.cDataAreas; i++)
                {
                    sectName = "DataArea_" + i.ToString("00");
                    //DataAreasConf[i] = new DataAreaConf(sectName, DriverConfigFile);
                    DataAreasConf[(i - 1)] = (DataAreaConf)DriverConfigFile.GetSection(sectName);
                }

                if ((GeneralSett.cDrivers > 0))
                {
                    isInitialized = true;
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }//END DriverConfig Class Constructor
コード例 #2
0
ファイル: DriverConfig.cs プロジェクト: ajw588/DriverCommApp
 /// <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="DriverConfigFile"> Configuration file mapped.</param>
 public GeneralDriver(string sect, Configuration DriverConfigFile)
 {
     settings = DriverConfigFile.GetSection(sect) as GeneralDriver;
 }