is there any way to get the following (not compiling) code running? i have not found a solution for this.
public class Factory{
public static T Get<T>(V v)
where T : BaseClass<V> {
T someObject = DIContainer.Resolve<T>();
someObject.Set(v);
}
}
T is a normal generic type parameter, used to define the generic method "Get", but has a type constraint which contains a generic itself.
Now the method should define a parameter of which the type is defined by a generic type parameter defined by the generic type parameter of the method.
BaseClass would define a method Set receiving an argument of the type of its generic type parameter.
Meaning it should be possible to call Factory.Get<A<B>>(someObjectCastableToB);.
It would work by defining the method Get as Get with another constraint on V. But then the call would be Factory.Get<A<B>,B>(....) which is not that nice as the declaration of B is there two times.
Thanks!
Vdefined in your code snippet?