I have a class that works with a network via multiple resources. Its constructor receives arguments that are resolved at runtime by IoC container (StructureMap):
public NetworkWorker(IRetryService retryService, ILog log)
{ ... }
What I need is to control the number of resources this class uses on a use-case level - for example, client A need NetworkWorker instance that allows only one operation at a time, while client B need 10 ops at a time.
Currently this number is hardcoded in the constructor. The only way I see is to add a method void Configure(int resourceCount)
that each client of NetworkWorker would call with a different value.
Or may be there's a better way I don't see?
This class can do different things, but number of resources is required for every method call (Get/Send/etc
methods).
P.S. is this a known technique (with a Configure
method)? If it is, what's the name for it? smth like 'two-step initialization'?