// Decompiled with JetBrains decompiler
// Type: TaskScheduler.TaskList
// Assembly: AutoKMS, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: D1CED9E3-1FC7-49B8-B3AC-44976AB7F6E4
// Assembly location: C:\Users\Administrateur\Downloads\Virusshare-00000-msil\HackTool.Win32.KMSAuto.i-f317ba4d4051fad64a0aa45b587fa3dcea795bac30acec2872779abe31a07cbe.exe

using System;
using System.Collections;

namespace TaskScheduler
{
  public class TaskList : IEnumerable, IDisposable
  {
    private ScheduledTasks st;
    private string nameComputer;

    internal TaskList() => this.st = new ScheduledTasks();

    internal TaskList(string computer) => this.st = new ScheduledTasks(computer);

    internal string TargetComputer
    {
      get => this.nameComputer;
      set
      {
        this.st.Dispose();
        this.st = new ScheduledTasks(value);
        this.nameComputer = value;
      }
    }

    public Task NewTask(string name) => this.st.CreateTask(name);

    public void Delete(string name) => this.st.DeleteTask(name);

    public Task this[string name] => this.st.OpenTask(name);

    public IEnumerator GetEnumerator() => (IEnumerator) new TaskList.Enumerator(this.st);

    public void Dispose() => this.st.Dispose();

    private class Enumerator : IEnumerator
    {
      private ScheduledTasks outer;
      private string[] nameTask;
      private int curIndex;
      private Task curTask;

      internal Enumerator(ScheduledTasks st)
      {
        this.outer = st;
        this.nameTask = st.GetTaskNames();
        this.Reset();
      }

      public bool MoveNext()
      {
        bool flag = ++this.curIndex < this.nameTask.Length;
        if (flag)
          this.curTask = this.outer.OpenTask(this.nameTask[this.curIndex]);
        return flag;
      }

      public void Reset()
      {
        this.curIndex = -1;
        this.curTask = (Task) null;
      }

      public object Current => (object) this.curTask;
    }
  }
}
