Beispiel #1
0
        public AdaptedList <Month> CreateMonths(AdaptedList <DateTime> Dates, bool splitYears)
        {
            AdaptedList <Month> SortedMonths = new AdaptedList <Month>();
            Predicate <Month>   Predicate;

            //e => (e.GetYear == date.Year) && (e.GetMonth == date.Month)
            foreach (DateTime date in Dates)
            {
                if (splitYears)
                {
                    Predicate = e => (e.GetYear == date.Year) && (e.GetMonth == date.Month);
                }
                else
                {
                    Predicate = e => (e.GetMonth == date.Month);
                }
                // Temporary filtered list to check if the month already exists.
                AdaptedList <Month> PredicateMonthList = SortedMonths.Filter(Predicate);
                if (PredicateMonthList.Count == 0)
                {
                    SortedMonths.Add(new Month(date, 1));
                }
                else if (PredicateMonthList.Count == 1)
                {
                    PredicateMonthList[0].EventsThisMonth += 1;
                }
                else
                {
                    break;
                }
            }
            return(SortedMonths);
        }
Beispiel #2
0
        public AdaptedList <Z> Map <Z>(Func <R, Z> Func)
        {
            AdaptedList <Z> MappedList = new AdaptedList <Z>();

            foreach (R value in this)
            {
                MappedList.Add(Func(value));
            }
            return(MappedList);
        }