/// <summary>
 /// Adds a formatted string to a console.
 /// </summary>
 /// <param name="context">Context</param>
 /// <param name="color">Text color</param>
 /// <param name="format">Format string</param>
 /// <param name="args">Arguments</param>
 public static void WriteLine(this PerformContext context, ConsoleTextColor color, string format, params object[] args)
     => WriteLine(context, color, string.Format(format, args));
 /// <summary>
 /// Adds an updateable named progress bar to console.
 /// </summary>
 /// <param name="context">Context</param>
 /// <param name="name">Name</param>
 /// <param name="value">Initial value</param>
 /// <param name="color">Progress bar color</param>
 public static IProgressBar WriteProgressBar(this PerformContext context, string name, double value = 0, ConsoleTextColor color = null)
 {
     return ConsoleContext.FromPerformContext(context)?.WriteProgressBar(name, value, color) ?? new NoOpProgressBar();
 }
 /// <summary>
 /// Adds a formatted string to a console.
 /// </summary>
 /// <param name="context">Context</param>
 /// <param name="color">Text color</param>
 /// <param name="format">Format string</param>
 /// <param name="arg0">Argument</param>
 /// <param name="arg1">Argument</param>
 /// <param name="arg2">Argument</param>
 public static void WriteLine(this PerformContext context, ConsoleTextColor color, string format, object arg0, object arg1, object arg2)
     => WriteLine(context, color, string.Format(format, arg0, arg1, arg2));
 /// <summary>
 /// Adds a value to a console.
 /// </summary>
 /// <param name="context">Context</param>
 /// <param name="color">Text color</param>
 /// <param name="value">Value</param>
 public static void WriteLine(this PerformContext context, ConsoleTextColor color, object value)
     => WriteLine(context, color, value?.ToString());
 /// <summary>
 /// Adds an updateable progress bar to console.
 /// </summary>
 /// <param name="context">Context</param>
 /// <param name="value">Initial value</param>
 /// <param name="color">Progress bar color</param>
 public static IProgressBar WriteProgressBar(this PerformContext context, int value = 0, ConsoleTextColor color = null)
 {
     return(ConsoleContext.FromPerformContext(context)?.WriteProgressBar(value, color) ?? new NoOpProgressBar());
 }
Beispiel #6
0
 /// <summary>
 /// Returns an <see cref="IEnumerable{T}"/> reporting enumeration progress.
 /// </summary>
 /// <typeparam name="T">Item type</typeparam>
 /// <param name="enumerable">Source enumerable</param>
 /// <param name="context">Perform context</param>
 /// <param name="name">Progress bar name</param>
 /// <param name="color">Progress bar color</param>
 /// <param name="count">Item count</param>
 public static IEnumerable <T> WithProgress <T>(this IEnumerable <T> enumerable, PerformContext context, string name, ConsoleTextColor color = null, int count = -1)
 {
     return(WithProgress(enumerable, context.WriteProgressBar(name, 0, color), count));
 }
Beispiel #7
0
 /// <summary>
 /// Returns ab <see cref="IEnumerable"/> reporting enumeration progress.
 /// </summary>
 /// <param name="enumerable">Source enumerable</param>
 /// <param name="context">Perform context</param>
 /// <param name="color">Progress bar color</param>
 /// <param name="count">Item count</param>
 public static IEnumerable WithProgress(this IEnumerable enumerable, PerformContext context, ConsoleTextColor color = null, int count = -1)
 {
     return(WithProgress(enumerable, context.WriteProgressBar(0, color), count));
 }