Sorry if the question sounds trivial, I've read many discussions about that problem, but I'm not 100 percent sure if I got it correctly:
I want to get all interfaces, which are implemented by a class- then I can use following code:
foreach (TypeDefinition typeItem in currentAssembly.MainModule.Types)
{
// if the class has interfaces, get them
Mono.Collections.Generic.Collection<TypeReference> interfaceList = typeItem.Interfaces;
}
So the variable "interfaceList" should now contain all interfaces, which "typeItem" implements- it does not matter if the interfaces are implemented explicitly or implicitly?
Thanks in advance for your answers!
To find out if above code is working you need to create simple assemblies with following test cases. Then code some unit test and you are done.
Test cases:
If points 5 and 6 doesn't show correct number of interfaces you can sum up "this" class interfaces and "all-parents" class interfaces
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.