Esempio n. 1
0
        private bool ClonePropertyHandler(PropertyInfo pi, object value, object target)
        {
            if (!pi.CanWrite)
            {
                return(true);
            }

            pi.SetValue(target, CDObject.TryClone(value), null);

            return(true);
        }
        public static IList Clone(this IList source)
        {
            if (source == null)
            {
                return(null);
            }

            MethodInfo mi = source.GetType().GetMethod("Clone");

            if (mi != null)
            {
                return((IList)mi.Invoke(source, null));
            }

            IList      list      = Activator.CreateInstance(source.GetType()) as IList;
            MethodInfo addMethod = list.GetType().GetMethod("Add");

            foreach (object item in source)
            {
                addMethod.Invoke(list, new object[] { CDObject.TryClone(item) });
            }

            return(list);
        }