Tonight I updated the Dimecasts codebase from the 2.4.9 version of StructureMap to 2.5.0 and ran into few scenarios where some 'hefty' changes were required. I thought I would share the 2 major areas that needed change.
Adding named concrete instances for a given interface:
Was
AddInstanceOf<IAddin>().UsingConcreteType<DotNetKicksAddin>().WithName("DotNetKicks");
Is
ForRequestedType().AddInstances( x =>
{
x.OfConcreteType().WithName( "DotNetKicks" );
x.OfConcreteType().WithName( "DZone" );
x.OfConcreteType().WithName( "Digg" );
x.OfConcreteType().WithName( "ShareThis" );
}
);
Registering Registry's at application startup:
Was
StructureMapConfiguration.AddRegistry( new IoCWebRegistration() );
Is
ObjectFactory.Initialize( scanner =>
{
scanner.AddRegistry( new IoCWebRegistration() );
scanner.AddRegistry( new IoCDomainRegistration() );
scanner.AddRegistry( new IoCRepositoryRegistration() );}
);
Till next time,
[----- Remember to check out DimeCasts.Net -----]