Exemple #1
0
        void SetCurrent(SerialTree _serialTree, object _o, string _path)
        {
            Type         tp = _o.GetType();
            PropertyInfo pi = tp.GetProperty("Current");

            if (pi == null)
            {
                return;
            }
            int        ival = Convert.ToInt32(_serialTree[_path + ".Current"]);
            MethodInfo mi   = tp.GetMethod("get_Item", new Type[] { typeof(int) });

            try
            {
                pi.SetValue(_o, mi.Invoke(_o, new object[] { ival }), null);
            }
            catch
            {
                pi.SetValue(_o, null, null);
            }
        }
Exemple #2
0
 protected void ExecLoad(SerialTree _serialTree, object _o, string _path)
 {
     foreach (PropertyInfo pi in _o.GetType().GetProperties())
     {
         if (Attribute.GetCustomAttribute(pi, typeof(De)) == null)
         {
             continue;
         }
         string ipath = _path + "." + pi.Name;
         object io    = (_o as IParent).AddNew(pi);
         if (io == null)
         {
             if (Attribute.GetCustomAttribute(pi, typeof(PasswordPropertyTextAttribute)) == null)
             {
                 pi.SetValue(_o, GetValue(pi, ipath, _serialTree[ipath]), null);
             }
             else
             {
                 using (Cry cry = new Cry())
                 {
                     string bpwd = cry.from(_serialTree[ipath]);
                     pi.SetValue(_o, bpwd, null);
                 }
             }
         }
         if (io is IParent)
         {
             ExecLoad(_serialTree, io, ipath);
         }
         if (io is IParentList)
         {
             foreach (string npath in _serialTree.GetList(ipath))
             {
                 ExecLoad(_serialTree, (io as IParentList).AddNew(), npath);
             }
             SetCurrent(_serialTree, io, ipath);
         }
     }
 }