示例#1
0
        public void Load()
        {
            var objectMapper = ObjectMapperFactory.CreateInstance();

            try
            {
                _settings = objectMapper.ReadValue <Settings>(_fileName);
                UpdateEffectPatternManager();

                //try loading the ELS configuration files, if something goes wrong, disable the els option
                if (_settings.ColorSettings.ElsEnabled)
                {
                    _settings.ColorSettings.ElsEnabled = _elsSettingsManager.Load();
                }

                _rage.DisplayPluginNotification("configuration loaded");
                _rage.LogTrivial(Settings.ToString());

                //initialize/reinitialize the effect devices and color manager
                _effectsManager.Initialize();
                _colorManager.Initialize(_settings);
            }
            catch (FileNotFoundException)
            {
                _rage.DisplayPluginNotification("configuration file not found, using defaults instead");
                LoadDefaults();
            }
            catch (Exception e)
            {
                _rage.LogTrivial(e.Message + Environment.NewLine + e.StackTrace);
                _rage.DisplayPluginNotification("configuration file is not valid, using defaults instead");
                LoadDefaults();
            }
        }
示例#2
0
        public void ShouldLoadElsFile()
        {
            var elsSettings = new ElsSettings
            {
                LightingSettings = new LightingSettings
                {
                    Extra01 = new ExtraSettings
                    {
                        IsElsControlled = true,
                        AllowEnvLight   = true,
                        Color           = Color.Blue
                    },
                    Extra02 = new ExtraSettings
                    {
                        IsElsControlled = true,
                        AllowEnvLight   = true,
                        Color           = Color.Blue
                    },
                    Extra03 = new ExtraSettings
                    {
                        IsElsControlled = true,
                        AllowEnvLight   = true,
                        Color           = Color.Blue
                    },
                    Extra04 = new ExtraSettings
                    {
                        IsElsControlled = true,
                        AllowEnvLight   = true,
                        Color           = Color.Red
                    },
                    Extra05 = new ExtraSettings
                    {
                        IsElsControlled = true,
                        AllowEnvLight   = true,
                        Color           = Color.Red
                    },
                    Extra06 = new ExtraSettings
                    {
                        IsElsControlled = true,
                        AllowEnvLight   = true,
                        Color           = Color.Red
                    }
                }
            };
            var objectMapper = ObjectMapperFactory.CreateInstance();

            var result = objectMapper.ReadValue <ElsSettings>(FILE);

            Assert.NotNull(result);
            Assert.Equal(elsSettings, result);
        }
        public bool Load()
        {
            _rage.LogTrivialDebug("loading ELS configuration files...");
            var objectMapper = ObjectMapperFactory.CreateInstance();

            _elsVehicleSettings.Clear();
            _elsSettings.Clear();

            try
            {
                foreach (var file in Directory.GetFiles(ElsDirectory, "*.xml"))
                {
                    _rage.LogTrivialDebug("loading els configuration file " + file);
                    var settings = LoadElsFile(file, objectMapper);

                    _rage.LogTrivialDebug("storing els configuration for vehicle " + settings.Key);
                    _elsSettings.Add(settings.Key, settings.Value);
                }

                foreach (var file in Directory.GetFiles(DefaultDirectory, "*.xml"))
                {
                    _rage.LogTrivialDebug("loading els default configuration file " + file);
                    var settings = LoadElsFile(file, objectMapper);
                    var name     = settings.Key;

                    _rage.LogTrivialDebug("storing els default configuration for vehicle " + name);
                    _elsVehicleSettings.Add(_elsSettings.ContainsKey(name)
                        ? new ElsVehicleSettings(name, _elsSettings[name], settings.Value)
                        : new ElsVehicleSettings(name, settings.Value));
                }

                _rage.LogTrivial("ELS configuration files loaded");
                return(true);
            }
            catch (Exception e)
            {
                _rage.LogTrivial(e.Message + Environment.NewLine + e.StackTrace);
                _rage.DisplayPluginNotification("an error occurred while loading the ELS configuration");
            }

            return(false);
        }
 public ReadValue()
 {
     _objectMapper = ObjectMapperFactory.CreateInstance();
 }