Пример #1
0
        /// <summary>
        /// Convert an enumeration from one type to another using the reflection class
        /// </summary>
        /// <typeparam name="SOURCE_TYPE">The type converting from</typeparam>
        /// <typeparam name="TARGET_TYPE">the type converting to</typeparam>
        /// <param name="source">The siurce object</param>
        /// <returns></returns>
        public static IEnumerable <TARGET_TYPE> ConvertTo <SOURCE_TYPE, TARGET_TYPE>(this IEnumerable <SOURCE_TYPE> source)
        {
            List <TARGET_TYPE> nlist = new List <TARGET_TYPE>();

            source.ToList().ForEach(z => nlist.Add(CustomReflection.ConvertObject <TARGET_TYPE>(z)));

            return(nlist);
        }
Пример #2
0
 /// <summary>
 /// Use reflection to create a new object of the specified type and deep copy matching members
 /// </summary>
 /// <typeparam name="TARGET_TYPE">Target type to create</typeparam>
 /// <param name="obj"></param>
 /// <returns></returns>
 public static void ConvertFrom(this Object TargetObject, Object SourceObject)
 {
     CustomReflection.CopyObject(SourceObject, TargetObject);
 }
Пример #3
0
 /// <summary>
 /// Use reflection to create a new object of the specified type and deep copy matching members
 /// </summary>
 /// <typeparam name="TARGET_TYPE">Target type to create</typeparam>
 /// <param name="obj"></param>
 /// <returns></returns>
 public static TARGET_TYPE ConvertTo <TARGET_TYPE>(this Object obj)
 {
     return(CustomReflection.ConvertObject <TARGET_TYPE>(obj));
 }