private void Load() { try { _configuration = ConfigurationContainer.LoadConfiguration(_settingsFilePath); } catch (Exception ex) { ModLogger.Warning("An error occured while loading mod configuration from file '{0}', the default configuration will be applied", _settingsFilePath); ModLogger.Exception(ex); // Always create a configuration object, even when the file could not be loaded. This way the mod will not crash on configuration issues _configuration = new ConfigurationContainer(); } // Apply the configuration to the running mod. _configuration.ApplyConfiguration(); }
public static ConfigurationContainer LoadConfiguration(string filename) { ModLogger.Debug("Loading configuration from '{0}'", filename); ConfigurationContainer result = null; // Check if the file exists. If so, deserialize it to a new instance. If not so, create a new empty instance if (File.Exists(filename)) { using (StreamReader sr = new StreamReader(filename)) result = (ConfigurationContainer)new XmlSerializer(typeof(ConfigurationContainer)).Deserialize(sr); } else result = new ConfigurationContainer(); // Assign the filename to the result. This is used later on when saving the configuration. result._filename = filename; ModLogger.Debug("Configuration loaded from '{0}'", filename); return result; }
public static ConfigurationContainer LoadConfiguration(string filename) { ModLogger.Debug("Loading configuration from '{0}'", filename); ConfigurationContainer result = null; // Check if the file exists. If so, deserialize it to a new instance. If not so, create a new empty instance if (File.Exists(filename)) { using (StreamReader sr = new StreamReader(filename)) result = (ConfigurationContainer) new XmlSerializer(typeof(ConfigurationContainer)).Deserialize(sr); } else { result = new ConfigurationContainer(); } // Assign the filename to the result. This is used later on when saving the configuration. result._filename = filename; ModLogger.Debug("Configuration loaded from '{0}'", filename); return(result); }
public UIModOptionsPanelBuilder(UIHelper uiHelper, ConfigurationContainer configuration) { _uiHelper = uiHelper; _configuration = configuration; _rootPanel = uiHelper.self as UIScrollablePanel; }