Ejemplo n.º 1
0
        public static KeyValueStoreConfiguration GetConfig(string path = CONFIG_FILE)
        {
            if (_config == null || _path != path)
            {
                _path = path;

                string fullPath;
                if (HttpContext.Current == null)
                {
                    fullPath = Path.Combine(Directory.GetCurrentDirectory(), path);
                }
                else
                {
                    fullPath = Path.Combine(HttpContext.Current.Server.MapPath("~/"), path);
                }

                var xmlDoc = LoadXmlDocFromPath(fullPath);
                SetUpFileWatcher(fullPath);
                _config = new KeyValueStoreConfiguration(xmlDoc);
            }
            return _config;
        }
Ejemplo n.º 2
0
 private static void SetUpFileWatcher(string fullPath)
 {
     string dir = Path.GetDirectoryName(fullPath),
            file = Path.GetFileName(fullPath);
     var watcher = new FileSystemWatcher(dir, file);
     watcher.EnableRaisingEvents = true;
     watcher.Changed += new FileSystemEventHandler((obj, args) => {
         _config = null;
         //KeyValueStoreConfiguration.OnConfigChange();
     });
 }