我在配置 NSB 时使用 ninject。这是我的注册方式:
public class EndpointConfig : IConfigureThisEndpoint, AsA_Publisher, IWantCustomInitialization
{
#region Implementation of IWantCustomInitialization
public void Init()
{
var kernel = new StandardKernel();
Configure.With().NinjectBuilder(kernel);
kernel.Load(new BackendModule());
}
#endregion
}
public class BackendModule : NinjectModule
{
#region Overrides of NinjectModule
/// <summary>
/// Loads the module into the kernel.
/// </summary>
public override void Load()
{
Bind<IEventBus>().To<NsbBus>();
Bind<IRecordStorageConfig>().To<RegistrationEventStorageConfig>();
Bind<IRecordStorage>().To<RegistrationRecordStorage>();
Bind<IRecordStorageFactory>().To<RegistrationRecordStorageFactory>();
Bind<IAggregateRootFactory>().To<RegistrationFactory>();
}
#endregion
}
我需要传奇中的 IAggregateRootFactory。
public class RegistrationSaga : Saga<RegistrationSagaData>,
IAmStartedByMessages<StartRegistration>,
IHandleMessages<CreateRegistration>,
IHandleMessages<ValidateRegistration>,
IHandleMessages<CancelRegistration>
{
public RegistrationFactory Factory { get; set; }
// removed implementation
}
saga 成功启动,命令是处理程序被调用。但是 IAggregateRootFactory 属性注入不起作用。工厂始终为空。我接线错了吗?