/// <summary> /// 载入解决方案 /// </summary> /// <param name="sluFile"></param> public void Load(string sluFile) { Context.StateMessage = "正在载入..."; Context.Solution = ConfigLoader.Load(sluFile); Context.StateMessage = "载入成功"; Model.OnSolutionChanged(); }
/// <summary> /// 升级配置类 /// </summary> /// <returns></returns> public void Load() { var path = IOHelper.CheckPath(@"C:\Projects\AgebullDesigner", "UpgradeDocument"); var files = IOHelper.GetAllFiles(path, "cfg"); RootConfig.ConfigTypes.Clear(); foreach (var file in files) { RootConfig.ConfigTypes.Add(ConfigLoader.DeSerializer <ClassUpgradeConfig>(file)); } }
/// <summary> /// 载入 /// </summary> /// <param name="sluFile"></param> public static SolutionConfig Load(string sluFile) { ConfigLoader loader = new ConfigLoader(); loader.LoadSolution(GlobalConfig.CheckPath(GlobalConfig.ProgramRoot, "Global"), "global.json", true); GlobalConfig.GlobalSolution = loader._solution; if (string.IsNullOrEmpty(sluFile) || string.Equals(sluFile, GlobalConfig.GlobalSolution.SaveFileName, StringComparison.OrdinalIgnoreCase)) { return(GlobalConfig.GlobalSolution); } loader = new ConfigLoader(); loader.LoadSolution(Path.GetDirectoryName(sluFile), Path.GetFileName(sluFile), false); return(loader._solution); }
/// <summary> /// 保存通知对象 /// </summary> public void SaveConfig <TConfig>(string filename, TConfig config, bool checkState) where TConfig : FileConfigBase { if (config.SaveFileName != null) { if (File.Exists(config.SaveFileName) && checkState) { if (config.Option.IsDelete) { var old = ConfigLoader.DeSerializer <TConfig>(config.SaveFileName); if (old != null) { if (old.IsDelete) { return; } config = old; config.Option.IsDelete = true; } } if (config.Option.IsLock) { return; } } if (!string.Equals(config.SaveFileName, filename, StringComparison.OrdinalIgnoreCase) && File.Exists(config.SaveFileName)) { File.Delete(config.SaveFileName); } } if (config.Option.CanLock) { config.Option.LockConfig(); } try { string json = JsonConvert.SerializeObject(config); File.WriteAllText(filename, json, Encoding.UTF8); config.SaveFileName = filename; } catch (Exception e) { Trace.WriteLine(e.ToString()); } }
private void LoadFile(string sluFile) { Context.Solution = ConfigLoader.Load(sluFile); Context.FileName = sluFile; SaveLastSolution(); }