Exemple #1
0
 /// <summary>
 /// Continuous calculation of the average of the underlying data source.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="source">The source observable</param>
 /// <param name="valueSelector">The function which returns the value</param>
 /// <param name="emptyValue">The resulting average value when there is no data</param>
 /// <returns>
 /// An observable of averages
 /// </returns>
 public static IObservable <float> Avg <T>([NotNull] this IObservable <IAggregateChangeSet <T> > source, [NotNull] Func <T, float?> valueSelector, float emptyValue = 0)
 {
     return(source.Avg(t => valueSelector(t).GetValueOrDefault(), emptyValue));
 }
Exemple #2
0
 /// <summary>
 /// Averages the specified value selector.
 /// </summary>
 /// <typeparam name="T">The type to average.</typeparam>
 /// <param name="source">The source.</param>
 /// <param name="valueSelector">The value selector.</param>
 /// <param name="emptyValue">The empty value.</param>
 /// <returns>An observable of decimals with the averaged values.</returns>
 public static IObservable <decimal> Avg <T>(this IObservable <IAggregateChangeSet <T> > source, Func <T, decimal?> valueSelector, decimal emptyValue = 0)
 {
     return(source.Avg(t => valueSelector(t).GetValueOrDefault(), emptyValue));
 }