Esempio n. 1
0
        /// <summary>
        /// Creates a new <see cref="XConfiguration"/> (or gets an existing one) from an underlying <see cref="XFileHandler"/>. This caches the object.
        /// </summary>
        /// <param name="handler">The underlying <see cref="XFileHandler"/> that this <see cref="XConfiguration"/> should extend.</param>
        /// <returns></returns>
        public static XConfiguration GetConfigurationUtility(XFileHandler handler, string cfgFileName = DEFAULT_CFG_FILE_NAME)
        {
            if (ConfigurationTies.ContainsKey(handler) && ConfigurationTies[handler].ContainsKey(cfgFileName))
            {
                return(ConfigurationTies[handler][cfgFileName]);
            }

            if (!ConfigurationTies.ContainsKey(handler))
            {
                ConfigurationTies[handler] = new Dictionary <string, XConfiguration>();
            }


            XConfiguration cfg = new XConfiguration(handler, cfgFileName);

            ConfigurationTies[handler][cfgFileName] = cfg;
            return(cfg);
        }
Esempio n. 2
0
 /// <summary>
 /// Mirrors the specified <see cref="XConfiguration"/> so that it saves under <paramref name="handler"/>.
 /// </summary>
 /// <param name="source">The source <see cref="XConfiguration"/></param>
 /// <param name="dataPersistenceFolder">The folder to treat like an alternate data persistence folder.</param>
 public ConfigMirror(XConfiguration source, XFileHandler handler)
 {
     SourceConfig = source;
     ThisHandler  = handler;
     source.OnConfigValueChanged += OnConfigValueChanged;
 }