コード例 #1
0
 public CommonConfiguration(ModuleLoader loader, ModuleConfiguration configuration, IEventLogging logging)
 {
     this.loader = loader;
     this._logging = logging;
     _config = configuration;
     _labelStorageAdapter = CreateLabelStorageAdapter(configuration);
     _systemParametersAdapter = new SystemParametersAdapter();
 }
コード例 #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="loader"></param>
        /// <param name="checkModules"></param>
        /// <param name="logging"></param>
        /// <param name="notThrowExceptionIfInvalideConfiguration"> используется ТОЛЬКО для дизайнера в автономном режиме</param>
        public CommonConfiguration(ModuleLoader loader, bool checkModules, IEventLogging logging, bool notThrowExceptionIfInvalideConfiguration)
        {
            this.loader = loader;
            this._logging = logging;
            string labelStoragePath;
            string moduleConfigFile = String.Empty;
            string configurationSchemaFile;
            try
            {
                string moduleConfigPath = labelStoragePath = Path.GetFullPath(ConfigurationFolder);
                moduleConfigFile = Path.Combine(moduleConfigPath, ConfigurationFile);
                labelStoragePath = Path.Combine(labelStoragePath, LabelFile);
                configurationSchemaFile = Path.Combine(moduleConfigPath, ConfigurationSchemaFile);
            }
            catch (ArgumentException ex)
            {
                throw new ModuleConfigurationException(moduleConfigFile);
            }

            try
            {
                _config = LoadModuleConfiguration(moduleConfigFile, configurationSchemaFile, this.loader.ModuleList);
                if (checkModules) CheckLoadedModules();
            }
            catch(Exception ex)
            {
                if (notThrowExceptionIfInvalideConfiguration)
                {
                    _config = new InvalideModuleConfiguration() {ErrorMessage = ex.Message, InnerException = ex};
                }
                else
                {
                    throw;
                }
            }

            _systemParametersAdapter = new SystemParametersAdapter();
            _labelStorageAdapter = CreateLabelStorageAdapter(_config, labelStoragePath);
        }