Exemple #1
0
        public static void StartWatch(ISingletonWatcher inst)
        {
            var PyhsicalPath = PathHelper.GetDataPath(inst.WatcherFile);

            if (!File.Exists(PyhsicalPath))
            {
                PyhsicalPath = ResourceHelper.CopyToAppData(inst.GetType(), inst.WatcherFile);
            }
            Reload(inst);

            FileDepend.Watch(PyhsicalPath, () => Reload(inst));
        }
Exemple #2
0
        public static void Reload(ISingletonWatcher inst)
        {
            var PyhsicalPath = PathHelper.GetDataPath(inst.WatcherFile);

            if (!File.Exists(PyhsicalPath))
            {
                PyhsicalPath = ResourceHelper.CopyToAppData(inst.GetType(), inst.WatcherFile);
            }

            using (StreamReader reader = new StreamReader(PyhsicalPath, Encoding.UTF8))
            {
                var json  = reader.ReadToEnd().Replace("\n", "").Replace("\r", "").Trim();
                var type  = inst.GetType();
                var other = JsonConvert.DeserializeObject(json, type);
                MyReflectionHelper.InvokeMethod(typeof(Mapper), "Map", new Type[] { type, type }, null, new[] { other, inst });
                // Mapper.Map(, this);
            }
        }