using System; using Hyper.ComponentModel; using System.Reflection; using System.Drawing; using System.Collections.Generic; using System.IO; using System.ComponentModel; using System.Collections; using System.Text; using System.Threading; using System.Runtime.Serialization.Formatters.Binary; using BrainTechLLC.ThreadSafeObjects; namespace BrainTechLLC { [TypeDescriptionProvider(typeof(HyperTypeDescriptionProvider)), Serializable] public class PropInfo { public PropertyInfo PropertyInfo; public PropertyDescriptor PropertyDescriptor; public StaticLookup<Type, List<Attribute>> AttributeLookup; public object GetValue(object thisObject) { return PropertyDescriptor.GetValue(thisObject); } public void SetValue(object thisObject, object newVal) { PropertyDescriptor.SetValue(thisObject, newVal); } public string Name { get { return PropertyDescriptor.Name; } } public PropInfo(PropertyInfo propertyInfo, PropertyDescriptor propertyDescriptor) { PropertyInfo = propertyInfo; PropertyDescriptor = propertyDescriptor; object[] attrs = PropertyInfo.GetCustomAttributes(true); if (attrs != null && attrs.Length > 0) { AttributeLookup = new StaticLookup<Type, List<Attribute>>(); for (int n = 0; n < attrs.Length; n++) { Attribute attr = attrs[n] as Attribute; List<Attribute> attrList = AttributeLookup.Get(attr.GetType()); attrList.Add(attr); } } } public T[] GetAttributes<T>() where T : class { List<Attribute> attrs = Attributes(typeof(T)); if (attrs == null || attrs.Count == 0) return null; T[] results = new T[attrs.Count]; for (int n = 0; n < attrs.Count; n++) { results[n] = attrs[n] as T; } return results; } public List<Attribute> Attributes(Type t) { return (AttributeLookup == null) ? null : AttributeLookup.Get(t); } } }
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)