I use a Dynamic Assembly to create derived classes at run time. How can I tell, using reflection, whether the base class and individual methods in the base c开发者_运维问答lass can be used/called from within the derived class in the dynamic assembly?
There are a number of properties on the MethodInfo
and Type
objects that you can use to query visibility.
For example, for a type you can check IsPublic
, IsPrivate
, IsNotPublic
, IsNested
, IsNestedFamOrAssembly
, and a whole lot more.
For a method (the MethodInfo
object), you've got a similar set: IsPublic
,IsPrivate
, IsFamilyOrAssembly
, etc.
So combine this with information like the Assembly
property on a type (so you can tell if Type1 and Type2 are both in the same assembly) and you should be able to get all of the information you need.
精彩评论