Пример #1
0
        public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
        {
            PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(value, attributes);
            ArrayList list = new ArrayList();

            foreach (PropertyDescriptor descriptor in properties)
            {
                Attribute attribute = descriptor.Attributes[typeof(PropertyOrderAttribute)];
                if (attribute != null)
                {
                    PropertyOrderAttribute attribute2 = (PropertyOrderAttribute)attribute;
                    list.Add(new PropertyOrderPair(descriptor.Name, attribute2.Order));
                }
                else
                {
                    list.Add(new PropertyOrderPair(descriptor.Name, 0));
                }
            }
            list.Sort();
            ArrayList list2 = new ArrayList();

            foreach (PropertyOrderPair pair in list)
            {
                list2.Add(pair.Name);
            }
            return(properties.Sort((string[])list2.ToArray(typeof(string))));
        }
Пример #2
0
        public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
        {
            PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(value, attributes);
            ArrayList arrayList1 = new ArrayList();

            foreach (PropertyDescriptor propertyDescriptor in properties)
            {
                Attribute attribute = propertyDescriptor.Attributes[typeof(PropertyOrderAttribute)];
                if (attribute != null)
                {
                    PropertyOrderAttribute propertyOrderAttribute = (PropertyOrderAttribute)attribute;
                    arrayList1.Add((object)new PropertyOrderPair(propertyDescriptor.Name, propertyOrderAttribute.Order));
                }
                else
                {
                    arrayList1.Add((object)new PropertyOrderPair(propertyDescriptor.Name, 0));
                }
            }
            arrayList1.Sort();
            ArrayList arrayList2 = new ArrayList();

            foreach (PropertyOrderPair propertyOrderPair in arrayList1)
            {
                arrayList2.Add((object)propertyOrderPair.Name);
            }
            return(properties.Sort((string[])arrayList2.ToArray(typeof(string))));
        }