using System; namespace Spectre.Console; /// /// Contains extension methods for . /// public static class HasBoxBorderExtensions { /// /// Sets the border. /// /// An object type with a border. /// The object to set the border for. /// The border to use. /// The same instance so that multiple calls can be chained. public static T Border(this T obj, BoxBorder border) where T : class, IHasBoxBorder { if (obj is null) { throw new ArgumentNullException(nameof(obj)); } obj.Border = border; return obj; } /// /// Do not display a border. /// /// An object type with a border. /// The object to set the border for. /// The same instance so that multiple calls can be chained. public static T NoBorder(this T obj) where T : class, IHasBoxBorder { return Border(obj, BoxBorder.None); } /// /// Display a square border. /// /// An object type with a border. /// The object to set the border for. /// The same instance so that multiple calls can be chained. public static T SquareBorder(this T obj) where T : class, IHasBoxBorder { return Border(obj, BoxBorder.Square); } /// /// Display an ASCII border. /// /// An object type with a border. /// The object to set the border for. /// The same instance so that multiple calls can be chained. public static T AsciiBorder(this T obj) where T : class, IHasBoxBorder { return Border(obj, BoxBorder.Ascii); } /// /// Display a rounded border. /// /// An object type with a border. /// The object to set the border for. /// The same instance so that multiple calls can be chained. public static T RoundedBorder(this T obj) where T : class, IHasBoxBorder { return Border(obj, BoxBorder.Rounded); } /// /// Display a heavy border. /// /// An object type with a border. /// The object to set the border for. /// The same instance so that multiple calls can be chained. public static T HeavyBorder(this T obj) where T : class, IHasBoxBorder { return Border(obj, BoxBorder.Heavy); } /// /// Display a double border. /// /// An object type with a border. /// The object to set the border for. /// The same instance so that multiple calls can be chained. public static T DoubleBorder(this T obj) where T : class, IHasBoxBorder { return Border(obj, BoxBorder.Double); } }