Ok, maybe that title didn't make much sense, but here is the deal. Say I have a generic method with multiple type constraints, this this:
public static void DoSomethingAwesome<T>(T thing)
where T : IThing, IAwesome, IComparable<T>
{
...
}
Now.... how can I, using reflection, create something I can send in there?
If it was only one constraint I know I can do it like this:
var types = assembly
.GetTypes()
.Where(typeof (IThing).IsAssignableFrom)
foreach(var t in types)
DoSomethingAwesome((IThing) Activator.CreateInstance(t));
But, can't really cast to multiple interfaces... how on earth can I solve this? You could say I am pretty much lost here now :P
Title got kind of long and complex as I wasn't sure what to call this, please improve if you can