tags:

views:

32

answers:

1

Hi, if I want StructureMap to return a single object instance for all requests, is there any difference at all between the two methods below??

StructureMap.ObjectFactory.Initialize(x => {x
   .ForRequestedType<ISplitPaymentConfigurationReader>()
   .TheDefaultIsConcreteType<SplitPaymentConfigurationReader>()
   .CacheBy(StructureMap.Attributes.InstanceScope.Singleton);
});

and

StructureMap.ObjectFactory.Inject<ISplitPaymentConfigurationReader>(
 new SplitPaymentConfigurationReader());
+1  A: 

As answered by the great folks in StructureMap, the two are the same, except that with the first way, you get auto-wiring of dependencies, where you don't with the second way.

Adam