using System;
namespace Spectre.Console
{
///
/// Contains extension methods for .
///
public static class ProgressTaskExtensions
{
///
/// Sets the task description.
///
/// The task.
/// The description.
/// The same instance so that multiple calls can be chained.
public static ProgressTask Description(this ProgressTask task, string description)
{
if (task is null)
{
throw new ArgumentNullException(nameof(task));
}
task.Description = description;
return task;
}
///
/// Sets the max value of the task.
///
/// The task.
/// The max value.
/// The same instance so that multiple calls can be chained.
public static ProgressTask MaxValue(this ProgressTask task, double value)
{
if (task is null)
{
throw new ArgumentNullException(nameof(task));
}
task.MaxValue = value;
return task;
}
///
/// Sets the value of the task.
///
/// The task.
/// The value.
/// The same instance so that multiple calls can be chained.
public static ProgressTask Value(this ProgressTask task, double value)
{
if (task is null)
{
throw new ArgumentNullException(nameof(task));
}
task.Value = value;
return task;
}
///
/// Sets whether the task is considered indeterminate or not.
///
/// The task.
/// Whether the task is considered indeterminate or not.
/// The same instance so that multiple calls can be chained.
public static ProgressTask IsIndeterminate(this ProgressTask task, bool indeterminate = true)
{
if (task is null)
{
throw new ArgumentNullException(nameof(task));
}
task.IsIndeterminate = indeterminate;
return task;
}
}
}