/// <summary> /// Gets an IEnumerator instance for this collection. /// </summary> /// <returns>An enumerator.</returns> public IEnumerator <RunningTask> GetEnumerator() { if (v2Coll != null) { return(new ComEnumerator <RunningTask, V2Interop.IRunningTask>(() => v2Coll.Count, (object o) => v2Coll[o], o => { V2Interop.IRegisteredTask task = null; try { task = TaskService.GetTask(svc.v2TaskService, o.Path); } catch { } return task == null ? null : new RunningTask(svc, task, o); })); } return(new V1RunningTaskEnumerator(svc)); }
/// <summary> /// Gets an IEnumerator instance for this collection. /// </summary> /// <returns>An enumerator.</returns> public IEnumerator <RunningTask> GetEnumerator() { if (v2Coll != null) { return(new ComEnumerator <RunningTask, V2Interop.IRunningTaskCollection>(v2Coll, o => { var irt = (V2Interop.IRunningTask)o; V2Interop.IRegisteredTask task = null; try { task = TaskService.GetTask(svc.v2TaskService, irt.Path); } catch { } return task == null ? null : new RunningTask(svc, task, irt); })); } return(new V1RunningTaskEnumerator(svc)); }
/// <summary> /// Gets the task with the specified path. /// </summary> /// <param name="taskPath">The task path.</param> /// <returns>The task.</returns> public Task GetTask(string taskPath) { Task t = null; if (v2TaskService != null) { V2Interop.IRegisteredTask iTask = GetTask(this.v2TaskService, taskPath); if (iTask != null) { t = new Task(this, iTask); } } else { V1Interop.ITask iTask = GetTask(this.v1TaskScheduler, taskPath); if (iTask != null) { t = new Task(this, iTask); } } return(t); }
/// <summary> /// Gets the task with the specified path. /// </summary> /// <param name="taskPath">The task path.</param> /// <returns>The <see cref="Task"/> instance matching the <paramref name="taskPath"/>, if found. If not found, this method returns <c>null</c>.</returns> public Task GetTask([NotNull] string taskPath) { Task t = null; if (v2TaskService != null) { V2Interop.IRegisteredTask iTask = GetTask(v2TaskService, taskPath); if (iTask != null) { t = Task.CreateTask(this, iTask); } } else { taskPath = System.IO.Path.GetFileNameWithoutExtension(taskPath); V1Interop.ITask iTask = GetTask(v1TaskScheduler, taskPath); if (iTask != null) { t = new Task(this, iTask); } } return(t); }
internal Task(TaskService svc, TaskScheduler.V2Interop.IRegisteredTask iTask) { this.TaskService = svc; v2Task = iTask; }