コード例 #1
0
ファイル: MetaPar.cs プロジェクト: andreyV512/rag
 public void Copy(object _src, object _dst)
 {
     foreach (PropertyInfo pi_src in _src.GetType().GetProperties())
     {
         if (Attribute.GetCustomAttribute(pi_src, typeof(De)) == null)
         {
             continue;
         }
         PropertyInfo pi_dst = _dst.GetType().GetProperty(pi_src.Name);
         if (!metaDesc.SetDescription(_src, pi_src, _dst, pi_dst))
         {
             continue;
         }
         NoCopyAttribute no_copy = Attribute.GetCustomAttribute(pi_src, typeof(NoCopyAttribute)) as NoCopyAttribute;
         if (no_copy != null)
         {
             continue;
         }
         object io_dst = (_dst as IParent).AddNew(pi_dst);
         object io_src = pi_src.GetValue(_src, null);
         if (io_dst == null)
         {
             pi_dst.SetValue(_dst, io_src, null);
         }
         else
         {
             if (io_dst is IParent)
             {
                 Copy(io_src, io_dst);
             }
             if (io_dst is IParentList)
             {
                 foreach (object nio_src in io_src as IEnumerable)
                 {
                     Copy(nio_src, (io_dst as IParentList).AddNew());
                 }
                 SetCurrentCopy(io_src, io_dst);
             }
         }
     }
 }
コード例 #2
0
ファイル: ParBase.cs プロジェクト: andreyV512/rag
        public void SimpleCopy(ParBase _src)
        {
            Type tp_dst = GetType();
            Type tp_src = _src.GetType();

            if (tp_dst != tp_src)
            {
                return;
            }
            foreach (PropertyInfo pi_src in _src.GetType().GetProperties())
            {
                if (Attribute.GetCustomAttribute(pi_src, typeof(De)) == null)
                {
                    continue;
                }
                NoCopyAttribute no_copy = Attribute.GetCustomAttribute(pi_src, typeof(NoCopyAttribute)) as NoCopyAttribute;
                if (no_copy != null)
                {
                    continue;
                }
                PropertyInfo pi_dst = tp_dst.GetProperty(pi_src.Name);
                pi_dst.SetValue(this, pi_src.GetValue(_src, null), null);
            }
        }