I'm trying to clean duplicate code. The only difference are calls like
MyType x = Foo.LookupService<MyType>();
vs.
MyType x = Bar.FindService<MyType>();
So we have two mehtods of type T xxx<T>()
, i.e. a method returning an instance of T
given the class parameter T
. How could I pass such functions as a parameter to a method that tries to find instances of different types, something like
foo([magic generics stuff] resolve)
{
MyType x = resolve<MyType>();
MyOtherType y = resolve<MyOtherType>();
}