c# - How to specify named instance as constructor parameter for type that are auto-registered for StructureMap -


using structuremap, have types auto registered.

public class messageregistry : registry {     public messageregistry(){         scan(x =>              {                  x.assemblycontainingtype(typeof (formathelper));                  x.connectimplementationstotypesclosing(typeof (imessage<>));              });     } } 

so, in case imessage<currency>, find below type:

currencymessagehandler : imessage<currency> {     public currencymessagehandler(isession instance)  } 

as constructor parameter type isession, auto wired, however, have got more 1 implementation sqlsession , oraclesession. in case, pass sqlsession constructor parameter.

how specify named instance constructor parameter in case?

much appreciated.

i had same exact problem , solved excluding type scan , custom configuring it:

scan(scan => scan.exclude(t => t == typeof(currencymessagehandler)); 

and then:

for<imessage<currency>>.add<currencymessagehandler>()      .ctor<isession>.is(a => a.theinstancenamed("sqlserver")); 

Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -