mirror of
https://github.com/ckaczor/HomeMonitor.git
synced 2026-01-14 17:23:11 -05:00
25 lines
702 B
C#
25 lines
702 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using ChrisKaczor.HomeMonitor.Weather.Models;
|
|
using JetBrains.Annotations;
|
|
|
|
namespace ChrisKaczor.HomeMonitor.Weather.Service.Models
|
|
{
|
|
[PublicAPI]
|
|
public class ReadingAggregate
|
|
{
|
|
public decimal Min { get; set; }
|
|
|
|
public decimal Max { get; set; }
|
|
|
|
public decimal Average { get; set; }
|
|
|
|
public ReadingAggregate(IEnumerable<WeatherReading> readings, Func<WeatherReading, decimal> selector, int decimalPlaces)
|
|
{
|
|
Min = readings.Min(selector);
|
|
Max = readings.Max(selector);
|
|
Average = readings.Average(selector).Truncate(decimalPlaces);
|
|
}
|
|
}
|
|
} |