Let's say I have an interface like that:
interface IAwesome
{
T DoSomething<T>();
}
Is there any way to implement the DoSomething method with type constraint? Obviously, this won't work:
class IncrediblyAwesome<T> : IAwesome where T : PonyFactoryFactoryFacade
{
public T DoSomething()
{
throw new NotImplementedException();
}
}
This obviously won't work because this DoSomething() won't fully satisfy the contract of IAwesome - it only work for a subset of all possible values of the type parameter T. Is there any way to get this work short of some "casting black magic" (which is what I'm going to do as last resort if the answer is no)?
Honestly, I don't think it's possible but I wonder what you guys think.
EDIT: The interface in question is System.Linq.IQueryProvider so I can't modify the interface itself.