public void ReloadConfig(bool triggerEvent)
        {
            // Activate original
            OriginalFunction.Activate(string.Empty);

            if (triggerEvent)
            {
                ConfigReloaded?.Invoke();
            }
        }
Пример #2
0
 private void FileChanged(object sender, FileSystemEventArgs fse)
 {
     if (Regions == null)
     {
         return;
     }
     try {
         ReflectDelta(fse);
         ConfigReloaded.Invoke(fse);
     }
     catch (Exception e) {
         Faulted.Invoke(fse, e);
     }
 }
Пример #3
0
        /// <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);
            }
        }
Пример #4
0
 private static void RaiseConfigReloaded()
 {
     ConfigReloaded?.Invoke();
 }
Пример #5
0
 private void Reloaded(FileSystemEventArgs obj)
 {
     ConfigReloaded.Invoke(obj);
 }
Пример #6
0
 internal static void OnConfigReloaded(object sender, ConfigReloadedEventArgs e)
 {
     ConfigReloaded?.Invoke(sender, e);
 }