Skip to content

Instantly share code, notes, and snippets.

@alexjamesbrown
Created September 17, 2012 16:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexjamesbrown/3738428 to your computer and use it in GitHub Desktop.
Save alexjamesbrown/3738428 to your computer and use it in GitHub Desktop.
Getting generic type arguments from collection
var types = Assembly.GetAssembly(typeof(Repository<>))
.GetTypes()
.Where(x => x.BaseType != null && x.BaseType.GetGenericArguments().FirstOrDefault() != null)
.Select(x => x.BaseType != null ? x.BaseType.GetGenericArguments().FirstOrDefault() : null)
.ToList();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment