Esempio n. 1
0
        public string MakeReport(IEnumerable <Measurement> measurements)
        {
            var data   = measurements.ToList();
            var result = new StringBuilder();

            result.Append(Caption);
            result.Append(BeginList);
            result.Append(MakeItem("Temperature", StatisticMaker.MakeStatistics(data.Select(z => z.Temperature)).ToString()));
            result.Append(MakeItem("Humidity", StatisticMaker.MakeStatistics(data.Select(z => z.Humidity)).ToString()));
            result.Append(EndList);
            return(result.ToString());
        }
Esempio n. 2
0
        public static string MakeReport(IEnumerable <Measurement> dataSource,
                                        FormatMaker formatMaker, StatisticMaker statisticMaker)
        {
            var data   = dataSource.ToList();
            var result = new StringBuilder();

            result.Append(formatMaker.CaptionMake(statisticMaker.Caption));
            result.Append(formatMaker.ListBegin());
            result.Append(formatMaker
                          .ItemMake("Temperature",
                                    statisticMaker.StatisticCreator(data.Select(z => z.Temperature)).ToString()));
            result.Append(formatMaker.ItemMake("Humidity",
                                               statisticMaker.StatisticCreator(data.Select(z => z.Humidity)).ToString()));
            result.Append(formatMaker.ListEnd());
            return(result.ToString());
        }