Beispiel #1
0
 public ConfigWriter(WurmConfig config)
 {
     if (config == null)
     {
         throw new ArgumentNullException(nameof(config));
     }
     this.config = config;
 }
Beispiel #2
0
 public ConfigReader(WurmConfig config)
 {
     if (config == null)
     {
         throw new ArgumentNullException("config");
     }
     this.config = config;
 }
Beispiel #3
0
        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);
                }
            }
        }