Implementing interface with generic type that is less constrained than that of a method I need to call

Viewed 160

I'm implementing an interface in order to inject custom business logic into a framework that utilizes Microsoft Unity. My core issue is that a the interface I need to implement defines the following method:

T InterfaceMethod<T>();

T has no constraints. In my code, I need to call a method from a different 3rd party library, with a method signature of

T AnotherMethod<T>() where T: class;

The type T is significant to the logic of AnotherMethod. Is there any way to call AnotherMethod<T>() within my implementation, without using reflection? I obviously need to take alternate action if T is a value type. Is there perhaps a way to autobox to work around this?

3 Answers
Related