Reputation: 34800
I've installed the NServiceBus.StructureMap
package from NuGet and property injection is no longer working on my Sagas. Here's my configuration code (using the generic host):
public class EndpointConfig : IConfigureThisEndpoint, AsA_Publisher, IWantCustomInitialization
{
public void Init()
{
Configure.With()
.StructureMapBuilder(ConfigureStructureMap())
.XmlSerializer();
}
private static IContainer ConfigureStructureMap()
{
ObjectFactory.Initialize(cfg =>
{
cfg.For<IBarcodeReader>().Use<DataMatrixBarcodeReader>();
cfg.ForSingletonOf<IDocumentStore>().Use(() => InitializeStore());
cfg.For<IDocumentSession>().Use(x => x.GetInstance<IDocumentStore>().OpenSession());
});
return ObjectFactory.Container;
}
private static IDocumentStore InitializeStore()
{
return new DocumentStore
{
Url = "http://localhost:8080/",
DefaultDatabase = "db"
}
.Initialize();
}
}
Upvotes: 1
Views: 607
Reputation: 5273
Setter injection is not on by default in StructureMap so you need to enable it Autowire setters using StructureMap
Upvotes: 3