using System; using System.Collections; namespace TaskScheduler { /// /// Deprecated. Provided for V1 compatibility only. /// /// ///

Presents the Scheduled Tasks folder as a Task Collection.

/// ///

A TaskList is indexed by name rather than position. /// You can't add, remove, or assign tasks in TaskList. Accessing /// a Task in the list by indexing, or by enumeration, is equivalent to opening a task /// by calling the ScheduledTasks Open() method.

///

Provided for compatibility with version one of the library. Use of Scheduler /// and TaskList will normally result in COM memory leaks.

///
public class TaskList : IEnumerable, IDisposable { /// /// Scheduled Tasks folder supporting this TaskList. /// private ScheduledTasks st = null; /// /// Name of the target computer whose Scheduled Tasks are to be accessed. /// private string nameComputer; /// /// Constructors - marked internal so you have to create using Scheduler class. /// internal TaskList() { st = new ScheduledTasks(); } internal TaskList(string computer) { st = new ScheduledTasks(computer); } /// /// Enumerator for TaskList /// private class Enumerator : IEnumerator { private ScheduledTasks outer; private string[] nameTask; private int curIndex; private Task curTask; /// /// Internal constructor - Only accessable through /// /// ScheduledTasks object internal Enumerator(ScheduledTasks st) { outer = st; nameTask = st.GetTaskNames(); Reset(); } /// /// Moves to the next task. See for more information. /// /// true if next task found, false if no more tasks. public bool MoveNext() { bool ok = ++curIndex < nameTask.Length; if (ok) curTask = outer.OpenTask(nameTask[curIndex]); return ok; } /// /// Reset task enumeration. See for more information. /// public void Reset() { curIndex = -1; curTask = null; } /// /// Retrieves the current task. See for more information. /// public object Current { get { return curTask; } } } /// /// Name of target computer /// internal string TargetComputer { get { return nameComputer; } set { st.Dispose(); st = new ScheduledTasks(value); nameComputer = value; } } /// /// Creates a new task on the system with the supplied . /// /// Unique display name for the task. If not unique, an ArgumentException will be thrown. /// Instance of new task /// There is already a task of the same name as the one supplied for the new task. public Task NewTask(string name) { return st.CreateTask(name); } /// /// Deletes the task of the given . /// /// Name of task to delete public void Delete(string name) { st.DeleteTask(name); } /// /// Indexer which retrieves task of given . /// /// Name of task to retrieve public Task this[string name] { get { return st.OpenTask(name); } } #region Implementation of IEnumerable /// /// Gets a TaskList enumerator /// /// Enumerator for TaskList public System.Collections.IEnumerator GetEnumerator() { return new Enumerator(st); } #endregion #region Implementation of IDisposable /// /// Disposes TaskList /// public void Dispose() { st.Dispose(); } #endregion } }