0
public interface IEntity<T> {}
public interface IUserEntity:IEntity<User> {}
public class UserEntity: IUserEntity{}

So my question is: how can I find all the 'IUserEntity'-like interfaces, as well as all the 'UserEntity'-like implementations inside an assembly?

Nico
  • 497
  • 1
  • 4
  • 15
  • What did you try? – Klaus Gütter Dec 14 '20 at 10:24
  • I think this might help you along: https://stackoverflow.com/q/8645430/10608418 –  Dec 14 '20 at 10:30
  • After hours researching and experimenting, I modified the original answer from the linked post to something more intuitive, to me at least:) – Nico Dec 15 '20 at 12:11
  • Assembly.GetAssembly(typeof(IEntity<>)).GetTypes() .Where(t => t.GetInterfaces().Any( i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IEntity<>))).ToList(); – Nico Dec 15 '20 at 12:13

0 Answers0