A class that represents an iCalendar object. To load an iCalendar object, generally a static LoadFromXXX method is used.

Examples

For example, use the following code to load an iCalendar object from a URL:
CopyC#
IICalendar iCal = iCalendar.LoadFromUri(new Uri("http://somesite.com/calendar.ics"));
Once created, an iCalendar object can be used to gathers relevant information about events, todos, time zones, journal entries, and free/busy time.

Namespace: iCal
Assembly: ICalVCard (in ICalVCard.dll) Version: 1.0.0.0 (1.0.0.0)

Syntax

Remarks

The following is an example of loading an iCalendar and displaying a text-based calendar.

CopyC#
// 
// The following code loads and displays an iCalendar 
// with US Holidays for 2006.
// 
IICalendar iCal = iCalendar.LoadFromUri(new Uri("http://www.applegatehomecare.com/Calendars/USHolidays.ics"));

IList<Occurrence> occurrences = iCal.GetOccurrences(
    new iCalDateTime(2006, 1, 1, "US-Eastern", iCal),
    new iCalDateTime(2006, 12, 31, "US-Eastern", iCal));

foreach (Occurrence o in occurrences)
{
    IEvent evt = o.Component as IEvent;
    if (evt != null)
    {
        // Display the date of the event
        Console.Write(o.Period.StartTime.Local.Date.ToString("MM/dd/yyyy") + " -\t");

        // Display the event summary
        Console.Write(evt.Summary);

        // Display the time the event happens (unless it's an all-day event)
        if (evt.Start.HasTime)
        {
            Console.Write(" (" + evt.Start.Local.ToShortTimeString() + " - " + evt.End.Local.ToShortTimeString());
            if (evt.Start.TimeZoneInfo != null)
                Console.Write(" " + evt.Start.TimeZoneInfo.TimeZoneName);
            Console.Write(")");
        }

        Console.Write(Environment.NewLine);
    }
}

The following example loads all active to-do items from an iCalendar:

CopyC#
// 
// The following code loads and displays active todo items from an iCalendar
// for January 6th, 2006.
// 
IICalendar iCal = iCalendar.LoadFromUri(new Uri("http://somesite.com/calendar.ics"));

iCalDateTime dt = new iCalDateTime(2006, 1, 6, "US-Eastern", iCal);
foreach(Todo todo in iCal.Todos)
{
    if (todo.IsActive(dt))
    {
        // Display the todo summary
        Console.WriteLine(todo.Summary);
    }
}

Inheritance Hierarchy

See Also