コード例 #1
0
ファイル: EwsTask.cs プロジェクト: yaneshtyagi/2day
        public void ParseRecurrence(string xml)
        {
            if (xml == null)
            {
                throw new ArgumentNullException("xml");
            }

            this.Recurrence = EwsRecurrence.CreateFromXml(xml);
        }
コード例 #2
0
ファイル: EwsRecurrence.cs プロジェクト: yaneshtyagi/2day
 protected bool Equals(EwsRecurrence other)
 {
     return(this.RecurrenceType == other.RecurrenceType &&
            this.StartDate.Date.Equals(other.StartDate.Date) &&
            this.Interval == other.Interval &&
            this.DaysOfWeek == other.DaysOfWeek &&
            this.DayOfWeekIndex == other.DayOfWeekIndex &&
            this.DayOfMonth == other.DayOfMonth &&
            this.Month == other.Month);
 }
コード例 #3
0
ファイル: EwsRecurrence.cs プロジェクト: yaneshtyagi/2day
        internal static EwsRecurrence CreateFromXml(string xml)
        {
            if (xml == null)
            {
                throw new ArgumentNullException(nameof(xml));
            }

            xml = "<Root>" + xml + "</Root>";

            var xdoc = XDocument.Load(new StringReader(xml));

            var info = new EwsRecurrence {
                Interval = 1
            };

            var node = xdoc.TryGetNode("DailyRecurrence");

            if (node != null)
            {
                info.RecurrenceType = ExchangeRecurrencePattern.Daily;
                info.Interval       = node.XGetChildValue <int>("Interval", true);
            }

            node = xdoc.TryGetNode("DailyRegeneration");
            if (node != null)
            {
                info.RecurrenceType = ExchangeRecurrencePattern.DailyRegeneration;
                info.Interval       = node.XGetChildValue <int>("Interval", true);
            }

            node = xdoc.TryGetNode("WeeklyRecurrence");
            if (node != null)
            {
                info.RecurrenceType = ExchangeRecurrencePattern.Weekly;
                info.Interval       = node.XGetChildValue <int>("Interval", true);
                info.DaysOfWeek     = node.XGetChildValue <ExchangeDayOfWeek>("DaysOfWeek", true);
            }

            node = xdoc.TryGetNode("WeeklyRegeneration");
            if (node != null)
            {
                info.RecurrenceType = ExchangeRecurrencePattern.WeeklyRegeneration;
                info.Interval       = node.XGetChildValue <int>("Interval", true);
            }

            node = xdoc.TryGetNode("AbsoluteMonthlyRecurrence");
            if (node != null)
            {
                info.RecurrenceType = ExchangeRecurrencePattern.Monthly;
                info.Interval       = node.XGetChildValue <int>("Interval", true);
                info.DayOfMonth     = node.XGetChildValue <int>("DayOfMonth", true);
            }

            node = xdoc.TryGetNode("RelativeMonthlyRecurrence");
            if (node != null)
            {
                info.RecurrenceType = ExchangeRecurrencePattern.MonthlyRelative;
                info.Interval       = node.XGetChildValue <int>("Interval", true);
                info.DaysOfWeek     = node.XGetChildValue <ExchangeDayOfWeek>("DaysOfWeek", true);
                info.DayOfWeekIndex = node.XGetChildValue <ExchangeDayOfWeekIndex>("DayOfWeekIndex", true);
            }

            node = xdoc.TryGetNode("MonthlyRegeneration");
            if (node != null)
            {
                info.RecurrenceType = ExchangeRecurrencePattern.MonthlyRegeneration;
                info.Interval       = node.XGetChildValue <int>("Interval", true);
            }

            node = xdoc.TryGetNode("AbsoluteYearlyRecurrence");
            if (node != null)
            {
                info.RecurrenceType = ExchangeRecurrencePattern.Yearly;
                info.DayOfMonth     = node.XGetChildValue <int>("DayOfMonth", true);
                info.Month          = node.XGetChildMonthNamesIndex("Month");
            }

            node = xdoc.TryGetNode("RelativeYearlyRecurrence");
            if (node != null)
            {
                info.RecurrenceType = ExchangeRecurrencePattern.YearlyRelative;
                info.DaysOfWeek     = node.XGetChildValue <ExchangeDayOfWeek>("DaysOfWeek", true);
                info.DayOfWeekIndex = node.XGetChildValue <ExchangeDayOfWeekIndex>("DayOfWeekIndex", true);
                info.Month          = node.XGetChildMonthNamesIndex("Month");
            }

            node = xdoc.TryGetNode("YearlyRegeneration");
            if (node != null)
            {
                info.RecurrenceType = ExchangeRecurrencePattern.YearlyRegeneration;
                info.Interval       = node.XGetChildValue <int>("Interval", true);
            }

            node = xdoc.TryGetNode("NoEndRecurrence");
            if (node != null)
            {
                info.StartDate = node.XGetChildValue <DateTime>("StartDate", true);
            }

            return(info);
        }