Пример #1
0
 public AnnotationCommandHandlerAdapter(object annotatedCommandHandler,
                                        IParameterResolverFactory parameterResolverFactory,
                                        IHandlerDefinition handlerDefinition)
 {
     Assert.NotNull(annotatedCommandHandler, () => "annotatedCommandHandler may not be null");
     _modelInspector = AnnotatedAggregateMetaModelFactory.InspectAggregate(annotatedCommandHandler.GetType(), parameterResolverFactory, handlerDefinition);
     _target         = annotatedCommandHandler;
 }
Пример #2
0
        public static AnnotatedAggregate <T> Initialize(T aggregateRoot, IAggregateModel aggregateModel,
                                                        IEventBus eventBus, IRepositoryProvider repositoryProvider)
        {
            var aggregate = new AnnotatedAggregate <T>(aggregateRoot,
                                                       aggregateModel,
                                                       eventBus,
                                                       repositoryProvider);

            aggregate.RegisterWithUnitOfWork();
            return(aggregate);
        }
Пример #3
0
 public EventBase(IAggregateModel model, string eventType, string eventClrType)
 {
     TenantId           = model.TenantId;
     Id                 = model.Id;
     CreatedDateTimeUtc = DateTime.UtcNow;
     EventType          = eventType;
     ServerCulture      = Thread.CurrentThread.CurrentCulture.Name;
     _metaData          = new Dictionary <string, object>()
     {
         { ValueAggregateConstants.EventMetaDataHeaders.AggregateClrTypeHeader, model.GetType().AssemblyQualifiedName },
         { ValueAggregateConstants.EventMetaDataHeaders.EventClrTypeHeader, eventClrType },
         { ValueAggregateConstants.EventMetaDataHeaders.CommitIdHeader, model.CommitId }
     };
 }
Пример #4
0
        public static AnnotatedAggregate <T> Initialize(Func <T> aggregateFactory, IAggregateModel aggregateModel,
                                                        IEventBus eventBus, IRepositoryProvider repositoryProvider,
                                                        bool generateSequences)
        {
            var aggregate = new AnnotatedAggregate <T>(aggregateModel, eventBus, repositoryProvider);

            aggregate.RegisterWithUnitOfWork();
            if (generateSequences)
            {
                aggregate.InitSequence();
            }
            aggregate.RegisterRoot(aggregateFactory);
            return(aggregate);
        }
Пример #5
0
 public AggregateAnnotationCommandHandler(IRepository <T> repository,
                                          ICommandTargetResolver commandTargetResolver,
                                          IAggregateModel aggregateModel)
 {
     if (aggregateModel == null)
     {
         throw new ArgumentNullException(nameof(aggregateModel));
     }
     if (repository == null)
     {
         throw new ArgumentNullException(nameof(repository));
     }
     if (commandTargetResolver == null)
     {
         throw new ArgumentNullException(nameof(commandTargetResolver));
     }
     _repository            = repository;
     _commandTargetResolver = commandTargetResolver;
     _aggregateModel        = aggregateModel;
 }
Пример #6
0
 protected AbstractRepository(IAggregateModel aggregateModel)
 {
     NotNull(aggregateModel, () => "aggregateModel may not be null");
     AggregateModel = aggregateModel;
 }
Пример #7
0
 internal AggregateAdapter(IBoundedContextModel contextMap, TAggregateRoot aggregateRoot)
 {
     this.contextMap     = contextMap;
     this.aggregateRoot  = aggregateRoot;
     this.aggregateModel = contextMap.AggregateModel(typeof(TAggregateRoot));
 }
Пример #8
0
 public static AnnotatedAggregate <T> Initialize(T aggregateRoot, IAggregateModel aggregateModel,
                                                 IEventBus eventBus)
 {
     return(Initialize(aggregateRoot, aggregateModel, eventBus, null));
 }
Пример #9
0
 public static AnnotatedAggregate <T> Initialize(Func <T> aggregateFactory, IAggregateModel aggregateModel,
                                                 IEventBus eventBus, bool generateSequences)
 {
     return(Initialize(aggregateFactory, aggregateModel, eventBus, null, generateSequences));
 }
Пример #10
0
 public static AnnotatedAggregate <T> Initialize(Func <T> aggregateFactory, IAggregateModel aggregateModel,
                                                 IEventBus eventBus, IRepositoryProvider repositoryProvider)
 {
     return(Initialize(aggregateFactory, aggregateModel, eventBus, repositoryProvider, false));
 }
Пример #11
0
 public static AnnotatedAggregate <T> Initialize(Func <T> aggregateFactory, IAggregateModel aggregateModel, IEventBus eventBus)
 {
     return(Initialize(aggregateFactory, aggregateModel, eventBus, false));
 }
Пример #12
0
 protected AnnotatedAggregate(IAggregateModel inspector, IEventBus eventBus, IRepositoryProvider repositoryProvider)
 {
     _inspector          = inspector;
     _repositoryProvider = repositoryProvider;
     _eventBus           = eventBus;
 }
Пример #13
0
 protected AnnotatedAggregate(IAggregateModel inspector, IEventBus eventBus)
     : this(inspector, eventBus, (IRepositoryProvider)null)
 {
 }
Пример #14
0
 protected AnnotatedAggregate(T aggregateRoot, IAggregateModel model, IEventBus eventBus, IRepositoryProvider repositoryProvider)
     : this(model, eventBus, repositoryProvider)
 {
     this._aggregateRoot = aggregateRoot;
 }
Пример #15
0
 protected AnnotatedAggregate(T aggregateRoot, IAggregateModel model, IEventBus eventBus) : this(aggregateRoot, model, eventBus, null)
 {
 }
Пример #16
0
        private IReadOnlyDictionary <string, IMessageHandler <ICommandMessage> > InitializeHandlers(IAggregateModel aggregateModel)
        {
            var handlersFound           = new Dictionary <string, IMessageHandler <ICommandMessage> >();
            var aggregateCommandHandler = new AggregateCommandHandler(this);

            aggregateModel.CommandHandlers.ForEach(kv =>
            {
                if (kv.Value.Unwrap <ICommandMessageHandlingMember>()
                    .Map(x => x.IsFactoryHandler).OrElse(false))
                {
                    handlersFound[kv.Key] = new AggregateConstructorCommandHandler(kv.Value, this);
                }
                else
                {
                    handlersFound[kv.Key] = aggregateCommandHandler;
                }
            });
            return(handlersFound);
        }