I'm working on a quick project to monitor/process data. Essentially that's just monitors, schedules and processors. The monitor checks for data (ftp, local, imap, pop, etc) using a schedule and sends new data to a processor. They call have interfaces.
I'm trying to find a sane way to use config to configure what schedule/processor each monitor uses. That's pretty easy:
<monitor type="any.class.implementing.monitor">
<schedule type="any.class.implementing.schedule">
...
</schedule>
<processor type="any.class.implementing.processor" />
</monitor>
What I'm struggling with is what's the best way to configure any old monitor/schedule/processor thrown into the mix. On one hand, one could implement constructor params or properties (give ot take any syntax):
<monitor type="any.class.implementing.monitor">
<args>
<arg value="..." />
</args>
<properties>
<property name="..." value=..." />
</properties>
<schedule type="any.class.implementing.schedule">
...
</schedule>
<processor type="any.class.implementing.processor" />
</monitor>
Another solution is factory method in each interface that takes the custom config as a param:
public IMonitor Create(CustomConfigSection config);
I've seen people use both. What do you prefer? Any tricks of the trade when mapping config to constructors?
I'm a little torn as to whether DI can fit into this mess. In the end, it would be a set of bindings per monitor instance, which seems pointless except for defaults, which config could cover.