Beispiel #1
0
        public static Summary FromPeriodType(PeriodType periodType, DateTime startDate, string content)
        {
            switch (periodType.Type)
            {
            case PeriodTypeEnum.Day: return(DailySummary((Date)startDate, content));

            case PeriodTypeEnum.Week: return(WeeklySummary((Date)startDate, content));

            case PeriodTypeEnum.Month: return(MonthlySummary((Month)startDate, content));

            default: throw new ArgumentOutOfRangeException(nameof(periodType), periodType, $"Speficied period type \"{periodType}\" is not a valid type for constructing a summary.");
            }
        }
Beispiel #2
0
 public static Summary MonthlySummary(Month month, string content) =>
 new Summary(Guid.Empty, new SummaryPeriod(PeriodType.FromTypeEnum(PeriodTypeEnum.Month), month.SingleMonthRange()), content);
Beispiel #3
0
 public static Summary WeeklySummary(Date startDate, string content) =>
 new Summary(Guid.Empty, new SummaryPeriod(PeriodType.FromTypeEnum(PeriodTypeEnum.Week), startDate.FirstDayOfWeek().RangeFromWeeks(1)), content);
Beispiel #4
0
 public static Summary DailySummary(Date date, string content) =>
 new Summary(Guid.Empty, new SummaryPeriod(PeriodType.FromTypeEnum(PeriodTypeEnum.Day), date.SingleDayRange()), content);
 /// <summary>
 /// Filter a collection of summaries to include only those which are summarized by the specified summary type.
 /// </summary>
 /// <param name="summaries">The collection of summaries.</param>
 /// <param name="summaryType">The summary type that should summarize the summaries.</param>
 /// <returns>All summaries of the type which is summarized by the specified summary type.</returns>
 public static IEnumerable <Summary> SummarizedBy(this IEnumerable <Summary> summaries, PeriodType summaryType) =>
 summaries.Where(summary => summaryType.EncompassesType(summary.Period.Type));
 /// <summary>
 /// Filter a collection of summaries to include only those which are of the specified summary type.
 /// </summary>
 /// <param name="summaries">The collection of summaries.</param>
 /// <param name="summaryType">The summary type of summaries to include in the result.</param>
 /// <returns>All summaries that are of the specified type.</returns>
 public static IEnumerable <Summary> OfSummaryType(this IEnumerable <Summary> summaries, PeriodType summaryType) =>
 summaries.Where(summary => summary.Period.Type.Equals(summaryType));
 public SummaryPeriod(PeriodType type, DateRange dateRange)
 {
     DateRange = dateRange ?? throw new ArgumentNullException(nameof(dateRange));
     Type      = type ?? throw new ArgumentNullException(nameof(type));
 }