public MainForm(ConfigDic config) { setting = new Setting(config); InitializeComponent(); Version v = Assembly.GetExecutingAssembly().GetName().Version; VersionText.Text = "Version: "; VersionText.Text += v.Major + "." + v.Minor + "." + v.Build; }
/// <summary> /// override method of BaseAction.<br></br> /// </summary> /// <param name="context">input parameter</param> /// <returns>if successful,return the result.</returns> public override BaseActionResult Execute(Context context) { DataSetActionResult result = new DataSetActionResult(); ConfigDic obj = new ConfigDic(); DsConfigDic ds = obj.Load(1); result.Result = true; result.DataSetData = ds; return(result); }
protected override void AddParsers(ConfigDic configDic) { configDic.AddParser(str => (CheckState)Enum.Parse(typeof(CheckState), str)); configDic.AddParser(str => { var format = Regex.Match(str, @"[^\s]+").Value; var strMatch = Regex.Match(Regex.Replace(str, @"[^\s]+\s(.*)", "$1"), @"([^\|]+)"); var strs = new List <string>(); while (strMatch.Value != string.Empty) { strs.Add(strMatch.Value); strMatch = strMatch.NextMatch(); } return(new LineSetting(format, strs.ToArray())); }); configDic.AddParser(str => { try { return(Encoding.GetEncoding(str)); } catch { return(int.TryParse(str, out int codePage) ? Encoding.GetEncoding(codePage) : throw new InvalidCastException()); } }); configDic.AddParser(str => { Match match = Regex.Match(str, @"\((?<X>-?\d+), (?<Y>-?\d+)\)"); if (match.Success) { return(new Point(int.Parse(match.Groups["X"].Value), int.Parse(match.Groups["Y"].Value))); } throw new InvalidCastException(); }); configDic.AddParser(str => { Match match = Regex.Match(str, @"(?<X>\d+) \* (?<Y>\d+)"); if (match.Success) { return(new Size(int.Parse(match.Groups["X"].Value), int.Parse(match.Groups["Y"].Value))); } throw new InvalidCastException(); }); }
public MainForm(ConfigDic config) { folderBrowser = new CommonOpenFileDialog(); folderBrowser.Title = "ERB파일이 들어있는 폴더를 선택해주세요"; folderBrowser.IsFolderPicker = true; setting = new Setting(config); setting.Load(); InitializeComponent(); Version v = Assembly.GetExecutingAssembly().GetName().Version; VersionText.Text = "Version: "; VersionText.Text += v.Major + "." + v.Minor + "." + v.Build; }
/// <summary> /// 得到配置信息 /// </summary> /// <param name="key">键</param> /// <returns>值</returns> public static string GetConfigDic(string key) { if (ConfigDic == null) { return(""); } if (ConfigDic.ContainsKey(key)) { return(ConfigDic[key]); } else { return(""); } }
/// <summary> /// 设置配置信息 /// </summary> /// <param name="key">键</param> /// <param name="value">值</param> public static void SetConfigDic(string key, string value) { if (ConfigDic == null) { ConfigDic = new Dictionary <string, string>(); } if (ConfigDic.ContainsKey(key)) { ConfigDic[key] = value; } else { ConfigDic.Add(key, value); } }
static void Main(string[] args) { Properties.Settings.Default.Reload(); if (!Directory.Exists(ResourceFolderPath)) { Directory.CreateDirectory(ResourceFolderPath); } if (!Directory.Exists(RootPath + "Backup")) { Directory.CreateDirectory(RootPath + "Backup"); } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); try { string ezPath = ""; ConfigDic config = new ConfigDic(); config.Load(ConfigFilePath); if (!config.TryGetValue("ezTransXP_Path", out ezPath)) { FolderBrowserDialog dialog = new FolderBrowserDialog(); dialog.ShowNewFolderButton = true; dialog.Description = "ezTrans XP가 설치된 경로를 선택해 주세요"; dialog.ShowDialog(); ezPath = dialog.SelectedPath; config.SetValue("ezTransXP_Path", ezPath); dialog.Dispose(); } int result = TranslateXP.Initialize(ezPath); if (result != 0) { MessageBox.Show("EZTransXP 로드에 실패하였습니다.\nCode: " + result); return; } Application.Run(new MainForm(config)); config.Save(ConfigFilePath); TranslateXP.Terminate(); } catch (Exception e) { FileStream fs = new FileStream(LogFilePath, FileMode.Create); new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter().Serialize(fs, e); fs.Flush(); fs.Dispose(); Trace.Assert(false, e.Message); } }
static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); #if !DEBUG try { #endif var config = new ConfigDic(); config.Load(new FileStream(ConfigFilePath, FileMode.OpenOrCreate)); if (!config.TryGetValue("ezTransXP_Path", out string ezPath)) { var dialog = new FolderBrowserDialog() { ShowNewFolderButton = true, Description = "ezTrans XP가 설치된 경로를 선택해 주세요" }; dialog.ShowDialog(); ezPath = dialog.SelectedPath; config.SetValue("ezTransXP_Path", ezPath); dialog.Dispose(); } int result = TranslateXP.Initialize(ezPath); if (result != 0) { MessageBox.Show("EZTransXP 로드에 실패하였습니다.\nCode: " + result); return; } Application.Run(new MainForm(config)); config.Save(new FileStream(ConfigFilePath, FileMode.Create)); TranslateXP.Terminate(); #if !DEBUG } catch (Exception e) { var fs = new FileStream(LogFilePath, FileMode.Create); new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter().Serialize(fs, e); fs.Flush(); fs.Dispose(); MessageBox.Show(e.Message + "\r\n\r\n\r\n" + e.StackTrace, "에러발생!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } #endif }
private ConfigDicMgr() { this.m_szCfgFilePath = System.Configuration.ConfigurationManager.AppSettings["ConfigDicFilePath"]; this.m_dsConfigDic = new DsConfigDic(); ConfigDic obj = new ConfigDic(); DsConfigDic ds = obj.Load(2); this.m_dsConfigDic.Merge(ds); DsConfigDic ds1 = new DsConfigDic(); try { ds1.ReadXml(this.m_szCfgFilePath); this.m_dsConfigDic.Merge(ds1, false); } catch { } }
public int SetConfigDicValue(string ConfigName, string ModuleID, string Value) { DsConfigDic.ConfigDicRow Row = GetConfigDicRow(ConfigName, ModuleID); if (Row != null) { if (Row.Value.CompareTo(Value) != 0) { Row.Value = Value; Server.Business.ClientFramework.ConfigDic obj = new ConfigDic(); obj.WriteConfigDicRow(Row, 2); } } else { DsConfigDic.ConfigDicRow row; row = this.m_dsConfigDic.ConfigDic.AddConfigDicRow(ConfigName, Value, ModuleID, "", 0, "", "", 0, 0, 1, 0, "0"); Server.Business.ClientFramework.ConfigDic obj = new ConfigDic(); obj.WriteConfigDicRow(row, 2); } return(0); }
public Setting(ConfigDic config) { Config = config; }
protected override void AddWriters(ConfigDic configDic) { configDic.AddWriter <Encoding>(encoding => encoding.WebName.ToUpper()); configDic.AddWriter <Point>(p => $"({p.X}, {p.Y})"); configDic.AddWriter <Size>(s => $"{s.Width} * {s.Height}"); }
public Setting(ConfigDic config) { Config = config; config.AddParser(str => { try { return(Encoding.GetEncoding(str)); } catch { int codePage; if (int.TryParse(str, out codePage)) { return(Encoding.GetEncoding(codePage)); } else { throw new InvalidCastException(); } } }); config.AddWriter <Encoding>(encoding => encoding.WebName.ToUpper()); config.AddParser(str => (CheckState)Enum.Parse(typeof(CheckState), str)); config.AddParser(str => { var format = Regex.Match(str, @"[^\s]+").Value; var strMatch = Regex.Match(Regex.Replace(str, @"[^\s]+\s(.*)", "$1"), @"([^\|]+)"); List <string> strs = new List <string>(); while (strMatch.Value != string.Empty) { strs.Add(strMatch.Value); strMatch = strMatch.NextMatch(); } return(new LineSetting(format, strs.ToArray())); }); if (!config.HasKey(nameof(KoreanCB))) { KoreanCB = CheckState.Checked; } if (!config.HasKey(nameof(JapaneseCB))) { JapaneseCB = CheckState.Checked; } if (!config.HasKey(nameof(etcCB))) { etcCB = CheckState.Checked; } if (!config.HasKey(nameof(LineSetting))) { LineSetting = LineSetting.Default; } if (!config.HasKey(nameof(ReadEncoding))) { ReadEncoding = Encoding.UTF8; } if (!config.HasKey(nameof(IgnoreBlankERB))) { IgnoreBlankERB = true; } }