I have following following CTOR for a class:
public class Log : ILog {
...
public Log (string file, string flag) { .... }
....
}
I tried the following codes to make DI mapping:
public MyStructureMap {
public void static InitializeMapping() {
StructureMap.DSL.Registiry.ForRequestedType<ILog>().TheDefault.Is
.OfConcreteType<Log>().WithCtorArg("file").EqualTo(@"C:\tmp\log.txt");
StructureMap.DSL.Registiry.ForRequestedType<ILog>().TheDefault.Is
.OfConcreteType<Log>().WithCtorArg("flag").EqualTo(@"debug");
}
....
}
I could not get the object from ObjectFactory.GetInstance<ILog>() to work. I guess that in my case with two primitive parameters I cannot use WithCtorArg() to match parameters. Is that right? What is the best way to register my mapping?