Reputation: 315
In this scenario:
class MyClass
{
[MyAttribute("flag")]
public OtherClass Property {get; set;)
// etc.
}
Is there a way for code in OtherClass
to access the "flag" without knowledge of MyClass
?
Upvotes: 0
Views: 45
Reputation: 62157
Nope. Because OtherClass is totally independent and does not know where it is used. Well, in theory - yes. Load ALL classes, go through them, find all references, analyze for attribute via reflection. Depending on size and locality (in one assembly, in all assemblies) this may be slow or "oh damn, waht happened it is REALLLY slow", but yes, you can get access to all assemblies, all classes and use reflection on those.
Upvotes: 1