using System;
namespace Spectre.Console
{
///
/// Contains extension methods for .
///
public static class StyleExtensions
{
///
/// Creates a new style from the specified one with
/// the specified foreground color.
///
/// The style.
/// The foreground color.
/// The same instance so that multiple calls can be chained.
public static Style WithForeground(this Style style, Color color)
{
if (style is null)
{
throw new ArgumentNullException(nameof(style));
}
return new Style(
foreground: color,
background: style.Background,
decoration: style.Decoration);
}
///
/// Creates a new style from the specified one with
/// the specified background color.
///
/// The style.
/// The background color.
/// The same instance so that multiple calls can be chained.
public static Style WithBackground(this Style style, Color color)
{
if (style is null)
{
throw new ArgumentNullException(nameof(style));
}
return new Style(
foreground: style.Foreground,
background: color,
decoration: style.Decoration);
}
///
/// Creates a new style from the specified one with
/// the specified text decoration.
///
/// The style.
/// The text decoration.
/// The same instance so that multiple calls can be chained.
public static Style WithDecoration(this Style style, Decoration decoration)
{
if (style is null)
{
throw new ArgumentNullException(nameof(style));
}
return new Style(
foreground: style.Foreground,
background: style.Background,
decoration: decoration);
}
}
}