Beispiel #1
0
 private void Write11_Recurrence(string n, string ns, Recurrence o, bool isNullable, bool needType)
 {
     if (o == null)
     {
         if (isNullable)
         {
             base.WriteNullTagLiteral(n, ns);
         }
         return;
     }
     if (!needType)
     {
         Type type = o.GetType();
         if (!(type == typeof(Recurrence)))
         {
             throw base.CreateUnknownTypeException(o);
         }
     }
     base.WriteStartElement(n, ns, o, false, null);
     if (needType)
     {
         base.WriteXsiType("Recurrence", "");
     }
     base.WriteElementString("Type", "", this.Write8_RecurrenceType(o.Type));
     base.WriteElementStringRaw("Interval", "", XmlConvert.ToString(o.Interval));
     base.WriteElementStringRaw("NthDayInMonth", "", XmlConvert.ToString(o.NthDayInMonth));
     base.WriteElementString("DaysOfWeek", "", this.Write9_DaysOfWeek(o.DaysOfWeek));
     base.WriteElementString("WeekOrderInMonth", "", this.Write10_WeekOrderInMonth(o.WeekOrderInMonth));
     base.WriteElementStringRaw("MonthOrder", "", XmlConvert.ToString(o.MonthOrder));
     base.WriteEndElement(o);
 }
Beispiel #2
0
 internal static RecurrenceModel FromData(Recurrence recurrenceValueObject)
 {
     if (recurrenceValueObject == null)
     {
         return(new OnceRecurrenceModel());
     }
     else if (recurrenceValueObject is DailyRecurrence)
     {
         return(new DailyRecurrenceModel
         {
             Every = recurrenceValueObject.Every,
             Until = recurrenceValueObject.Until,
         });
     }
     else if (recurrenceValueObject is WeeklyRecurrence)
     {
         var weeklyRecurrenceValueObject = (WeeklyRecurrence)recurrenceValueObject;
         if (weeklyRecurrenceValueObject.DaysOfWeek == DaysOfWeek.None)
         {
             return(new WeeklyRecurrenceModel
             {
                 Every = weeklyRecurrenceValueObject.Every,
                 Until = weeklyRecurrenceValueObject.Until,
             });
         }
         else
         {
             return(new DaysOfWeekRecurrenceModel
             {
                 Every = weeklyRecurrenceValueObject.Every,
                 Until = weeklyRecurrenceValueObject.Until,
                 DaysOfWeek = weeklyRecurrenceValueObject.DaysOfWeek,
             });
         }
     }
     else if (recurrenceValueObject is MonthlyRecurrence)
     {
         return(new MonthlyRecurrenceModel
         {
             Every = recurrenceValueObject.Every,
             Until = recurrenceValueObject.Until,
         });
     }
     else
     {
         throw new NotSupportedException($"Given recurrence '{recurrenceValueObject.GetType().Name}' is not supported");
     }
 }