sta*_*chu 10 c# reflection inheritance cil mono.cecil
我正在使用Mono.Cecil在Assembly中查找派生类型的类型.Normaly可以使用IsAssignableFrom()方法完成,但我不能在Cecil中使用它.有没有这样的方法或其他方法来检查它?谢谢迈克
我从来没有用 Mono 做过任何事情,更不用说 Cecil,但浏览 GitHub 源代码,我猜你可能可以用 aTypeDefinition类型做一些事情:
public bool HasInterface(TypeDefinition type, string interfaceFullName)
{
return (type.Interfaces.Any(i => i.FullName.Equals(interfaceFullName))
|| type.NestedTypes.Any(t => HasInterface(t, interfaceFullName)));
}
Run Code Online (Sandbox Code Playgroud)