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; } }