/// <summary> /// Initializes a new instance of the <see cref="ZincOxide.Environment.ProgramEnvironment"/> class. /// </summary> /// <param name="task">The task to be carried out.</param> /// <param name="integerRepresentation">The integer representation of the program.</param> /// <param name="floatRepresentation">The float representation of the program.</param> /// <param name="verbosity">The verbosity level of the program.</param> public ProgramEnvironment(ProgramTask task = DefaultTask, ProgramIntegerRepresentation integerRepresentation = DefaultIntegerRepresentation, ProgramFloatRepresentation floatRepresentation = DefaultFloatRepresentation, ProgramVerbosity verbosity = DefaultVerbosity) { this.Task = task; this.IntegerRepresentation = integerRepresentation; this.FloatRepresentation = floatRepresentation; this.Verbosity = verbosity; }
/// <summary> /// Prints a generic message with a give verbosity, message format and zero or more message arguments. /// </summary> /// <param name="verbosity">The verbosity-level of the message.</param> /// <param name="format">The format of the message.</param> /// <param name="args">An object array that contains zero or more objects to format. </param> /// <exception cref="ArgumentNullException"><paramref name="format"/> or <paramref name="format"/> is <see langword="null"/>.</exception> /// <exception cref="FormatException"><paramref name="format"/> is invalid.</exception> /// <exception cref="FormatException">The index of a format item is less than zero, or greater than or equal to the length of the <paramref name="args"/> array.</exception> /// <remarks> /// <para>If the interaction level doesn't support the given level, no message is printed.</para> /// </remarks> public static void GenericMessage(ProgramVerbosity verbosity, string format, params object[] args) { if ((verbosity & VerbosityLevel) != 0x00) { Console.Error.Write(verbosity.ToString()); Console.Error.Write(": "); Console.Error.WriteLine(format, args); } }
/// <summary> /// Prints a generic message with a give verbosity, message format and zero or more message arguments. /// </summary> /// <param name="verbosity">The verbosity-level of the message.</param> /// <param name="format">The format of the message.</param> /// <param name="args">An object array that contains zero or more objects to format. </param> /// <exception cref="ArgumentNullException"><paramref name="format"/> or <paramref name="format"/> is <see langword="null"/>.</exception> /// <exception cref="FormatException"><paramref name="format"/> is invalid.</exception> /// <exception cref="FormatException">The index of a format item is less than zero, or greater than or equal to the length of the <paramref name="args"/> array.</exception> /// <remarks> /// <para>If the interaction level doesn't support the given level, no message is printed.</para> /// </remarks> public static void GenericMessage(ProgramVerbosity verbosity, string format, params object[] args) { if ((verbosity & VerbosityLevel) != 0x00) { Console.Error.Write (verbosity.ToString ()); Console.Error.Write (": "); Console.Error.WriteLine (format, args); } }
/// <summary> /// Sets the verbosity level of the program using textual input. /// </summary> /// <param name="level">The verbosity level specified by textual input.</param> /// <exception cref="ZincOxideFormatException">If the given level is not a valid level.</exception> public void SetVerbosity(string level) { ProgramVerbosity result; if (Enum.TryParse (level, true, out result)) { this.Verbosity = result; } else { throw new ZincOxideFormatException ("Cannot parse the verbositylevel to be executed."); } }