0

我在配置 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 属性注入不起作用。工厂始终为空。我接线错了吗?

4

1 回答 1

1

我不太确定为什么您的传奇需要在其中包含 RegistrationFactory/IAggregateRootFactory,但这可能不是一个好主意。

于 2012-04-19T20:09:58.967 回答