Ejemplo n.º 1
0
 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;
 }
Ejemplo n.º 3
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>
 protected internal EventSourcedAggregate(ISnapshot snapshot)
     : this(snapshot.IfNotNull()
                    .Then(s => s.AggregateId)
                    .ElseThrow(() => new ArgumentNullException(nameof(snapshot))))
 {
     sourceSnapshot = snapshot;
 }
Ejemplo n.º 4
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("snapshot")))
 {
     sourceEvents   = eventHistory.OrEmpty().ToArray();
     sourceSnapshot = snapshot;
 }
Ejemplo n.º 5
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("snapshot")))
 {
     sourceEvents = eventHistory.OrEmpty().ToArray();
     SourceSnapshot = snapshot;
 }
Ejemplo n.º 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());
 }