vendredi 1 mars 2019

Creational pattern for generic objects

could someone please help with the best way of returning the concrete implementation in the following scenarios. Say I have:

public interface IThing<TInput> where TInput : RequestBase
{
    string Process(T input);
}

And then multiple implementations:

public class Thing1<T> : IThing<T> where T : ReqThing1
public class Thing2<T> : IThing<T> where T : ReqThing2

In my calling class what is the best way of wrapping the construction of those classes and returning the IThing that I want in a clean, testable way? Thanks

Aucun commentaire:

Enregistrer un commentaire