Ejemplo n.º 1
0
        public static object Copy(object source)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            TypeAccessor ta = GetAccessor(source.GetType());

            return(CopyInternal(source, ta.CreateInstanceEx(), ta));
        }
Ejemplo n.º 2
0
        public PropertyDescriptorCollection CreateExtendedPropertyDescriptors(
            Type objectViewType,
            IsNullHandler isNull)
        {
            // This is definitely wrong.
            //
            //if (isNull == null)
            //	isNull = _isNull;

            PropertyDescriptorCollection pdc;

            pdc = CreatePropertyDescriptors();

            if (objectViewType != null)
            {
                TypeAccessor viewAccessor      = GetAccessor(objectViewType);
                IObjectView  objectView        = (IObjectView)viewAccessor.CreateInstanceEx();
                List <PropertyDescriptor> list = new List <PropertyDescriptor>();

                PropertyDescriptorCollection viewpdc = viewAccessor.PropertyDescriptors;

                foreach (PropertyDescriptor pd in viewpdc)
                {
                    list.Add(new ObjectViewPropertyDescriptor(pd, objectView));
                }

                foreach (PropertyDescriptor pd in pdc)
                {
                    if (viewpdc.Find(pd.Name, false) == null)
                    {
                        list.Add(pd);
                    }
                }

                pdc = new PropertyDescriptorCollection(list.ToArray());
            }

            pdc = pdc.Sort(new PropertyDescriptorComparer());

            pdc = GetExtendedProperties(pdc, OriginalType, String.Empty, Type.EmptyTypes, new PropertyDescriptor[0], isNull);

            return(pdc);
        }
Ejemplo n.º 3
0
 public static T CreateInstanceEx <T>()
 {
     return(TypeAccessor <T> .CreateInstanceEx());
 }