The name is a little tired, but easier to see in the code:
public struct MyStruct {
public bool HasAttribute(Attribute attribute) {
return ??????;
}
}
public class MyClass {
[SomeAttribute]
MyStruct child;
public MyClass() {}
}
I already know how to find attributes on MyClass.child
by getting property information for each of my properties and then calling GetCustomAttributes
, but this only works if I know that the struct instance matches MyClass.child
. I would like to do here to find out if a particular instance of the structure has attributes associated with it, not knowing which class contains the particular instance.
It would be wise for me if you could not do this for reference types, because an instance can reference from several places, but should the attribute set always be well defined for value types?
, . , . , .