I'm trying to find a way to get access to attributes which have been applied at the property level from within an object, but am hitting a brick wall. It appears that the data is stored at the type level, but I need it at the property level.
Here's an example of what I'm trying to make:
public class MyClass
{
[MyAttribute("This is the first")]
MyField First;
[MyAttribute("This is the second")]
MyField Second;
}
public class MyField
{
public string GetAttributeValue()
{
// Note that I do *not* know what property I'm in, but this
// should return 'this is the first' or 'this is the second',
// Depending on the instance of Myfield that we're in.
return this.MyCustomAttribute.value;
}
}