Passing constructor arguments when using StructureMap

I suggest declaring that with the StructureMap configuration. Using the slightly newer StructureMap code:

For<IProductProvider>().Use<ProductProvider>
  .Ctor<string>("connectionString").Is(someValueAtRunTime);

This way you don’t burden your client code from having to know the value and can keep your IoC configuration separate from your main code.

Leave a Comment