예제 #1
0
 public PropertyDescriptorCollection GetItemProperties(
     PropertyDescriptor[] listAccessors,
     Type objectViewType,
     IsNullHandler isNull,
     bool cache)
 {
     return(TypedListImpl.GetItemProperties(listAccessors, objectViewType, isNull, cache));
 }
예제 #2
0
 public StandardPropertyDescriptor(
     PropertyDescriptor pd,
     string namePrefix,
     PropertyDescriptor[] chainAccessors,
     IsNullHandler isNull)
     : base(pd)
 {
     _descriptor     = pd;
     _isNull         = isNull;
     _prefixedName   = namePrefix + pd.Name;
     _chainAccessors = chainAccessors;
 }
예제 #3
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);
        }
예제 #4
0
		public PropertyDescriptorCollection GetItemProperties(
			PropertyDescriptor[] listAccessors,
			Type                 objectViewType,
			IsNullHandler        isNull,
			bool                 cache)
		{
			return TypedListImpl.GetItemProperties(listAccessors, objectViewType, isNull, cache);
		}
예제 #5
0
        private static PropertyDescriptorCollection GetExtendedProperties(
            PropertyDescriptorCollection pdc,
            Type itemType,
            string propertyPrefix,
            Type[]                       parentTypes,
            PropertyDescriptor[]         parentAccessors,
            IsNullHandler isNull)
        {
            ArrayList list      = new ArrayList(pdc.Count);
            ArrayList objects   = new ArrayList();
            bool      isDataRow = itemType.IsSubclassOf(typeof(DataRow));

            foreach (PropertyDescriptor p in pdc)
            {
                Type propertyType = p.PropertyType;

                if (p.Attributes.Matches(BindableAttribute.No) ||
                    //propertyType == typeof(Type)               ||
                    isDataRow && p.Name == "ItemArray")
                {
                    continue;
                }

                bool isList           = false;
                bool explicitlyBound  = p.Attributes.Contains(BindableAttribute.Yes);
                PropertyDescriptor pd = p;

                if (propertyType.GetInterface("IList") != null)
                {
                    //if (!explicitlyBound)
                    //	continue;

                    isList = true;
                    pd     = new ListPropertyDescriptor(pd);
                }

                if (!isList &&
                    !propertyType.IsValueType &&
                    !propertyType.IsArray &&
                    (!propertyType.FullName.StartsWith("System.") || explicitlyBound ||
                     propertyType.IsGenericType) &&
                    propertyType != typeof(Type) &&
                    propertyType != typeof(string) &&
                    propertyType != typeof(object) &&
                    Array.IndexOf(parentTypes, propertyType) == -1)
                {
                    Type[] childParentTypes = new Type[parentTypes.Length + 1];

                    parentTypes.CopyTo(childParentTypes, 0);
                    childParentTypes[parentTypes.Length] = itemType;

                    PropertyDescriptor[] childParentAccessors = new PropertyDescriptor[parentAccessors.Length + 1];

                    parentAccessors.CopyTo(childParentAccessors, 0);
                    childParentAccessors[parentAccessors.Length] = pd;

                    PropertyDescriptorCollection pdch = GetAccessor(propertyType).PropertyDescriptors;

                    pdch = pdch.Sort(new PropertyDescriptorComparer());
                    pdch = GetExtendedProperties(
                        pdch,
                        propertyType,
                        propertyPrefix + pd.Name + "+",
                        childParentTypes,
                        childParentAccessors,
                        isNull);

                    objects.AddRange(pdch);
                }
                else
                {
                    if (propertyPrefix.Length != 0 || isNull != null)
                    {
                        pd = new StandardPropertyDescriptor(pd, propertyPrefix, parentAccessors, isNull);
                    }

                    list.Add(pd);
                }
            }

            list.AddRange(objects);

            return(new PropertyDescriptorCollection(
                       (PropertyDescriptor[])list.ToArray(typeof(PropertyDescriptor))));
        }
예제 #6
0
		public PropertyDescriptorCollection GetItemProperties(
			PropertyDescriptor[] listAccessors,
			Type                 objectViewType,
			IsNullHandler        isNull,
			bool                 cache)
		{
			PropertyDescriptorCollection pdc = null;

			if (listAccessors == null || listAccessors.Length == 0)
			{
				if (_pdc == null)
				{
					_pdc = _typeAccessor != null?
						_typeAccessor.CreateExtendedPropertyDescriptors(objectViewType, isNull):
						new PropertyDescriptorCollection(null);
				}

				pdc = _pdc;

				if (!cache)
					_pdc = null;
			}
			else
			{
				try
				{
					// Lets try to pick out the item type from the list type.
					//
					Type itemType = TypeHelper.GetListItemType(
						listAccessors[listAccessors.Length - 1].PropertyType);

					if (itemType == typeof(object))
					{
						TypeAccessor parentAccessor = _typeAccessor;

						foreach (PropertyDescriptor pd in listAccessors)
						{
							// We have to create an instance of the list to determine its item type
							//

							// Create an instance of the parent.
							//
							object parentObject = parentAccessor.CreateInstanceEx();

							// Create an instance of the list.
							//
							object listObject   = pd.GetValue(parentObject);

							if (listObject == null)
							{
								// We failed. Item type can not be determined.
								//
								itemType = null;

								break;
							}

							itemType = TypeHelper.GetListItemType(listObject);

							// Still bad.
							//
							if (itemType == typeof(object))
								break;

							parentAccessor = TypeAccessor.GetAccessor(itemType);
						}
					}

					if (itemType != null && itemType != typeof(object))
					{
						TypeAccessor ta = TypeAccessor.GetAccessor(itemType);

						pdc = ta.CreateExtendedPropertyDescriptors(null, isNull);
					}
				}
				catch
				{
				}

				if (pdc == null)
					pdc = new PropertyDescriptorCollection(null);
			}

			return pdc;
		}
예제 #7
0
        public PropertyDescriptorCollection GetItemProperties(
            PropertyDescriptor[] listAccessors,
            Type objectViewType,
            IsNullHandler isNull,
            bool cache)
        {
            PropertyDescriptorCollection pdc = null;

            if (listAccessors == null || listAccessors.Length == 0)
            {
                if (_pdc == null)
                {
                    _pdc = _typeAccessor != null?
                           _typeAccessor.CreateExtendedPropertyDescriptors(objectViewType, isNull) :
                               new PropertyDescriptorCollection(null);
                }

                pdc = _pdc;

                if (!cache)
                {
                    _pdc = null;
                }
            }
            else
            {
                try
                {
                    // Lets try to pick out the item type from the list type.
                    //
                    Type itemType = TypeHelper.GetListItemType(
                        listAccessors[listAccessors.Length - 1].PropertyType);

                    if (itemType == typeof(object))
                    {
                        TypeAccessor parentAccessor = _typeAccessor;

                        foreach (PropertyDescriptor pd in listAccessors)
                        {
                            // We have to create an instance of the list to determine its item type
                            //

                            // Create an instance of the parent.
                            //
                            object parentObject = parentAccessor.CreateInstanceEx();

                            // Create an instance of the list.
                            //
                            object listObject = pd.GetValue(parentObject);

                            if (listObject == null)
                            {
                                // We failed. Item type can not be determined.
                                //
                                itemType = null;

                                break;
                            }

                            itemType = TypeHelper.GetListItemType(listObject);

                            // Still bad.
                            //
                            if (itemType == typeof(object))
                            {
                                break;
                            }

                            parentAccessor = TypeAccessor.GetAccessor(itemType);
                        }
                    }

                    if (itemType != null && itemType != typeof(object))
                    {
                        TypeAccessor ta = TypeAccessor.GetAccessor(itemType);

                        pdc = ta.CreateExtendedPropertyDescriptors(null, isNull);
                    }
                }
                catch
                {
                }

                if (pdc == null)
                {
                    pdc = new PropertyDescriptorCollection(null);
                }
            }

            return(pdc);
        }