コード例 #1
0
        void FillInDefaults()
        {
            _container.Register(x => new InMemoryEventStore(x.Get <IDomainEventSerializer>()));
            _container.Register <IEventStore>(x => x.Get <InMemoryEventStore>());

            if (!_container.HasService <IEventDispatcher>(checkForPrimary: true))
            {
                _container.Register <IEventDispatcher>(x =>
                                                       new ViewManagerEventDispatcher(
                                                           x.Get <IAggregateRootRepository>(),
                                                           x.Get <IEventStore>(),
                                                           x.Get <IDomainEventSerializer>(),
                                                           x.Get <IDomainTypeNameMapper>()));
            }

            if (!_container.HasService <IAggregateRootRepository>(checkForPrimary: true))
            {
                _container.Register <IAggregateRootRepository>(context =>
                                                               new DefaultAggregateRootRepository(
                                                                   context.Get <IEventStore>(),
                                                                   context.Get <IDomainEventSerializer>(),
                                                                   context.Get <IDomainTypeNameMapper>()));
            }

            if (!_container.HasService <IDomainEventSerializer>(checkForPrimary: true))
            {
                _container.Register <IDomainEventSerializer>(context => new JsonDomainEventSerializer("<events>"));
            }

            if (!_container.HasService <ICommandMapper>(checkForPrimary: true))
            {
                _container.Register <ICommandMapper>(context => new DefaultCommandMapper());
            }

            if (!_container.HasService <IDomainTypeNameMapper>(checkForPrimary: true))
            {
                _container.Register <IDomainTypeNameMapper>(context => new DefaultDomainTypeNameMapper());
            }
        }