public IEnumerable <string> ETags()
 {
     return(sourceSnapshot.IfNotNull()
            .Then(s => s.ETags)
            .Else(() => new string[0])
            .Concat(eventHistory.Select(e => e.ETag).Distinct()));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="EventSourcedAggregate{T}"/> class.
 /// </summary>
 /// <param name="snapshot">A snapshot of the aggregate's built-up state.</param>
 protected internal EventSourcedAggregate(ISnapshot snapshot)
     : this(snapshot.IfNotNull()
            .Then(s => s.AggregateId)
            .ElseThrow(() => new ArgumentNullException(nameof(snapshot))))
 {
     sourceSnapshot = snapshot;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="EventSourcedAggregate{T}"/> class.
 /// </summary>
 /// <param name="snapshot">A snapshot of the aggregate's built-up state.</param>
 protected internal EventSourcedAggregate(ISnapshot snapshot)
     : this(snapshot.IfNotNull()
                    .Then(s => s.AggregateId)
                    .ElseThrow(() => new ArgumentNullException(nameof(snapshot))))
 {
     sourceSnapshot = snapshot;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="EventSourcedAggregate{T}"/> class.
 /// </summary>
 /// <param name="snapshot">A snapshot of the aggregate's built-up state.</param>
 /// <param name="eventHistory">The event history.</param>
 protected internal EventSourcedAggregate(ISnapshot snapshot, IEnumerable <IEvent> eventHistory = null) :
     this(snapshot.IfNotNull()
          .Then(s => s.AggregateId)
          .ElseThrow(() => new ArgumentNullException("snapshot")))
 {
     sourceEvents   = eventHistory.OrEmpty().ToArray();
     sourceSnapshot = snapshot;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="EventSourcedAggregate{T}"/> class.
 /// </summary>
 /// <param name="snapshot">A snapshot of the aggregate's built-up state.</param>
 /// <param name="eventHistory">The event history.</param>
 protected internal EventSourcedAggregate(ISnapshot snapshot, IEnumerable<IEvent> eventHistory = null) :
     this(snapshot.IfNotNull()
                  .Then(s => s.AggregateId)
                  .ElseThrow(() => new ArgumentNullException("snapshot")))
 {
     sourceEvents = eventHistory.OrEmpty().ToArray();
     SourceSnapshot = snapshot;
 }
Example #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EventSourcedAggregate{T}"/> class.
 /// </summary>
 /// <param name="snapshot">A snapshot of the aggregate's built-up state.</param>
 /// <param name="eventHistory">The event history.</param>
 protected internal EventSourcedAggregate(ISnapshot snapshot, IEnumerable <IEvent> eventHistory = null)
     : this(snapshot.IfNotNull().Then(s => s.AggregateId).ElseThrow(() => new ArgumentNullException(nameof(snapshot))))
 {
     SourceSnapshot = snapshot;
     InitializeEventHistory(eventHistory.OrEmpty());
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="EventSourcedAggregate{T}"/> class.
 /// </summary>
 /// <param name="snapshot">A snapshot of the aggregate's built-up state.</param>
 /// <param name="eventHistory">The event history.</param>
 protected internal EventSourcedAggregate(ISnapshot snapshot, IEnumerable<IEvent> eventHistory = null)
     : this(snapshot.IfNotNull().Then(s => s.AggregateId).ElseThrow(() => new ArgumentNullException(nameof(snapshot))))
 {
     SourceSnapshot = snapshot;
     InitializeEventHistory(eventHistory.OrEmpty());
 }