コード例 #1
0
        /// <inheritdoc />
        public async Task <TAggregateRoot> GetAsync <TAggregateRoot, TAggregateState>(
            string aggregateId,
            AggregateExecutionContext context)
            where TAggregateRoot : AggregateRoot <TAggregateState>
            where TAggregateState : AggregateState, new()
        {
            var aggregateRoot = CreateEmptyAggregate <TAggregateRoot, TAggregateState>(aggregateId, context);

            await FillAggregateHistoryAsync(aggregateRoot);

            return(aggregateRoot);
        }
コード例 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BaseAggregateRoot{TState}"/> class.
 /// </summary>
 /// <param name="id">Aggregate id.</param>
 /// <param name="context">Aggregate execution context.</param>
 protected BaseAggregateRoot(string id, AggregateExecutionContext context)
     : base(id)
 {
     Context = context;
 }
コード例 #3
0
        private static TAggregateRoot CreateEmptyAggregate <TAggregateRoot, TAggregateState>(string aggregateId, AggregateExecutionContext context)
            where TAggregateRoot : AggregateRoot <TAggregateState>
            where TAggregateState : AggregateState, new()
        {
            var type            = typeof(TAggregateRoot);
            var constructorInfo = type.GetConstructor(new[] { typeof(string), typeof(AggregateExecutionContext) })
                                  ?? throw new ArgumentNullException($"No contrsuctor with '{typeof(string)}, {typeof(AggregateExecutionContext)}' "
                                                                     + $"arguments is found in '{typeof(TAggregateRoot)}'.");

            var aggregateRoot = (TAggregateRoot)constructorInfo.Invoke(new object[] { aggregateId, context });

            return(aggregateRoot);
        }
コード例 #4
0
 /// <inheritdoc />
 public TAggregateRoot Create <TAggregateRoot, TAggregateState>(string aggregateId, AggregateExecutionContext context)
     where TAggregateRoot : AggregateRoot <TAggregateState>
     where TAggregateState : AggregateState, new()
 {
     return(CreateEmptyAggregate <TAggregateRoot, TAggregateState>(aggregateId, context));
 }