Esempio n. 1
0
        public override object Deserialize(TextReader tr)
        {
            if (tr == null)
            {
                return(null);
            }

            using (tr)
            {
                var ctx      = SerializationContext;
                var contents = tr.ReadToEnd();

                using (var normalized = TextUtil.Normalize(contents, ctx))
                {
                    var lexer  = new iCalLexer(normalized);
                    var parser = new iCalParser(lexer);

                    // Parse the iCalendar(s)!
                    var iCalendars = parser.icalendar(SerializationContext);

                    // Return the parsed iCalendar(s)
                    return(iCalendars);
                }
            }
        }
        public override iCalObject Deserialize(TextReader tr, Type iCalendarType)
        {
            // Normalize line endings, so "\r" is treated the same as "\r\n"
            // NOTE: fixed bug #1773194 - Some applications emit mixed line endings
            TextReader textReader = NormalizeLineEndings(tr);

            // Create a lexer for our text stream
            iCalLexer  lexer  = new iCalLexer(textReader);
            iCalParser parser = new iCalParser(lexer);

            // Determine the calendar type we'll be using when constructing
            // iCalendar objects...
            parser.iCalendarType = iCalendarType;

            // Parse the component!
            DDay.iCal.iCalendar iCal      = new DDay.iCal.iCalendar();
            iCalObject          component = parser.component(iCal);

            // Close our text stream
            tr.Close();
            textReader.Close();

            // Return the parsed component
            return(component);
        }
Esempio n. 3
0
        public override object Deserialize(TextReader tr)
        {
            if (tr != null)
            {
                // Normalize the text before parsing it
                tr = TextUtil.Normalize(tr, SerializationContext);

                // Create a lexer for our text stream
                iCalLexer  lexer  = new iCalLexer(tr);
                iCalParser parser = new iCalParser(lexer);

                // Get our serialization context
                ISerializationContext ctx = SerializationContext;

                // Get a serializer factory from our serialization services
                ISerializerFactory sf = GetService <ISerializerFactory>();

                // Get a calendar component factory from our serialization services
                ICalendarComponentFactory cf = GetService <ICalendarComponentFactory>();

                // Parse the component!
                ICalendarComponent component = parser.component(ctx, sf, cf, null);

                // Close our text stream
                tr.Close();

                // Return the parsed component
                return(component);
            }
            return(null);
        }
Esempio n. 4
0
        public override object Deserialize(TextReader tr)
        {
            if (tr == null)
            {
                return(null);
            }

            using (tr)
            {
                var ctx      = SerializationContext;
                var contents = tr.ReadToEnd();

                using (var normalized = TextUtil.Normalize(contents, ctx))
                {
                    var lexer  = new iCalLexer(normalized);
                    var parser = new iCalParser(lexer);

                    // Get a serializer factory from our serialization services
                    var sf = GetService <ISerializerFactory>();

                    // Get a calendar component factory from our serialization services
                    var cf = GetService <ICalendarComponentFactory>();

                    var parsedComponent = parser.component(ctx, sf, cf, null);
                    return(parsedComponent);
                }
            }
        }
Esempio n. 5
0
        static public ComponentBase LoadFromStream(iCalObject parent, TextReader tr)
        {
            // Create a lexer for our text stream
            iCalLexer  lexer  = new iCalLexer(tr);
            iCalParser parser = new iCalParser(lexer);

            // Determine the calendar type we'll be using when constructing
            // iCalendar components...
            if (parent != null)
            {
                parser.iCalendarType = parent.iCalendar.GetType();
            }
            else
            {
                parent = new iCalendar();
                parser.iCalendarType = typeof(iCalendar);
            }

            // Parse the iCalendar!
            ComponentBase comp = (ComponentBase)parser.component(parent);

            // Close our text stream
            tr.Close();

            // Return the parsed component
            return(comp);
        }
Esempio n. 6
0
        public override object Deserialize(TextReader tr)
        {
            if (tr != null)
            {
                // Normalize the text before parsing it
                tr = TextUtil.Normalize(tr, SerializationContext);

                // Create a lexer for our text stream
                iCalLexer  lexer  = new iCalLexer(tr);
                iCalParser parser = new iCalParser(lexer);

                // Get our serialization context
                ISerializationContext ctx = SerializationContext;

                // Parse the component!
                ICalendarProperty p = parser.property(ctx, null);

                // Close our text stream
                tr.Close();

                // Return the parsed property
                return(p);
            }
            return(null);
        }
Esempio n. 7
0
 public override object Deserialize(TextReader tr)
 {
     using (tr)
     {
         var lexer  = new iCalLexer(tr);
         var parser = new iCalParser(lexer);
         var p      = parser.parameter(SerializationContext, null);
         return(p);
     }
 }
Esempio n. 8
0
        public override object Deserialize(TextReader tr)
        {
            // Create a lexer for our text stream
            iCalLexer  lexer  = new iCalLexer(tr);
            iCalParser parser = new iCalParser(lexer);

            // Get our serialization context
            ISerializationContext ctx = SerializationContext;

            // Parse the component!
            ICalendarParameter p = parser.parameter(ctx, null);

            // Close our text stream
            tr.Close();

            // Return the parsed parameter
            return(p);
        }
        public override iCalObject Deserialize(TextReader tr, Type iCalendarType)
        {
            // Create a lexer for our text stream
            iCalLexer  lexer  = new iCalLexer(tr);
            iCalParser parser = new iCalParser(lexer);

            // Determine the calendar type we'll be using when constructing
            // iCalendar objects...
            parser.iCalendarType = iCalendarType;

            // Parse the iCalendar!
            DDay.iCal.iCalendar iCal = parser.icalobject();

            // Close our text stream
            tr.Close();

            // Return the parsed iCalendar
            return(iCal);
        }
Esempio n. 10
0
        /// <summary>
        ///     Deserializes the specified tr.
        /// </summary>
        /// <param name="tr">The tr.</param>
        /// <returns></returns>
        public override object Deserialize(TextReader tr)
        {
            if (tr != null)
            {
                // Normalize the text before parsing it
                tr = TextUtil.Normalize(tr, SerializationContext);

                // Create a lexer for our text stream
                var lexer  = new iCalLexer(tr);
                var parser = new iCalParser(lexer);

                // Parse the iCalendar(s)!
                IICalendarCollection iCalendars = parser.icalendar(SerializationContext);

                // Close our text stream
                tr.Close( );

                // Return the parsed iCalendar(s)
                return(iCalendars);
            }
            return(null);
        }