I would like to be able to inject a number of dependent dependencies in a class using structural map, if this is possible the main reason I I want this connection to string injection right now.
I am doing it wrong, but here's how I got it (just need to add injection now):
psuedo:
There the connection string is to put a name on the constructor parameter so that StructureMap will know how it is in any way needle?
Edit: I can have more than one connection string, which are defined from the configuration database to run-time.
Edit: A solution I 'has been thought about is a DynamicConnectionString and a ThatDatabaseConnectionString class ... that way it could inject string based on connection type
After
You can do this (assuming that myConnectionString Is a string example):
container.Configure (r = & gt; R .ConcreteType & lt; MyServiceClass & gt; () .configher.ktr ( ) What is (myConnectionString)); If you need to map MyServiceClass from the interface (or abstract base class), you can do it instead:
container Configure (r = & gt; r. & Lt; IServiceClass & gt; () .Use & lt; MyServiceClass & gt; () .tor & lt; string & gt; () (myConnectionString)); If you have pre-configured connection connections configured in the container, then you can do something like this:
container Configure (r = & gt; r. & Gt; string & gt; (). Use ("foo"). Named ("connStr1")); Container. Configure (r = & gt; r string & gt; (). Use ("bar"). Named ("connStr2")); Container.Configure (r = & gt; R .ConcreteType & lt; MyServiceClass & gt; () .Configure.Ctor & lt; string & gt ;. () ((iConText ctx) is => ctx.getInstance & LT ; String & gt; ("connStr2"));
Comments
Post a Comment