Reputation: 358
I know structuremap is used for IoC in C#. It can be hooked via two ways. Through configuration:
ObjectFactory.Initialize(x =>
{
x.UseDefaultStructureMapConfigFile = true;
});
<StructureMap>
<DefaultInstance PluginType="XXXXXXX, YYYYYY" PluggedType="AAAAA,BBBBB" Scope="PerRequest" />
</StructureMap>
And from code, like this:
ObjectFactory.Initialize(x =>
{
x.UseDefaultStructureMapConfigFile = false;
x.AddRegistry<StructureMapRegistry>();
});
HttpContextLifecycle cycle = new HttpContextLifecycle();
For<IDataRepository<MethodName>>().LifecycleIs(cycle).Use<MethodName>();
I want to know what are the pros and cons of both approaches.
Upvotes: 2
Views: 215
Reputation: 151604
Upvotes: 3