Is there a design pattern for this ?

Posted by ytrewq on Stack Overflow See other posts from Stack Overflow or by ytrewq
Published on 2010-05-03T17:47:54Z Indexed on 2010/05/03 18:08 UTC
Read the original article Hit count: 191

Filed under:
|
|
|

I have a component that needs to call a specific service depending on the input it receives. So my component has to look at the input and based on a configuration that says "for this input call this service with this data" needs to call the proper service. The services have a common signature method and a specific one (each).

I thought about an abstract class that includes the signatures for all three methods. The implementation for the two services will override all three methods (throwing NotImplementedException for the methods that are not supported by current service). A component that could be initialized with a map (that for each input type will have the type of the service to be called) will also be defined.

Do you have a better approach to cope this scenario ?

© Stack Overflow or respective owner

Related posts about c#

Related posts about factory