c# - Castle Windsor instance configuration -
i trying implement configuration (from distributed cache) injection using castle windsor message handler.
the configuration of single instance straight forward, i'm not sure best way provide different configuration multiple instances, injected same class
i have following class hierarchy, , injection working ok, cant create different configurations iadapter instances:
public interface iadapter { void send(string message) string receive(); } public interface imsmqadapterconfig { string queuename {get;set;} } public class msmqadapter { private readonly imsmqadapterconfig _config; public imsmqadapter(imsmqadapterconfig config) { _config = config; } public void send(string message) { string queuename = _config.queuename; // queuename } } public class messageprocessor { private readonly iadapter _input; private readonly iadapter _output; public messageprocessor(iadapter input, iadapter output) { _input = input; _output = output; } public void run() { string msg = _input.receive(); // message _output.send(msg); } }
i create factory class resolve problem, however, prefer keep dependencies transparent.
in above example, register single instance of msmqadapter, however, change imsmqadapterconfig instance, , hence queue name (simplified example) each adapter instance
i understand, register 2 instances of imsmqadapter, , tightly couple configuration instance, again, i'm looking bit cleaner that.
is possible?
Comments
Post a Comment