1
我已經從NuGet安裝了NServiceBus.StructureMap
包,屬性注入不再適用於我的Sagas。這裏是(使用通用主機)我的配置代碼:當使用StructureMap和NServiceBus時,屬性注入不起作用
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();
}
}