Examples
IICalendar iCal = iCalendar.LoadFromUri(new Uri("http://somesite.com/calendar.ics"));
Assembly: ICalVCard (in ICalVCard.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
Visual Basic |
---|
<SerializableAttribute> _ Public Class iCalendar _ Inherits CalendarComponent _ Implements IICalendar, ICalendarComponent, ICalendarPropertyListContainer, ICalendarObject, _ IKeyedObject(Of String), ILoadable, ICopyable, IServiceProvider, _ IServiceProvider, IGetOccurrencesTyped, IGetOccurrences, IMergeable, IDisposable |
Visual C++ |
---|
[SerializableAttribute] public ref class iCalendar : public CalendarComponent, IICalendar, ICalendarComponent, ICalendarPropertyListContainer, ICalendarObject, IKeyedObject<String^>, ILoadable, ICopyable, IServiceProvider, IServiceProvider, IGetOccurrencesTyped, IGetOccurrences, IMergeable, IDisposable |
Remarks
The following is an example of loading an iCalendar and displaying a text-based calendar.
//
// 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:
//
// 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
iCal..::..CalendarObjectBase
iCal..::..CalendarObject
iCal..::..CalendarComponent
iCal..::..iCalendar