Example #1
0
    /// <summary>
    /// Parse a directive from a string
    /// </summary>
    /// <param name="directive">The string to parse</param>
    /// <returns>The parsed directive if recognised</returns>
    public static ExecutionDirective Parse(string directive)
    {
      ExecutionDirective output = new ExecutionDirective();
      string loweredDirective = directive.ToLower();

      switch (loweredDirective)
      {
        case "echooff":
          output.EchoOff = true;
          break;

        case "echoon":
          output.EchoOff = false;
          break;

        case "stoponerror":
          output.StopOnError = true;
          break;

        case "ignoreunknowncommands":
          output.IgnoreUnknownCommands = true;
          break;
      }

      return output;
    }
Example #2
0
    /// <summary>
    /// Patch an ExecutionDirective with another
    /// </summary>
    /// <param name="original">The directive to patch</param>
    /// <param name="patch">The patch to apply</param>
    /// <returns>The patched directive</returns>
    public void Patch(ExecutionDirective patch)
    {
      if (patch.EchoOff != null)
        EchoOff = patch.EchoOff;

      if (patch.StopOnError != null)
        StopOnError = patch.StopOnError;

      if (patch.IgnoreUnknownCommands != null)
        IgnoreUnknownCommands = patch.IgnoreUnknownCommands;
    }