private void InitSavedData() { DurableCfg.Init(); nameSpace = ConfigurationManager.AppSettings["namespace"]; namespaceValue.Text = nameSpace + (ClassModel.IsValidNamespace(nameSpace) ? "" : " (不合法)"); for (int i = 0; i < DurableCfg.Cfg.excelFiles.Count; i++) { excelFileList.Items.Add(DurableCfg.Cfg.excelFiles[i]); } excelFileList.Items.Add("-- 浏览文件夹 --"); for (int i = 0; i < DurableCfg.Cfg.csharpOutput.Count; i++) { csharpOutputList.Items.Add(DurableCfg.Cfg.csharpOutput[i]); } csharpOutputList.Items.Add("-- 浏览文件夹 --"); if (DurableCfg.Cfg.csharpOutput.Count > 0) { csharpOutputList.SelectedIndex = 0; csharpOutput = DurableCfg.Cfg.csharpOutput[0]; } for (int i = 0; i < DurableCfg.Cfg.jsonOutput.Count; i++) { jsonOutputList.Items.Add(DurableCfg.Cfg.jsonOutput[i]); } jsonOutputList.Items.Add("-- 浏览文件夹 --"); if (DurableCfg.Cfg.jsonOutput.Count > 0) { jsonOutput = DurableCfg.Cfg.jsonOutput[0]; jsonOutputList.SelectedIndex = 0; } }
public static void Init() { string path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); path = Path.Combine(path, "TableGenerater/cfg.json"); if (File.Exists(path)) { string cfg = File.ReadAllText(path); _cfg = JsonConvert.DeserializeObject <DurableCfg>(cfg); } }
private void TableGenerater_FormClosing(object sender, FormClosingEventArgs e) { DurableCfg.Save(); excel.Close(); }