Exemplo n.º 1
0
        /// <summary>
        /// 複製單一 Object 屬性
        /// </summary>
        /// <param name="objSource">來源 Object</param>
        /// <param name="objDest">目的 Object</param>
        /// <param name="intScope">以來源或目的 Class 的屬性為主</param>
        /// <param name="aryException">例外,不複製之屬性</param>
        public static void CopyClassToClass <T1, T2>(T1 objSource, T2 objDest, Scope intScope, params string[] aryException)
        {
            //
            var objClass = new CopyClass(typeof(T1), typeof(T2), intScope, aryException);

            objClass.CopyPropertyValue(objSource, objDest);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 複製多筆(List) Object 屬性
        /// </summary>
        /// <param name="lstSource">來源 Object list (IEnumerable)</param>
        /// <param name="lstDest">目的 Object list</param>
        /// <param name="intScope">以來源或目的 Class 的屬性為主</param>
        /// <param name="aryException">例外,不複製之屬性</param>
        public static void CopyListToList <T1, T2>(IEnumerable <T1> lstSource, ref List <T2> lstDest, Scope intScope, params string[] aryException) where T2 : class, new()
        {
            //
            T2  objDest;
            var objClass = new CopyClass(typeof(T1), typeof(T2), intScope, aryException);

            lstDest = new List <T2>();
            foreach (var objSource in lstSource)
            {
                objDest = new T2();
                objClass.CopyPropertyValue(objSource, objDest);
                lstDest.Add(objDest);
            }
        }