c# - How to use StructureMap for the case of primitive types in CTOR -


I have the following ctor following for a class:

  Public class login Ilog {. ..Log log (string file, string flag) {....} ....}  

I tried the following code to de mapping:

< Pre> public MyStructureMap {Public Zero Static InitializeMapping () {StructureMap.DSL.Registiry.ForRequestedType & LT; Ilog & gt; () TheDefault.Is .OfConcreteType & LT; Sign in & gt; () WithCtorArg ("File") EqualTo ("@C ...: \ tmp \ log.txt"); StructureMap.DSL.Registiry.ForRequestedType & LT; Ilog & gt; () TheDefault.Is .OfConcreteType. & Lt; Sign in & gt; () WithCtorArg ("Flag") EqualTo (@ "Debug") .. } ....}

I could not get object from ObjectFactory.GetInstance & lt; to work (); Ilog & gt; I think that in my case I can not use WithCtorArg () with two primitive parameters matching the parameters, is that right? What is the best way to register my mapping?

I started working with StructureMap today and when I saw a reply on StackOverflow for something else Was looking for your question. Your question is a bit old, but if you do not find your answer, here it goes:

You can use several primitive parameters. To take advantage of the fluent interface, you just have to change your syntax:

  Public Texture Map {public zero static initialimaging () {StructureMap.DSL.Registiry.ForRequestedType & lt; ILog & gt; (). Is.OfConcreteType & LT; Sign in & gt; () .WithCtorArg ("file") EqualTo (@ "C: \ tmp \ log.txt") .WithCtorArg ("flag") EqualTo (@ "debug"); .. } ....}  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -