lundi 10 février 2020

C# .net core conditional construction of class

I am creating a ASP.NET Core Rest API application.

On Controller, depending upon the value of parameter we need to create request processor {job of the processor is to further process the request and perform business logic}.

Now with .net core DI how can we construct object when we have some condition to execute on run-time data before system identify what type of object we need to create/construct.

I can think of ServiceLocator, but it's anti-pattern. What should be proper approach to solve it.

Aucun commentaire:

Enregistrer un commentaire