public ConfigWriter(WurmConfig config) { if (config == null) { throw new ArgumentNullException(nameof(config)); } this.config = config; }
public ConfigReader(WurmConfig config) { if (config == null) { throw new ArgumentNullException("config"); } this.config = config; }
void Refresh() { lock (locker) { bool anyChanges = false; var configNamesNormalized = wurmConfigDirectories.AllDirectoryNamesNormalized.ToArray(); var oldMap = nameToConfigMap; var newMap = new Dictionary <string, WurmConfig>(); List <Exception> configCreationErrors = new List <Exception>(); foreach (var configName in configNamesNormalized) { WurmConfig config; if (!oldMap.TryGetValue(configName, out config)) { try { FileInfo gameSettingsFileInfo = new FileInfo( wurmConfigDirectories.GetGameSettingsFileFullPathForConfigName( configName)); config = new WurmConfig(gameSettingsFileInfo.FullName, publicEventInvoker, taskManager, logger); config.ConfigChanged += ConfigOnConfigChanged; newMap.Add(configName, config); anyChanges = true; } catch (Exception exception) { configCreationErrors.Add(exception); } } else { newMap.Add(configName, config); } } if (anyChanges) { nameToConfigMap = newMap; onAvailableConfigsChanged.Trigger(); } if (configCreationErrors.Any()) { throw new AggregateException(configCreationErrors); } } }