Created
December 22, 2016 15:10
-
-
Save lakario/4cf7f7800c37480fb8568328055d99cd to your computer and use it in GitHub Desktop.
.NET doesn't provide a method to reflect the immediate interface ancestors of a given type, this method accomplishes that.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private IEnumerable<Type> GetClosestInterfaces(Type type) | |
{ | |
IEnumerable<Type> interfaces = type.GetInterfaces(); | |
var parents = interfaces.Except( | |
interfaces.SelectMany(x => x.GetInterfaces()).Intersect(interfaces)); | |
return parents; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment