mercredi 27 mars 2019

Get Direct Implementations of Interface in C#

I have an interface IFoo in C#.

I have these implementations:

  • public class Foo : IFoo
  • public interface IBar : IFoo
  • public class Bar : IBar
  • public interface IBuzz : IBar

Is there a way, using reflection and the type of IFoo, that I can obtain the types of Foo and IBar (i.e. only the direct implementations of IFoo; I want to exclude other types or interfaces)? I've done some preliminary searching on here but I'm only finding answers that are 5+ years old that don't quite cut the mustard (either they don't work, or they don't correctly filter out all the types to direct implementations only).





Aucun commentaire:

Enregistrer un commentaire