Given the available accessibility Levels, is there any pattern or proper approach to make class A accessible only from class B and C and vice versa, where there is no inheritance relation between class A, class B and class C? (Preferrably at compile time)
A,B and C are siblings and are located in the same namespace.
So far, the only thing that comes to mind is:
- Using reflection to determine calling class and throwing exceptions (Runtime)
- Nest classes (using a base class) and use
protected
modifier
The latter seems to be the best approach, but is there any other way? I am looking for something like InternalsVisibleTo
but inside an assembly.