상속: DDay.iCal.UniqueComponent, IFreeBusy
예제 #1
0
        /// <summary>
        /// Removes an <see cref="iCalObject"/>-based component from all
        /// of the collections that this object may be contained in within
        /// the iCalendar.
        /// </summary>
        /// <param name="child"></param>
        public override void RemoveChild(iCalObject child)
        {
            base.RemoveChild(child);

            if (child is UniqueComponent)
            {
                UniqueComponents.Remove((UniqueComponent)child);
            }

            Type type = child.GetType();

            if (type == typeof(Event) || type.IsSubclassOf(typeof(Event)))
            {
                Events.Remove((Event)child);
            }
            else if (type == typeof(FreeBusy) || type.IsSubclassOf(typeof(FreeBusy)))
            {
                FreeBusy.Remove((FreeBusy)child);
            }
            else if (type == typeof(Journal) || type.IsSubclassOf(typeof(Journal)))
            {
                Journals.Remove((Journal)child);
            }
            else if (type == typeof(DDay.iCal.Components.TimeZone) || type.IsSubclassOf(typeof(DDay.iCal.Components.TimeZone)))
            {
                TimeZones.Remove((DDay.iCal.Components.TimeZone)child);
            }
            else if (type == typeof(Todo) || type.IsSubclassOf(typeof(Todo)))
            {
                Todos.Remove((Todo)child);
            }
        }
예제 #2
0
        /// <summary>
        /// Adds an <see cref="iCalObject"/>-based component to the
        /// appropriate collection.  Currently, the iCalendar component
        /// supports the following components:
        ///     <list type="bullet">
        ///         <item><see cref="DDay.iCal.Components.Event"/></item>
        ///         <item><see cref="DDay.iCal.Components.FreeBusy"/></item>
        ///         <item><see cref="DDay.iCal.Components.Journal"/></item>
        ///         <item><see cref="DDay.iCal.Components.TimeZone"/></item>
        ///         <item><see cref="DDay.iCal.Components.Todo"/></item>
        ///     </list>
        /// </summary>
        /// <param name="child"></param>
        public override void AddChild(iCalObject child)
        {
            base.AddChild(child);
            child.Parent = this;

            if (child is UniqueComponent)
            {
                UniqueComponents.Add((UniqueComponent)child);
            }

            Type type = child.GetType();

            if (type == typeof(Event) || type.IsSubclassOf(typeof(Event)))
            {
                Events.Add((Event)child);
            }
            else if (type == typeof(FreeBusy) || type.IsSubclassOf(typeof(FreeBusy)))
            {
                FreeBusy.Add((FreeBusy)child);
            }
            else if (type == typeof(Journal) || type.IsSubclassOf(typeof(Journal)))
            {
                Journals.Add((Journal)child);
            }
            else if (type == typeof(iCalTimeZone) || type.IsSubclassOf(typeof(iCalTimeZone)))
            {
                TimeZones.Add((iCalTimeZone)child);
            }
            else if (type == typeof(Todo) || type.IsSubclassOf(typeof(Todo)))
            {
                Todos.Add((Todo)child);
            }
        }
예제 #3
0
 public void Dispose()
 {
     Children.Clear();
     Events.Clear();
     FreeBusy.Clear();
     Journals.Clear();
     Todos.Clear();
 }
예제 #4
0
 public void Dispose()
 {
     Children.Clear();
     Events.Clear();
     FreeBusy.Clear();
     Journals.Clear();
     Todos.Clear();
     TimeZones.Clear();
     UniqueComponents.Clear();
 }
예제 #5
0
        ///// <summary>
        ///// Returns a list of flattened recurrences for all recurring components
        ///// in the iCalendar.
        ///// </summary>
        ///// <returns>A list of flattened recurrences for all recurring components</returns>
        //public IEnumerable<RecurringComponent> FlattenRecurrences()
        //{
        //    foreach (RecurringComponent rc in RecurringComponents)
        //        foreach (RecurringComponent instance in rc.FlattenRecurrences())
        //            yield return instance;
        //}

        ///// <summary>
        ///// Returns a list of flattened recurrences of type T.
        ///// </summary>
        ///// <typeparam name="T">The type for which to return flattened recurrences</typeparam>
        ///// <returns>A list of flattened recurrences of type T</returns>
        //public IEnumerable<T> FlattenRecurrences<T>()
        //{
        //    foreach (RecurringComponent rc in FlattenRecurrences())
        //    {
        //        if (rc is T)
        //        {
        //            object obj = rc;
        //            yield return (T)obj;
        //        }
        //    }
        //}

        ///// <summary>
        ///// Returns a list of flattened recurrence instances for the given date range.
        ///// </summary>
        ///// <param name="startDate">The starting date of the date range</param>
        ///// <param name="endDate">The ending date of the date range</param>
        ///// <returns>A list of flattened recurrences for the date range</returns>
        //public IEnumerable<RecurringComponent> GetRecurrencesForRange(Date_Time startDate, Date_Time endDate)
        //{
        //    foreach (RecurringComponent rc in GetRecurrencesForRange<RecurringComponent>(startDate, endDate))
        //        yield return rc;
        //}

        ///// <summary>
        ///// Returns a list of flattened recurrence instances of type T for the given date range.
        ///// </summary>
        ///// <param name="startDate">The starting date of the date range</param>
        ///// <param name="endDate">The ending date of the date range</param>
        ///// <returns>A list of flattened recurrences of type T for the date range</returns>
        //public IEnumerable<T> GetRecurrencesForRange<T>(Date_Time startDate, Date_Time endDate)
        //{
        //    Evaluate<T>(startDate, endDate);

        //    foreach (T t in FlattenRecurrences<T>())
        //    {
        //        if (t is RecurringComponent)
        //        {
        //            RecurringComponent rc = (RecurringComponent)(object)t;
        //            if (rc.Start >= startDate && rc.Start <= endDate)
        //                yield return t;
        //        }
        //    }
        //}

        #endregion

        #region IDisposable Members

        public void Dispose()
        {
            Children.Clear();
            Events.Clear();
            FreeBusy.Clear();
            Journals.Clear();
            Todos.Clear();
            // FIXME: disposing of time zones currently causes problems when merging calendars.
            // There are probably problems anyway when serializing, but for now...
            //TimeZones.Clear();
            //UniqueComponents.Clear();
        }
예제 #6
0
        /// <summary>
        /// Adds an <see cref="iCalObject"/>-based component to the
        /// appropriate collection.  Currently, the iCalendar component
        /// supports the following components:
        ///     <list>
        ///         <item>Event</item>
        ///         <item>FreeBusy</item>
        ///         <item>Journal</item>
        ///         <item>TimeZone</item>
        ///         <item>Todo</item>
        ///     </list>
        /// </summary>
        /// <param name="child"></param>
        public override void AddChild(iCalObject child)
        {
            Type type = child.GetType();

            switch (type.Name)
            {
            case "Event": Events.Add(child); break;

            case "FreeBusy": FreeBusy.Add(child); break;

            case "Journal": Journals.Add(child); break;

            case "TimeZone": TimeZones.Add(child); break;

            case "Todo": Todos.Add(child); break;

            default: break;
            }
        }
예제 #7
0
        static public IFreeBusy CreateRequest(IDateTime fromInclusive, IDateTime toExclusive, IOrganizer organizer, IAttendee[] contacts)
        {
            var fb = new FreeBusy();

            fb.DTStamp = iCalDateTime.Now;
            fb.DTStart = fromInclusive;
            fb.DTEnd   = toExclusive;
            if (organizer != null)
            {
                fb.Organizer = organizer.Copy <IOrganizer>();
            }
            if (contacts != null)
            {
                foreach (var attendee in contacts)
                {
                    fb.Attendees.Add(attendee.Copy <IAttendee>());
                }
            }

            return(fb);
        }
예제 #8
0
        /// <summary>
        /// Adds an <see cref="iCalObject"/>-based component to the
        /// appropriate collection.  Currently, the iCalendar component
        /// supports the following components:
        ///     <list type="bullet">
        ///         <item><see cref="Event"/></item>
        ///         <item><see cref="FreeBusy"/></item>
        ///         <item><see cref="Journal"/></item>
        ///         <item><see cref="DDay.iCal.Components.TimeZone"/></item>
        ///         <item><see cref="Todo"/></item>
        ///     </list>
        /// </summary>
        /// <param name="child"></param>
        public override void AddChild(iCalObject child)
        {
            base.AddChild(child);
            child.Parent = this;

            Type type = child.GetType();

            switch (type.Name)
            {
            case "Event": Events.Add((Event)child); break;

            case "FreeBusy": FreeBusy.Add((FreeBusy)child); break;

            case "Journal": Journals.Add((Journal)child); break;

            case "TimeZone": TimeZones.Add((DDay.iCal.Components.TimeZone)child); break;

            case "Todo": Todos.Add((Todo)child); break;

            default: break;
            }
        }
예제 #9
0
        static public IFreeBusy CreateRequest(IDateTime fromInclusive, IDateTime toExclusive, IOrganizer organizer, IAttendee[] contacts)
        {
            FreeBusy fb = new FreeBusy();
            fb.DTStamp = iCalDateTime.Now;
            fb.DTStart = fromInclusive;
            fb.DTEnd = toExclusive;
            if (organizer != null)
                fb.Organizer = organizer.Copy<IOrganizer>();
            if (contacts != null)
            {
                foreach (IAttendee attendee in contacts)
                    fb.Attendees.Add(attendee.Copy<IAttendee>());
            }

            return fb;
        }