In previous versions of StructureMap, I have a code like this:
_container.Configure(config =>
config
.For<ILogger>.Use<TLogger>.Ctor<string>("loggerName")
.Is((IContext ctx) => ctx.Root.RequestedType.ToString))
Using this, I was able to pass the class name to my logger and it was very helpful in auto wiring scenarios.
After updating to StrucureMap 3, the above code shows error and I cannot find the right code for StructureMap 3.
TL;DR; Where is Context.Root? How can I access it in StructureMap 3?
Looks like I was wrong in the first place.
Instead of Context.Root
, I can use Context.ParentType
and accomplish what I wanted.
A sample, available in this link: http://docs.structuremap.net/UsingSessionContext.htm#section1 (Logger Sample)helped me find the solution.