/// <summary>
 /// Internal base constructor for an unbound Trigger.
 /// </summary>
 internal Trigger()
 {
     iTaskTrigger = null;
     taskTrigger = new TaskTrigger();
     taskTrigger.TriggerSize = (ushort)Marshal.SizeOf(taskTrigger);
     taskTrigger.BeginYear = (ushort)DateTime.Today.Year;
     taskTrigger.BeginMonth = (ushort)DateTime.Today.Month;
     taskTrigger.BeginDay = (ushort)DateTime.Today.Day;
 }
 /// <summary>
 /// Internal constructor which initializes itself from
 /// from an ITaskTrigger interface.
 /// </summary>
 /// <param name="iTrigger">Instance of ITaskTrigger from system task scheduler.</param>
 internal Trigger(ITaskTrigger iTrigger)
 {
     if (iTrigger == null)
         throw new ArgumentNullException("iTrigger", "ITaskTrigger instance cannot be null");
     taskTrigger = new TaskTrigger();
     taskTrigger.TriggerSize = (ushort)Marshal.SizeOf(taskTrigger);
     iTrigger.GetTrigger(ref taskTrigger);
     iTaskTrigger = iTrigger;
 }
 /// <summary>
 /// Creates a new, bound Trigger object from an ITaskTrigger interface.  The type of the
 /// concrete object created is determined by the type of ITaskTrigger.
 /// </summary>
 /// <param name="iTaskTrigger">Instance of ITaskTrigger.</param>
 /// <returns>One of the concrete classes derived from Trigger.</returns>
 /// <exception cref="ArgumentNullException"></exception>
 /// <exception cref="ArgumentException">Unable to recognize trigger type.</exception>
 internal static Trigger CreateTrigger(ITaskTrigger iTaskTrigger)
 {
     if (iTaskTrigger == null)
         throw new ArgumentNullException("iTaskTrigger", "Instance of ITaskTrigger cannot be null");
     TaskTrigger sTaskTrigger = new TaskTrigger();
     sTaskTrigger.TriggerSize = (ushort)Marshal.SizeOf(sTaskTrigger);
     iTaskTrigger.GetTrigger(ref sTaskTrigger);
     switch ((TriggerType)sTaskTrigger.Type)
     {
         case TriggerType.RunOnce:
             return new RunOnceTrigger(iTaskTrigger);
         case TriggerType.RunDaily:
             return new DailyTrigger(iTaskTrigger);
         case TriggerType.RunWeekly:
             return new WeeklyTrigger(iTaskTrigger);
         case TriggerType.RunMonthlyDOW:
             return new MonthlyDowTrigger(iTaskTrigger);
         case TriggerType.RunMonthly:
             return new MonthlyTrigger(iTaskTrigger);
         case TriggerType.OnIdle:
             return new OnIdleTrigger(iTaskTrigger);
         case TriggerType.OnSystemStart:
             return new OnSystemStartTrigger(iTaskTrigger);
         case TriggerType.OnLogon:
             return new OnLogonTrigger(iTaskTrigger);
         default:
             throw new ArgumentException("Unable to recognize type of trigger referenced in iTaskTrigger",
                                         "iTaskTrigger");
     }
 }