virtual public ICalendarComponent Build(string objectName, bool uninitialized) { Type type = null; // Determine the type of component to build. switch (objectName.ToUpper()) { case Components.ALARM: type = typeof(Alarm); break; case Components.EVENT: type = typeof(Event); break; case Components.FREEBUSY: type = typeof(FreeBusy); break; case Components.JOURNAL: type = typeof(Journal); break; case Components.TIMEZONE: type = typeof(iCalTimeZone); break; case Components.TODO: type = typeof(Todo); break; case Components.DAYLIGHT: case Components.STANDARD: type = typeof(iCalTimeZoneInfo); break; default: type = typeof(CalendarComponent); break; } ICalendarComponent c = null; if (uninitialized) { // Create a new, uninitialized object (i.e. no constructor has been called). c = SerializationUtil.GetUninitializedObject(type) as ICalendarComponent; } else { // Create a new, initialized object. c = Activator.CreateInstance(type) as ICalendarComponent; } if (c != null) { // Assign the name of this component. c.Name = objectName.ToUpper(); } return(c); }
public IICalendarCollection icalendar( ISerializationContext ctx ) //throws RecognitionException, TokenStreamException { IICalendarCollection iCalendars = new iCalendarCollection(); SerializationUtil.OnDeserializing(iCalendars); IICalendar iCal = null; ISerializationSettings settings = ctx.GetService(typeof(ISerializationSettings)) as ISerializationSettings; { // ( ... )* for (;;) { if ((LA(1) == CRLF || LA(1) == BEGIN)) { { // ( ... )* for (;;) { if ((LA(1) == CRLF)) { match(CRLF); } else { goto _loop4_breakloop; } } _loop4_breakloop :; } // ( ... )* match(BEGIN); match(COLON); match(VCALENDAR); { // ( ... )* for (;;) { if ((LA(1) == CRLF)) { match(CRLF); } else { goto _loop6_breakloop; } } _loop6_breakloop :; } // ( ... )* ISerializationProcessor <IICalendar> processor = ctx.GetService(typeof(ISerializationProcessor <IICalendar>)) as ISerializationProcessor <IICalendar>; // Do some pre-processing on the calendar: if (processor != null) { processor.PreDeserialization(iCal); } iCal = (IICalendar)SerializationUtil.GetUninitializedObject(settings.iCalendarType); SerializationUtil.OnDeserializing(iCal); // Push the iCalendar onto the serialization context stack ctx.Push(iCal); icalbody(ctx, iCal); match(END); match(COLON); match(VCALENDAR); { // ( ... )* for (;;) { if ((LA(1) == CRLF) && (LA(2) == EOF || LA(2) == CRLF || LA(2) == BEGIN) && (tokenSet_0_.member(LA(3)))) { match(CRLF); } else { goto _loop8_breakloop; } } _loop8_breakloop :; } // ( ... )* // Do some final processing on the calendar: if (processor != null) { processor.PostDeserialization(iCal); } // Notify that the iCalendar has been loaded iCal.OnLoaded(); iCalendars.Add(iCal); SerializationUtil.OnDeserialized(iCal); // Pop the iCalendar off the serialization context stack ctx.Pop(); } else { goto _loop9_breakloop; } } _loop9_breakloop :; } // ( ... )* SerializationUtil.OnDeserialized(iCalendars); return(iCalendars); }