示例#1
0
 /// <summary>
 /// Subscribes the specified aggregator to a catchup.
 /// </summary>
 /// <typeparam name="TProjection">The type of the projection.</typeparam>
 /// <typeparam name="TData">The type of the stream's data.</typeparam>
 /// <typeparam name="TCursor">The type of the cursor.</typeparam>
 /// <param name="catchup">The catchup.</param>
 /// <param name="aggregate">A delegate that performs an aggregate operation on projections receiving new data.</param>
 /// <param name="projectionStore">The projection store.</param>
 /// <returns>
 /// A disposable that, when disposed, unsubscribes the aggregator.
 /// </returns>
 public static IDisposable Subscribe <TProjection, TData, TCursor>(
     this IStreamCatchup <TData, TCursor> catchup,
     AggregateAsync <TProjection, TData> aggregate,
     IProjectionStore <string, TProjection> projectionStore = null)
 {
     return(catchup.Subscribe(Aggregator.Create(aggregate),
                              projectionStore.AsHandler()));
 }
示例#2
0
 /// <summary>
 /// Subscribes the specified aggregator to a catchup.
 /// </summary>
 /// <typeparam name="TProjection">The type of the projection.</typeparam>
 /// <typeparam name="TData">The type of the stream's data.</typeparam>
 /// <typeparam name="TCursor">The type of the cursor.</typeparam>
 /// <param name="catchup">The catchup.</param>
 /// <returns>A disposable that, when disposed, unsubscribes the aggregator.</returns>
 public static IDisposable Subscribe <TProjection, TData, TCursor>(
     this IStreamCatchup <TData, TCursor> catchup,
     AggregateAsync <TProjection, TData> aggregate,
     FetchAndSaveProjection <TProjection> manageProjection,
     HandleAggregatorError <TProjection> onError = null)
 {
     return(catchup.Subscribe(Aggregator.Create(aggregate), manageProjection, onError));
 }
示例#3
0
 public AnonymousStreamAggregator(
     AggregateAsync <TProjection, TData> aggregate)
 {
     if (aggregate == null)
     {
         throw new ArgumentNullException("aggregate");
     }
     this.aggregate = aggregate;
 }
示例#4
0
 /// <summary>
 /// Creates a stream aggregator.
 /// </summary>
 /// <typeparam name="TProjection">The type of the projection.</typeparam>
 /// <typeparam name="TData">The type of the data.</typeparam>
 /// <param name="aggregate">Performs aggregation of data from the stream.</param>
 public static IStreamAggregator <TProjection, TData> Create <TProjection, TData>(
     AggregateAsync <TProjection, TData> aggregate)
 {
     return(new AnonymousStreamAggregator <TProjection, TData>(aggregate));
 }
示例#5
0
 /// <summary>
 /// Traces calls to the specified aggregator function.
 /// </summary>
 /// <typeparam name="TProjection">The type of the projection.</typeparam>
 /// <typeparam name="TData">The type of the data.</typeparam>
 /// <param name="aggregate">The aggregator function.</param>
 /// <param name="write">A delegate that can be used to specify how the arguments should be traced. If this is not provided, output is sent to <see cref="System.Diagnostics.Trace" />.</param>
 /// <returns>The original aggregator wrapped in a tracing decorator.</returns>
 public static IStreamAggregator <TProjection, TData> Trace <TProjection, TData>(
     this AggregateAsync <TProjection, TData> aggregate,
     Action <TProjection, IStreamBatch <TData> > write = null)
 {
     return(Create(aggregate).Trace(write));
 }