/// <inheritdoc />
        public void ReadIcs(IcsReader reader)
        {
            Guard.IsNotNull(reader, "reader");

            ReadIcs(reader.ReadContentLine());
        }
Beispiel #2
0
        /// <inheritdoc/>
        public void ReadIcs(IcsReader reader)
        {
            ContentLine content;
            while (null != (content = reader.ReadContentLine()))
            {
                switch (content.Name.ToLowerInvariant())
                {
                    case "end":
                        if (!content.Value.Equals(Component.Names.Event, StringComparison.InvariantCultureIgnoreCase))
                            throw new CalendarException(String.Format("Expected 'END:{0}' not '{1}'.", Component.Names.Event, content));
                        return;
                    case "begin":
                        switch (content.Value.ToUpperInvariant())
                        {
                            case Component.Names.Alarm:
                                Alarm = new VAlarm();
                                Alarm.ReadIcs(reader);
                                break;
                            default:
                                throw new CalendarException(string.Format("'{0}' is not a component of an event.", content.Value));
                        }
                        break;
                    case "attach": Attachments.Add(new CalendarAttachment(content)); break;
                    case "class": Classification = content.ToTag<AccessClassification>(); break;
                    case "comment": Comment.Add(content.ToText()); break;
                    case "created": CreatedOn = content.ToDate(); break;
                    case "dtstamp": CreatedOnByAgent = content.ToDate(); break;
                    case "description": Description = content.ToText(); break;
                    case "duration": Duration = content.ToTimeSpan(); break;
                    case "dtend": EndsOn = content.ToDate(); break;
                    case "geo": GlobalPosition = content.ToGeoCoordinate(); break;
                    case "uid": Id = content.Value; break;
                    case "transp": IsTransparent = content.ToBoolean("TRANSPARENT", "OPAQUE"); break;
                    case "location": Location = content.ToText(); break;
                    case "last-modified": ModifiedOn = content.ToDate(); break;
                    case "organizer": Organizer = content.ToMailAddress(); break;
                    case "exdate": ExcludedDates.AddRange(content.ToRecurrenceDates()); break;
                    case "rdate": RecurrenceDates.AddRange(content.ToRecurrenceDates()); break;
                    case "rrule": RecurrenceRule = RecurrenceRule.Parse(content.Value); break;
                    case "sequence": Revision = content.ToInt32(); break;
                    case "dtstart": StartsOn = content.ToDate(); break;
                    case "recurrence-id": RecurrenceId = content.ToDate(); break;
                    case "summary": Summary = content.ToText(); break;
                    case "status": Status = content.ToTag<EventStatus>(); break;
                    case "url": Uri = content.Value; break;
                    case "categories": Categories.AddRange(content.ToTags<Tag>()); break;
                    case "request-status": RequestStatuses.Add(new RequestStatus(content)); break;
                    case "attendee": Attendees.Add(new Attendee(content)); break;
                    case "contact": Contacts.Add(new Contact(content)); break;
                    case "resources": Resources.AddRange(content.ToTextEnumerable()); break;
                    case "related-to": Relationships.Add(new RelationshipReference(content)); break;
                    case "priority": Priority = content.ToInt32(); break;
                }
            }

            throw new CalendarException("Unexpected end of file.");
        }
Beispiel #3
0
        /// <inheritdoc/>
        public void ReadIcs(IcsReader reader)
        {
            ContentLine content;
            while (null != (content = reader.ReadContentLine()))
            {
                switch (content.Name.ToLowerInvariant())
                {
                    case "end":
                        if (!content.Value.Equals(Component.Names.FreeBusy, StringComparison.InvariantCultureIgnoreCase))
                            throw new CalendarException(String.Format("Expected 'END:{0}' not '{1}'.", Component.Names.FreeBusy, content));
                        return;
                    case "dtstamp":
                        CreatedOnByAgent = content.ToDate();
                        break;
                    case "uid":
                        Id = content.Value;
                        break;
                    case "contact":
                        Contact = new Contact(content);
                        break;
                    case "dtstart":
                        StartsOn = content.ToDate();
                        break;
                    case "dtend":
                        EndsOn = content.ToDate();
                        break;
                    case "organizer":
                        Organizer = content.ToMailAddress();
                        break;
                    case "url":
                        Uri = content.Value;
                        break;
                    case "attendee":
                        Attendees.Add(new Attendee(content));
                        break;
                    case "comment":
                        Comment.Add(content.ToText());
                        break;
                    case "request-status":
                        RequestStatuses.Add(new RequestStatus(content));
                        break;
                    case "freebusy":
                        FreeBusyTimes.Add(new TimeSlot(content));
                        break;
                }
            }

            throw new CalendarException("Unexpected end of file.");
        }
Beispiel #4
0
        /// <summary>
        ///   Read the component properties from the <see cref="IcsReader"/>.
        /// </summary>
        /// <param name="reader">
        ///   The <see cref="IcsReader"/> containing the content of the component.
        /// </param>
        public void ReadIcs(IcsReader reader)
        {
            Guard.IsNotNull(reader, "reader");

            // Must start with "BEGIN:VCARD".
            ContentLine content = reader.ReadContentLine();
            if (content == null)
                throw new CalendarException("Unexpected end of file.");
            if (!(content.Name.ToLowerInvariant() == "begin" && content.Value.ToLowerInvariant() == Component.Names.Card.ToLowerInvariant()))
                throw new CalendarException(string.Format("Expected 'BEGIN:VCARD' not '{0}'.", content));

            // Process the content.
            while (null != (content = reader.ReadContentLine()))
            {
                switch (content.Name.ToLowerInvariant())
                {
                    case "end":
                        if (!content.Value.Equals(Component.Names.Card, StringComparison.InvariantCultureIgnoreCase))
                            throw new CalendarException(String.Format("Expected 'END:{0}' not '{1}'.", Component.Names.Card, content));
                        return;
                    case "adr": Addresses.Add(new VCardAddress(content)); break;
                    case "bday": BirthDate = new VCardDate(content); break;
                    case "categories": Categories.Add(new VCardString(content)); break;
                    case "email": Emails.Add(new VCardString(content)); break;
                    case "fn": FormattedNames.Add(new VCardText(content)); break;
                    case "gender": Gender = content.Value; break;
                    case "geo": GeographicPositions.Add(new VCardUri(content)); break;
                    case "lang": Languages.Add(new VCardString(content)); break;
                    case "kind": Kind = content.Value; break;
                    case "prodid": ProductId = content.Value; break;
                    case "n": Names.Add(new VCardName(content)); break;
                    case "nickname": NickNames.Add(new VCardText(content)); break;
                    case "note": Notes.Add(new VCardText(content)); break;
                    case "photo": Photos.Add(new VCardUri(content)); break;
                    case "source": Sources.Add(new VCardUri(content)); break;
                    case "tel": Telephones.Add(new VCardString(content)); break;
                    case "tz": Timezones.Add(new VCardString(content)); break;
                    case "url": Urls.Add(new VCardUri(content)); break;
                    case "version": Version = content.Value; break;
                }
            }

            throw new CalendarException("Expected 'END:VCARD' not end of file.");
        }
Beispiel #5
0
        /// <summary>
        ///   Read the component properties from the <see cref="IcsReader"/>.
        /// </summary>
        /// <param name="reader">
        ///   The <see cref="IcsReader"/> containing the content of the component.
        /// </param>
        public void ReadIcs(IcsReader reader)
        {
            Guard.IsNotNull(reader, "reader");

            // Must start with "BEGIN:VCALENDAR".
            ContentLine content = reader.ReadContentLine();
            if (content == null)
                throw new CalendarException("Unexpected end of file.");
            if (!(content.Name.ToLowerInvariant() == "begin" && content.Value.ToLowerInvariant() == Component.Names.Calendar.ToLowerInvariant()))
                throw new CalendarException(string.Format("Expected 'BEGIN:VCALENDAR' not '{0}'.", content));

            // Process the content.
            while (null != (content = reader.ReadContentLine()))
            {
                switch (content.Name.ToLowerInvariant())
                {
                    case "end":
                        if (!content.Value.Equals(Component.Names.Calendar, StringComparison.InvariantCultureIgnoreCase))
                            throw new CalendarException(String.Format("Expected 'END:{0}' not '{1}'.", Component.Names.Calendar, content));
                        return;
                    case "version": Version = content.Value; break;
                    case "prodid": ProductId = content.Value; break;
                    case "calscale": Scale = content.Value; break;
                    case "method": Method = content.Value; break;
                    case "begin":
                    {
                        Func<ICalenderComponent> factory;
                        ComponentRegistry.TryGetValue(content.Value, out factory);
                        if (factory == null)
                            throw new CalendarException(string.Format("The calendar component '{0}' is not registered.", content.Value));
                        var component = factory.Invoke();
                        component.ReadIcs(reader);
                        Components.Add(component);
                        break;
                    }
                }
            }

            throw new CalendarException("Expected 'END:VCALENDAR' not end of file.");
        }
Beispiel #6
0
        /// <inheritdoc/>
        public void ReadIcs(IcsReader reader)
        {
            ContentLine content;
            while (null != (content = reader.ReadContentLine()))
            {
                switch (content.Name.ToLowerInvariant())
                {
                    case "begin":
                        SeasonalChange adjustment;
                        switch (content.Value.ToLowerInvariant())
                        {
                            case "standard": adjustment = new StandardChange(); break;
                            case "daylight": adjustment = new DaylightChange(); break;
                            default:
                                throw new CalendarException(string.Format("'{0}' is not a component of a time zone.", content.Value));
                        }
                        adjustment.ReadIcs(reader);
                        Adjustments.Add(adjustment);
                        break;

                    case "end":
                        if (!content.Value.Equals(Component.Names.TimeZone, StringComparison.InvariantCultureIgnoreCase))
                            throw new CalendarException(String.Format("Expected 'END:{0}' not '{1}'.", Component.Names.TimeZone, content));
                        return;

                    case "tzid": Id = content.Value; break;
                    case "last-modified": ModifiedOn = content.ToDate(); break;
                    case "url": Uri = content.Value; break;
                }
            }

            throw new CalendarException("Unexpected end of file.");
        }
        /// <inheritdoc />
        public void ReadIcs(IcsReader reader)
        {
            ContentLine content;
            while (null != (content = reader.ReadContentLine()))
            {
                switch (content.Name.ToLowerInvariant())
                {
                    case "end":
                        return;

                    case "dtstart": StartsOn = content.ToLocalDateTime(); break;
                    case "tzoffsetfrom": OffsetFrom = content.ToTimeZoneOffset(); break;
                    case "tzoffsetto": OffsetTo = content.ToTimeZoneOffset(); break;
                    case "tzname": Name = content.ToText(); break;
                    case "comment": Comment.Add(content.ToText()); break;
                    case "rdate": RecurrenceDates.AddRange(content.ToRecurrenceDates()); break;
                    case "rrule": RecurrenceRule = RecurrenceRule.Parse(content.Value); break;
                }
            }

            throw new CalendarException("Unexpected end of file.");
        }
Beispiel #8
0
 /// <inheritdoc/>
 public void ReadIcs(IcsReader reader)
 {
     ContentLine content;
     while (null != (content = reader.ReadContentLine()))
     {
         switch (content.Name.ToLowerInvariant())
         {
             case "end":
                 if (!content.Value.Equals(Component.Names.Journal, StringComparison.InvariantCultureIgnoreCase))
                     throw new CalendarException(String.Format("Expected 'END:{0}' not '{1}'.", Component.Names.Journal, content));
                 return;
             case "class":
                 Classification = content.ToTag<AccessClassification>();
                 break;
             case "comment":
                 Comment.Add(content.ToText());
                 break;
             case "created":
                 CreatedOn = content.ToDate();
                 break;
             case "dtstamp":
                 CreatedOnByAgent = content.ToDate();
                 break;
             case "description":
                 Description.Add(content.ToText());
                 break;
             case "uid":
                 Id = content.Value;
                 break;
             case "last-modified":
                 ModifiedOn = content.ToDate();
                 break;
             case "organizer":
                 Organizer = content.ToMailAddress();
                 break;
             case "exdate":
                 ExcludedDates.AddRange(content.ToRecurrenceDates());
                 break;
             case "recurrence-id":
                 RecurrenceId = content.ToDate();
                 break;
             case "rdate":
                 RecurrenceDates.AddRange(content.ToRecurrenceDates());
                 break;
             case "rrule":
                 RecurrenceRule = RecurrenceRule.Parse(content.Value);
                 break;
             case "sequence":
                 Revision = content.ToInt32();
                 break;
             case "dtstart":
                 StartsOn = content.ToDate();
                 break;
             case "summary":
                 Summary = content.ToText();
                 break;
             case "status":
                 Status = content.ToTag<JournalStatus>();
                 break;
             case "url":
                 Uri = content.Value;
                 break;
             case "categories":
                 Categories.AddRange(content.ToTags<Tag>());
                 break;
             case "request-status":
                 RequestStatuses.Add(new RequestStatus(content));
                 break;
             case "attendee":
                 Attendees.Add(new Attendee(content));
                 break;
             case "contact":
                 Contacts.Add(new Contact(content));
                 break;
             case "attach":
                 Attachments.Add(new CalendarAttachment(content));
                 break;
             case "related-to":
                 Relationships.Add(new RelationshipReference(content));
                 break;
         }
     }
 }
Beispiel #9
0
        /// <inheritdoc/>
        public void ReadIcs(IcsReader reader)
        {
            ContentLine content;
            while (null != (content = reader.ReadContentLine()))
            {
                switch (content.Name.ToLowerInvariant())
                {
                    case "end":
                        if (!content.Value.Equals(Component.Names.Alarm, StringComparison.InvariantCultureIgnoreCase))
                            throw new CalendarException(String.Format("Expected 'END:{0}' not '{1}'.", Component.Names.TimeZone, content));
                        return;
                    case "attendee": Attendees.Add(new Attendee(content)); break;
                    case "action": Action = content.ToTag<AlarmAction>(); break;
                    case "trigger":
                    {
                        switch ((content.Parameters["value"] ?? "duration").ToLowerInvariant())
                        {
                            case "date-time":
                                TriggerOn = content.ToDate().Value;
                                break;
                            case "duration":
                                TriggerDuration = content.ToTimeSpan();
                                break;
                        }
                        switch ((content.Parameters["related"] ?? "start").ToLowerInvariant())
                        {
                            case "start":
                                TriggerEdge = TriggerEdge.Start;
                                break;
                            case "end":
                                TriggerEdge = TriggerEdge.End;
                                break;
                        }
                        break;
                    }
                    case "duration": Duration = content.ToTimeSpan(); break;
                    case "attach": Attachment = new CalendarAttachment(content); break;
                    case "description": Description = content.ToText(); break;
                    case "summary": Summary = content.ToText(); break;
                    case "repeat": Repeat = content.ToInt32(); break;

                }
            }

            throw new CalendarException("Unexpected end of file.");
        }