Пример #1
0
            public static TimeSlot Parse(Parser parser, int startindent)
            {
                var timeslot = new TimeSlot();

                if (parser.curr.kw != Parser.RegKeywords.None)
                {
                    throw parser.GetException("unexpected line in TimeSlots");
                }
                timeslot.Description = parser.GetLine();
                if (parser.curr.indent <= startindent)
                {
                    return(timeslot);
                }
                var ind = parser.curr.indent;

                while (parser.curr.indent == ind)
                {
                    switch (parser.curr.kw)
                    {
                    case Parser.RegKeywords.Time:
                        timeslot.Time = parser.GetTime();
                        break;

                    case Parser.RegKeywords.DayOfWeek:
                        timeslot.DayOfWeek = parser.GetInt();
                        break;

                    case Parser.RegKeywords.Limit:
                        timeslot.Limit = parser.GetInt();
                        break;

                    default:
                        throw parser.GetException("unexpected line in TimeSlot");
                    }
                }
                return(timeslot);
            }
Пример #2
0
 public static TimeSlot Parse(Parser parser, int startindent)
 {
     var timeslot = new TimeSlot();
     if (parser.curr.kw != Parser.RegKeywords.None)
         throw parser.GetException("unexpected line in TimeSlots");
     timeslot.Description = parser.GetLine();
     if (parser.curr.indent <= startindent)
         return timeslot;
     var ind = parser.curr.indent;
     while (parser.curr.indent == ind)
     {
         switch (parser.curr.kw)
         {
             case Parser.RegKeywords.Time:
                 timeslot.Time = parser.GetTime();
                 break;
             case Parser.RegKeywords.DayOfWeek:
                 timeslot.DayOfWeek = parser.GetInt();
                 break;
             case Parser.RegKeywords.Limit:
                 timeslot.Limit = parser.GetInt();
                 break;
             default:
                 throw parser.GetException("unexpected line in TimeSlot");
         }
     }
     return timeslot;
 }