public CaseModel Func_GetValue_SetValue() { return(new CaseModel() { NameSign = @"获取/设置值", ExeEvent = () => { GS answer = new GS() { Age = RandomData.GetInt(), DateOfBirth = RandomData.GetDateTime(), Name = RandomData.GetChineseString(), Price = RandomData.GetDouble(), Sex = RandomData.Item(EnumInfo.GetALLItem <GS.SexEnum>()), }; GS result = new GS(); ShineUponParser parser = new ShineUponParser(typeof(GS)); foreach (ShineUponInfo info in parser.GetDictionary().Values) { KeyString ks = parser.GetValue_KeyString(info, answer); parser.SetValue_Object(info, result, ks.Value); } return true; }, }); }
public CaseModel Func_FieldModelParser() { return(new CaseModel() { NameSign = @"字段", ExeEvent = () => { ShineUponParser parser = new ShineUponParser(typeof(F)); KeyString[] keys = F.Answer_FieldInfos(); return new VerifyIList <YTS.Tools.Model.KeyString, ShineUponInfo>(CalcWayEnum.DoubleCycle) { Answer = keys, Source = new List <ShineUponInfo>(parser.GetDictionary().Values), Func_isEquals = (item, info) => { return item.Key == info.Name && item.Key == info.Property.Name && item.Value == info.Explain.Text; }, Func_lengthNotEquals = (len_key, len_column) => { Console.WriteLine("keys.Length: {0} columns.Length: {1} 不相等", len_key, len_column); }, Func_notFind = (item) => { Console.WriteLine("Key: {0} Value: {1} 没找到", item.Key, item.Value); }, }.Calc(); }, }); }
/// <summary> /// 读取: ini.file => model /// </summary> public void IniConfig_Read(AbsShineUpon model) { Type mtype = model.GetType(); string section_name = mtype.FullName; ShineUponParser perser = new ShineUponParser(mtype); foreach (ShineUponInfo info in perser.GetDictionary().Values) { string sinival = ReadString(section_name, info.Name, string.Empty); if (CheckData.IsStringNull(sinival)) { continue; } perser.SetValue_Object(info, model, sinival); } }
public CaseModel Func_SystemConfig() { return(new CaseModel() { NameSign = @"系统配置", ExeEvent = () => { SystemConfig sys_config = GlobalSystemService.GetInstance().Config.Get <SystemConfig>(); Console.WriteLine("Config:"); ShineUponParser parser = new ShineUponParser(typeof(SystemConfig)); foreach (ShineUponInfo info in parser.GetDictionary().Values) { KeyObject ko = parser.GetValue_KeyObject(info, sys_config); Console.WriteLine("info.Name: {0} ko.Key: {1} ko.Value: {2}", info.Name, ko.Key, ko.Value); } return true; }, }); }
/// <summary> /// 读取: model => ini.file /// </summary> public void IniConfig_Write <M>(M model) where M : AbsShineUpon { if (CheckData.IsObjectNull(model)) { return; } Type mtype = model.GetType(); string section_name = mtype.FullName; ShineUponParser perser = new ShineUponParser(mtype); foreach (ShineUponInfo info in perser.GetDictionary().Values) { KeyString ks = perser.GetValue_KeyString(info, model); if (CheckData.IsObjectNull(ks)) { continue; } WriteString(section_name, info.Name, ks.Value); } }