Beispiel #1
0
 public Configuration(SetValidationCommandInterceptor interceptor)
 {
     var commandService = new CommandService();
     commandService.Configure();
     commandService.AddInterceptor(interceptor);
     Register<ICommandService>(commandService);
 }
Beispiel #2
0
        public override void Load()
        {
            Kernel.Bind<IUniqueIdentifierGenerator>()
                .To<GuidCombGenerator>();

            var eventStoreConnectionString = ConfigurationManager.ConnectionStrings["EventStore"].ConnectionString;
            Kernel.Bind<IEventStore>()
                .ToMethod(ctx => new MsSqlServerEventStore(eventStoreConnectionString))
                .InSingletonScope();

            Kernel.Bind<IEventBus>()
                .ToMethod(ctx => new InProcessEventBus().RegisterDenormalizers(Kernel))
                .InSingletonScope();

            Kernel.Bind<IAggregateRootCreationStrategy>()
                .To<NinjectAggregateRootCreationStrategy>()
                .InSingletonScope();

            Kernel.Bind<IDomainRepository>()
                .To<DomainRepository>()
                .InSingletonScope();

            Kernel.Bind<ICommandServiceInterceptor>()
                .To<ValidationCommandInterceptor>()
                .InSingletonScope();

            Kernel.Bind<ICommandServiceInterceptor>()
                .To<SetValidationCommandInterceptor>()
                .InSingletonScope();

            Kernel.Bind<ICommandService>()
                .ToMethod(ctx =>
                              {
                                  var cs = new CommandService();
                                  cs.Configure();
                                  var interceptors = ctx.Kernel.GetAll<ICommandServiceInterceptor>();
                                  foreach (var interceptor in interceptors)
                                      cs.AddInterceptor(interceptor);
                                  return cs;
                              })
                .InSingletonScope();

            Kernel.Bind<IMapMaker>()
                .ToMethod(ctx => ctx.Kernel.Get<NHibernateMapMaker>());

            Kernel.Bind<Map>()
                .ToMethod(ctx => ctx.Kernel.Get<IMapMaker>().MakeMap())
                .InSingletonScope();

            Kernel.Bind<IDialect>()
                .ToMethod(ctx => new MsSqlDialect(ctx.Kernel.Get<Map>()))
                .InSingletonScope();
        }
Beispiel #3
0
        public override void Load()
        {
            Kernel.Bind<IKernel>().ToConstant(Kernel);

            var commandService = new CommandService();
            commandService.Configure();
            commandService.AddInterceptor(new ValidationCommandInterceptor());
            Kernel.Bind<ICommandService>().ToConstant(commandService);

            Kernel.Bind<IAggregateRootCreationStrategy>().To<NinjectAggregateRootCreationStrategy>();

            Kernel.Bind<IClock>().To<DateTimeBasedClock>();
        }