Пример #1
0
        public Calendar Clone()
        {
            var newCalender = new Calendar()
            {
                DaysToAlwaysExclude = DaysToAlwaysExclude.ToList(),
                InheritedCalendar   = InheritedCalendar.ToList(),
                DaysToExclude       = new HashSet <DateTime>(DaysToExclude),
                MonthsToExclude     = MonthsToExclude.ToList(),
                Name = Name
            };

            return(newCalender);
        }
Пример #2
0
        public Calendar Merge(Calendar otherCalendar)
        {
            if (otherCalendar.CalendarType != CalendarType)
            {
                throw new Exception("Cannot merge calendars of differing types");
            }
            var newCalender = new Calendar()
            {
                DaysToAlwaysExclude = DaysToAlwaysExclude.Concat(otherCalendar.DaysToAlwaysExclude).Distinct().ToList(),
                InheritedCalendar   = InheritedCalendar.Concat(otherCalendar.InheritedCalendar).Distinct().ToList(),
                DaysToExclude       = new HashSet <DateTime>(DaysToExclude.Concat(otherCalendar.DaysToExclude).Distinct()),
                MonthsToExclude     = MonthsToExclude.Concat(otherCalendar.MonthsToExclude).Distinct().ToList(),
                Name = Name
            };

            return(newCalender);
        }