Example #1
0
        /// <summary>
        /// Aply a change based on an event.
        /// </summary>
        /// <param name="e">The event to apply.</param>
        /// <param name="isNew">Indication whether this is a new event (true) that needs to be added to the 
        /// list of uncommitted changes or not (false).</param>
        private void ApplyChange(DomainEvent e, bool isNew)
        {
            // handle the event
            HandleEvent(e);

            // add event to list of uncommitted events
            if (isNew)
            {
                _changes.Add(e as DomainEvent);
            }
        }
Example #2
0
 /// <summary>
 /// Constructor taking parameters for initialisation.
 /// </summary>
 /// <param name="id">The unique Id of the aggregate.</param>
 /// <param name="eventData">The event data.</param>
 /// <param name="version">The current version of the aggregate for concurrency control.</param>
 public EventDescriptor(Guid id, DomainEvent eventData, int version)
 {
     EventData = eventData;
     Version = version;
     Id = id;
 }
Example #3
0
 /// <summary>
 /// Call the appropriate handle method on the derived Aggregate class based on the event type. 
 /// </summary>
 /// <param name="e">The event to handle.</param>
 private void HandleEvent(DomainEvent e)
 {
     var handleMethod = this.GetType().GetMethod("Handle", new Type[] { e.GetType() });
     handleMethod.Invoke(this, new object[] { e });
 }
Example #4
0
 /// <summary>
 /// Aply a change based on an event.
 /// </summary>
 /// <param name="e">The event to apply.</param>
 protected void ApplyChange(DomainEvent e)
 {
     ApplyChange(e, true);
 }