public void ReloadConfig(bool triggerEvent) { // Activate original OriginalFunction.Activate(string.Empty); if (triggerEvent) { ConfigReloaded?.Invoke(); } }
private void FileChanged(object sender, FileSystemEventArgs fse) { if (Regions == null) { return; } try { ReflectDelta(fse); ConfigReloaded.Invoke(fse); } catch (Exception e) { Faulted.Invoke(fse, e); } }
/// <summary> /// Reloads the config from disk. Unsaved changes are lost. /// </summary> public void Reload() { lock (_ioLock) { Dictionary <ConfigDefinition, string> descriptions = Cache.ToDictionary(x => x.Key, x => x.Key.Description); string currentSection = ""; foreach (string rawLine in File.ReadAllLines(ConfigFilePath)) { string line = rawLine.Trim(); if (line.StartsWith("#")) //comment { continue; } if (line.StartsWith("[") && line.EndsWith("]")) //section { currentSection = line.Substring(1, line.Length - 2); continue; } string[] split = line.Split('='); //actual config line if (split.Length != 2) { continue; //empty/invalid line } string currentKey = split[0].Trim(); string currentValue = split[1].Trim(); var definition = new ConfigDefinition(currentSection, currentKey); if (descriptions.ContainsKey(definition)) { definition.Description = descriptions[definition]; } Cache[definition] = currentValue; } ConfigReloaded?.Invoke(this, EventArgs.Empty); } }
private static void RaiseConfigReloaded() { ConfigReloaded?.Invoke(); }
private void Reloaded(FileSystemEventArgs obj) { ConfigReloaded.Invoke(obj); }
internal static void OnConfigReloaded(object sender, ConfigReloadedEventArgs e) { ConfigReloaded?.Invoke(sender, e); }