我已经从NuGet安装了NServiceBus.StructureMap
软件包,并且属性注入不再适用于我的Sagas。这是我的配置代码(使用通用主机):
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();
}
}