Ejemplo n.º 1
0
 private void CallCommandOnAggregate(ICommand command, AggregateBase aggregateBase)
 {
     if (aggregateBase != null)
     {
         aggregateBase.CallMethod(CommandHandlerMethodName, command);
     }
     else
     {
         throw new AggregateNotFoundException();
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 ///     Publishes the updated version of the aggregate we are working with to a publisher. This could be a queue or a database writer in low volume scenarios.
 /// </summary>
 private static void PublishUpdatedAggregate(AggregateBase instance)
 {
     IAggregateUpdatePublisher publisher = Core.Instance.AggregateUpdatePublisher;
     if (publisher != null)
     {
         Core.Instance.AggregateUpdatePublisher.PublishUpdate(instance);
     }
 }
Ejemplo n.º 3
0
        private void InvokeEvent(AggregateBase instance, IEvent @event)
        {
            Type eventType = @event.GetType();

            MethodInfo eventHandlerMethod =
                instance.GetType()
                        .Methods()
                        .FirstOrDefault(mi => mi.GetParameters().Any(i => i.ParameterType == eventType));

            if (eventHandlerMethod != null)
            {
                eventHandlerMethod.Invoke(instance, new object[] {@event});

                if (!_aggregateLoading)
                {
                    PublishUpdatedAggregate(instance);
                    UpdateAggregateCache(instance);
                }
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 ///     This updates the aggregate in the cache, if used.
 /// </summary>
 /// <param name="instance"></param>
 private static void UpdateAggregateCache(AggregateBase instance)
 {
     if (Core.Instance.UseCaching && Core.Instance.Cache != null)
     {
         Core.Instance.Cache.Cache(instance);
     }
 }