Skip to content

Instantly share code, notes, and snippets.

Created February 5, 2011 19:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/812713 to your computer and use it in GitHub Desktop.
Save anonymous/812713 to your computer and use it in GitHub Desktop.
Find a form that implements an specific Generic Interace Modulo.Controle.IMessageForm<T>
foreach(var form in form formType in (from type in GetType.Assembly.GetTypes()
where !type.IsAbstract && type.IsSubClassOf(typeof(Form)) && type.GetInterfaces().Any(i => i.IsGenericType) select type)
let intForm = formType.GetInterface("ModuloControle.IMessageForm'1")
where intForm != null && intForm.GetGenericArguments()[0] == myDesiredType
select (Form) GetType().Assembly.CreateInstance(formType.FullName)
{ ... }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment