Ejemplo n.º 1
0
        public override bool Equals(RecurrencePattern value, bool ignoreCalendarTypeAndIsLeapMonth)
        {
            if (!(value is IntervalRecurrencePattern))
            {
                return(false);
            }
            IntervalRecurrencePattern intervalRecurrencePattern = (IntervalRecurrencePattern)value;

            return(intervalRecurrencePattern.RecurrenceInterval == this.recurrenceInterval);
        }
Ejemplo n.º 2
0
        protected Recurrence ICalRecurrenceFromXsoRecurrence(Recurrence xsoRecurrence)
        {
            Recurrence        recurrence = new Recurrence();
            RecurrencePattern pattern    = xsoRecurrence.Pattern;
            RecurrenceRange   range      = xsoRecurrence.Range;

            if (pattern is DailyRecurrencePattern)
            {
                recurrence.Frequency = Frequency.Daily;
            }
            else if (pattern is WeeklyRecurrencePattern)
            {
                recurrence.Frequency = Frequency.Weekly;
                WeeklyRecurrencePattern weeklyRecurrencePattern = (WeeklyRecurrencePattern)pattern;
                recurrence.ByDayList     = VItemBase.ByDayListFromDaysOfWeek(weeklyRecurrencePattern.DaysOfWeek);
                recurrence.WorkWeekStart = weeklyRecurrencePattern.FirstDayOfWeek;
            }
            else if (pattern is MonthlyRecurrencePattern)
            {
                recurrence.Frequency = Frequency.Monthly;
                MonthlyRecurrencePattern monthlyRecurrencePattern = (MonthlyRecurrencePattern)pattern;
                recurrence.ByMonthDay = new int[]
                {
                    monthlyRecurrencePattern.DayOfMonth
                };
            }
            else if (pattern is MonthlyThRecurrencePattern)
            {
                recurrence.Frequency = Frequency.Monthly;
                MonthlyThRecurrencePattern monthlyThRecurrencePattern = (MonthlyThRecurrencePattern)pattern;
                recurrence.ByDayList = VItemBase.ByDayListFromDaysOfWeek(monthlyThRecurrencePattern.DaysOfWeek);
                int order = (int)monthlyThRecurrencePattern.Order;
                if (recurrence.ByDayList.Length == 1)
                {
                    recurrence.ByDayList[0].OccurrenceNumber = order;
                }
                else
                {
                    recurrence.BySetPosition = new int[]
                    {
                        order
                    };
                }
            }
            else if (pattern is YearlyRecurrencePattern)
            {
                recurrence.Frequency = Frequency.Yearly;
                YearlyRecurrencePattern yearlyRecurrencePattern = (YearlyRecurrencePattern)pattern;
                recurrence.ByMonth = new int[]
                {
                    yearlyRecurrencePattern.Month
                };
                recurrence.ByMonthDay = new int[]
                {
                    yearlyRecurrencePattern.DayOfMonth
                };
            }
            else if (pattern is YearlyThRecurrencePattern)
            {
                recurrence.Frequency = Frequency.Yearly;
                YearlyThRecurrencePattern yearlyThRecurrencePattern = (YearlyThRecurrencePattern)pattern;
                recurrence.ByMonth = new int[]
                {
                    yearlyThRecurrencePattern.Month
                };
                recurrence.ByDayList = VItemBase.ByDayListFromDaysOfWeek(yearlyThRecurrencePattern.DaysOfWeek);
                int order2 = (int)yearlyThRecurrencePattern.Order;
                if (recurrence.ByDayList.Length == 1)
                {
                    recurrence.ByDayList[0].OccurrenceNumber = order2;
                }
                else
                {
                    recurrence.BySetPosition = new int[]
                    {
                        order2
                    };
                }
            }
            IntervalRecurrencePattern intervalRecurrencePattern = pattern as IntervalRecurrencePattern;

            if (intervalRecurrencePattern != null)
            {
                recurrence.Interval = intervalRecurrencePattern.RecurrenceInterval;
            }
            else
            {
                recurrence.Interval = 1;
            }
            if (range is EndDateRecurrenceRange)
            {
                EndDateRecurrenceRange endDateRecurrenceRange = (EndDateRecurrenceRange)range;
                recurrence.UntilDateTime = (DateTime)(endDateRecurrenceRange.EndDate + xsoRecurrence.StartOffset).ToUtc();
            }
            else if (range is NumberedRecurrenceRange)
            {
                NumberedRecurrenceRange numberedRecurrenceRange = (NumberedRecurrenceRange)range;
                recurrence.Count = numberedRecurrenceRange.NumberOfOccurrences;
            }
            return(recurrence);
        }