public override PropertyDescriptorCollection GetProperties() { if (this._properties != null) { return(this._properties); } bool flag = true; PropertyInfo[] properties = this._component.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public); Hashtable hashtable = new Hashtable(); for (int i = properties.Length - 1; i >= 0; i--) { hashtable[properties[i].Name] = new ReflectionPropertyDescriptor(properties[i]); } if (this._component.Site != null) { System.ComponentModel.Design.ITypeDescriptorFilterService typeDescriptorFilterService = (System.ComponentModel.Design.ITypeDescriptorFilterService) this._component.Site.GetService(typeof(System.ComponentModel.Design.ITypeDescriptorFilterService)); if (typeDescriptorFilterService != null) { flag = typeDescriptorFilterService.FilterProperties(this._component, hashtable); } } PropertyDescriptor[] array = new PropertyDescriptor[hashtable.Values.Count]; hashtable.Values.CopyTo(array, 0); PropertyDescriptorCollection propertyDescriptorCollection = new PropertyDescriptorCollection(array, true); if (flag) { this._properties = propertyDescriptorCollection; } return(propertyDescriptorCollection); }
public override EventDescriptorCollection GetEvents() { if (this._events != null) { return(this._events); } bool flag = true; EventInfo[] events = this._component.GetType().GetEvents(); Hashtable hashtable = new Hashtable(); foreach (EventInfo eventInfo in events) { hashtable[eventInfo.Name] = new ReflectionEventDescriptor(eventInfo); } if (this._component.Site != null) { System.ComponentModel.Design.ITypeDescriptorFilterService typeDescriptorFilterService = (System.ComponentModel.Design.ITypeDescriptorFilterService) this._component.Site.GetService(typeof(System.ComponentModel.Design.ITypeDescriptorFilterService)); if (typeDescriptorFilterService != null) { flag = typeDescriptorFilterService.FilterEvents(this._component, hashtable); } } ArrayList arrayList = new ArrayList(); arrayList.AddRange(hashtable.Values); EventDescriptorCollection eventDescriptorCollection = new EventDescriptorCollection(arrayList); if (flag) { this._events = eventDescriptorCollection; } return(eventDescriptorCollection); }
protected AttributeCollection GetAttributes(IComponent comp) { if (this._attributes != null) { return(this._attributes); } bool flag = true; ArrayList arrayList = new ArrayList(); foreach (Attribute value in this._infoType.GetCustomAttributes(false)) { arrayList.Add(value); } Type baseType = this._infoType.BaseType; while (baseType != null && baseType != typeof(object)) { foreach (Attribute value2 in baseType.GetCustomAttributes(false)) { arrayList.Add(value2); } baseType = baseType.BaseType; } foreach (Type componentType in this._infoType.GetInterfaces()) { foreach (object obj in TypeDescriptor.GetAttributes(componentType)) { Attribute value3 = (Attribute)obj; arrayList.Add(value3); } } Hashtable hashtable = new Hashtable(); for (int l = arrayList.Count - 1; l >= 0; l--) { Attribute attribute = (Attribute)arrayList[l]; hashtable[attribute.TypeId] = attribute; } if (comp != null && comp.Site != null) { System.ComponentModel.Design.ITypeDescriptorFilterService typeDescriptorFilterService = (System.ComponentModel.Design.ITypeDescriptorFilterService)comp.Site.GetService(typeof(System.ComponentModel.Design.ITypeDescriptorFilterService)); if (typeDescriptorFilterService != null) { flag = typeDescriptorFilterService.FilterAttributes(comp, hashtable); } } Attribute[] array = new Attribute[hashtable.Values.Count]; hashtable.Values.CopyTo(array, 0); AttributeCollection attributeCollection = new AttributeCollection(array); if (flag) { this._attributes = attributeCollection; } return(attributeCollection); }