lundi 13 novembre 2017

Organizing inherited services in webapi controller

My problem is this:

  1. I need to call two different services with similar API through HTTP. Lets say I derived IBaseService with two methods - MakeOrder and CancelOrder.
  2. Service I want to call is determined by request I receive - It contains serviceToCall attribute.
  3. I use Asp.NET core basic dependency container and want to have nice code - some workaround'd be easy thought.

The thing is that I got lost in all the patterns and approaches I can choose (besides DI Factory method or Strategy came to my mind).

Could you guys give me a hint how to solve the isue? I bet there is a way how to do it without if statement in every method.

Aucun commentaire:

Enregistrer un commentaire