예제 #1
0
        public static object DeepCopy(this IGroupBaseObject o)
        {
            Type t = o.GetType();

            PropertyInfo[] properties = t.GetProperties();
            Object         p          = t.InvokeMember("", System.Reflection.BindingFlags.CreateInstance, null, o, null);

            foreach (PropertyInfo pi in properties)
            {
                if (pi.CanWrite)
                {
                    object value = pi.GetValue(o, null);
                    pi.SetValue(p, value, null);
                }
            }
            return(p);
        }
예제 #2
0
        /// <summary> 获取特性 指定参数的类型的特性 </summary>
        public static T GetAttributeInfo <T>(this IGroupBaseObject o) where T : Attribute
        {
            Type t = o.GetType();

            return((T)Attribute.GetCustomAttribute(t, typeof(T)));
        }