Пример #1
0
 void SaveSetting()
 {
     if (string.IsNullOrEmpty(SettingFileName) == false)
     {
         KeyValueDic dic = new KeyValueDic();
         if (System.IO.File.Exists(SettingFileName))
         {
             dic = KeyValueDic.Load(SettingFileName);
             //foreach (var item in System.IO.File.ReadLines(SettingFileName))
             //{
             //    var d = item.Split('\t');
             //    if (d.Length > 1) dic.Add(d[0], d[1]);
             //}
         }
         if (dic == null)
         {
             dic = new KeyValueDic();
         }
         foreach (var item in Properties.OfType <BaseProperty>().Where(n => n.DoSave == true))
         {
             if (dic.ContainsKey(item.Key))
             {
                 dic[item.Key] = item.Value;
             }
             else
             {
                 dic.Add(item.Key, item.Value);
             }
         }
         dic.Save(SettingFileName);
     }
 }
Пример #2
0
 void LoadSetting()
 {
     if (string.IsNullOrEmpty(SettingFileName) == false)
     {
         if (System.IO.File.Exists(SettingFileName))
         {
             var dic = KeyValueDic.Load(SettingFileName);
             if (dic != null)
             {
                 foreach (var item in Properties.OfType <BaseProperty>())
                 {
                     if (dic.ContainsKey(item.Key))
                     {
                         item.Value = dic[item.Key];
                     }
                 }
             }
         }
     }
 }