Hi there
I am trying to determine the type of a property which an attribute relates to, from within the attributes constructor. More specificity I am looking for the class which contains the property.
my current constructor looks like this:
public IndexedCategoryAttribute(Type DefiningClass, String HeaderText, int Index)
{
this._definingClass = DefiningClass;
however I want it to look like:
public IndexedCategoryAttribute(String HeaderText, int Index)
{
PropertyInfo Info = ???
this._definingClass = Info.DeclaringType;
I believe that this will provide safer code for users of the attribute since at present it requires a 'typeof(MyClass)' in the the Attribute definition, which opens the posiblity of the wrong type being supplied?
For further information, I am using this with the propertygrid. The type is used in a static Dictionary<Type, Dictionary<String, int>>
for grouping category's to the class they relate to.