/// <summary>
        /// Constructs a new issue template with the given issue level, format and default arguments.
        /// </summary>
        /// <param name="aLevel">The type and priority of the issue (e.g. minor/warning/unrankable).</param>
        /// <param name="aFormat">The formatting string, use {0}, {1}, etc to insert arguments.</param>
        /// <param name="aDefaultArguments">The default arguments for the format string, supply as many of these as you have {0}, {1}, etc.</param>
        public IssueTemplate(Issue.Level aLevel, string aFormat, params object[] aDefaultArguments)
        {
            Level = aLevel;

            format           = aFormat;
            defaultArguments = aDefaultArguments;

            for (int i = 0; i < defaultArguments.Length; ++i)
            {
                if (!format.Contains("{" + i + "}"))
                {
                    throw new ArgumentException(
                              "\"" + aFormat + "\" There are " + defaultArguments.Length + " default arguments given, but the format string " +
                              "does not contain any \"{" + i + "}\", which makes the latter one(s) useless. Ensure there " +
                              "are an equal amount of {0}, {1}, etc as there are default arguments.");
                }
            }

            if (format.Contains("{" + defaultArguments.Length + "}"))
            {
                throw new ArgumentException(
                          "\"" + aFormat + "\" There are " + defaultArguments.Length + " default arguments given, but the format string " +
                          "contains an unused argument place, \"{" + defaultArguments.Length + "}\". Ensure there " +
                          "are an equal amount of {0}, {1}, etc as there are default arguments.");
            }

            cause = null;
        }
示例#2
0
 /// <summary> Returns the icon of the given issue level. </summary>
 protected static string GetIcon(Issue.Level aLevel)
 {
     return
         (aLevel == Issue.Level.Problem ? "cross" :
          aLevel == Issue.Level.Warning ? "exclamation" :
          aLevel == Issue.Level.Minor   ? "minor" :
          aLevel == Issue.Level.Error   ? "error" :
          aLevel == Issue.Level.Check   ? "check" :
          "info");
 }