public RecurrenceOrder?SetWeekDayOrder(string weekDayOrder) { RecurrenceOrder recurrenceOrder; if (Enum.TryParse(weekDayOrder, out recurrenceOrder)) { WeekDayOrder = recurrenceOrder; return(recurrenceOrder); } return(null); }
public override bool FromXml(XmlNode node) { ParseDateRange(node); ParseFirstDayOfWeek(node); Frequency = default(int); XmlNode yearlyNode = node.SelectSingleNode("//yearly"); if (yearlyNode != null && yearlyNode.Attributes["yearFrequency"] != null) { int yearFrequency; if (int.TryParse(yearlyNode.Attributes["yearFrequency"].Value, out yearFrequency)) { Frequency = yearFrequency; } int day; if (yearlyNode.Attributes["day"] != null && int.TryParse(yearlyNode.Attributes["day"].Value, out day)) { this.Day = day; } int month; if (yearlyNode.Attributes["month"] != null && int.TryParse(yearlyNode.Attributes["month"].Value, out month)) { this.Month = month; } this.YearlyByDay = false; return(true); } yearlyNode = node.SelectSingleNode("//yearlyByDay"); if (yearlyNode != null && yearlyNode.Attributes["yearFrequency"] != null) { int yearFrequency; if (int.TryParse(yearlyNode.Attributes["yearFrequency"].Value, out yearFrequency)) { Frequency = yearFrequency; } foreach (string day in daysOfWeekPool.Values) { bool enabled = false; if (yearlyNode.Attributes[day] != null && bool.TryParse(yearlyNode.Attributes[day].Value, out enabled) && enabled) { WeekDay = daysOfWeekPool.First(item => item.Value == day).Key; break; } } RecurrenceOrder number; if (yearlyNode.Attributes["weekdayOfMonth"] != null && Enum.TryParse(yearlyNode.Attributes["weekdayOfMonth"].Value, out number)) { WeekDayOrder = number; } int month; if (yearlyNode.Attributes["month"] != null && int.TryParse(yearlyNode.Attributes["month"].Value, out month)) { this.Month = month; } this.YearlyByDay = true; return(true); } return(false); }