mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-06-19 13:28:16 +08:00
Remove verbs from extension methods
Removed the verbs from all extension methods that manipulate properties which makes the API more succinct and easier to read. Also added implicit conversion from string to Style. As a good OSS citizen, I've obsoleted the old methods with a warning for now, so this shouldn't break anyone using the old methods.
This commit is contained in:

committed by
Patrik Svensson

parent
037a215a78
commit
041bd016a2
@ -12,7 +12,7 @@ namespace Spectre.Console
|
||||
/// <param name="obj">The alignable object.</param>
|
||||
/// <param name="alignment">The alignment.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
public static T SetAlignment<T>(this T obj, Justify alignment)
|
||||
public static T Alignment<T>(this T obj, Justify alignment)
|
||||
where T : class, IAlignable
|
||||
{
|
||||
if (obj is null)
|
||||
|
@ -69,7 +69,7 @@ namespace Spectre.Console
|
||||
/// <param name="calendar">The calendar.</param>
|
||||
/// <param name="style">The highlight style.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
public static Calendar SetHighlightStyle(this Calendar calendar, Style? style)
|
||||
public static Calendar HighlightStyle(this Calendar calendar, Style? style)
|
||||
{
|
||||
if (calendar is null)
|
||||
{
|
||||
@ -86,7 +86,7 @@ namespace Spectre.Console
|
||||
/// <param name="calendar">The calendar.</param>
|
||||
/// <param name="style">The header style.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
public static Calendar SetHeaderStyle(this Calendar calendar, Style? style)
|
||||
public static Calendar HeaderStyle(this Calendar calendar, Style? style)
|
||||
{
|
||||
if (calendar is null)
|
||||
{
|
||||
|
@ -17,7 +17,12 @@ namespace Spectre.Console
|
||||
public static T Collapse<T>(this T obj)
|
||||
where T : class, IExpandable
|
||||
{
|
||||
SetExpand<T>(obj, false);
|
||||
if (obj is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(obj));
|
||||
}
|
||||
|
||||
obj.Expand = false;
|
||||
return obj;
|
||||
}
|
||||
|
||||
@ -29,20 +34,14 @@ namespace Spectre.Console
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
public static T Expand<T>(this T obj)
|
||||
where T : class, IExpandable
|
||||
{
|
||||
SetExpand<T>(obj, true);
|
||||
return obj;
|
||||
}
|
||||
|
||||
private static void SetExpand<T>(T obj, bool value)
|
||||
where T : class, IExpandable
|
||||
{
|
||||
if (obj is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(obj));
|
||||
}
|
||||
|
||||
obj.Expand = value;
|
||||
obj.Expand = true;
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,11 +7,29 @@ namespace Spectre.Console
|
||||
/// </summary>
|
||||
public static class HasBorderExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Enables the safe border.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">An object type with a border.</typeparam>
|
||||
/// <param name="obj">The object to enable the safe border for.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
public static T SafeBorder<T>(this T obj)
|
||||
where T : class, IHasBorder
|
||||
{
|
||||
if (obj is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(obj));
|
||||
}
|
||||
|
||||
obj.UseSafeBorder = true;
|
||||
return obj;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disables the safe border.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">An object type with a border.</typeparam>
|
||||
/// <param name="obj">The object to set the border for.</param>
|
||||
/// <param name="obj">The object to disable the safe border for.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
public static T NoSafeBorder<T>(this T obj)
|
||||
where T : class, IHasBorder
|
||||
@ -29,10 +47,10 @@ namespace Spectre.Console
|
||||
/// Sets the border style.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">An object type with a border.</typeparam>
|
||||
/// <param name="obj">The object to set the border color for.</param>
|
||||
/// <param name="obj">The object to set the border style for.</param>
|
||||
/// <param name="style">The border style to set.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
public static T SetBorderStyle<T>(this T obj, Style style)
|
||||
public static T BorderStyle<T>(this T obj, Style style)
|
||||
where T : class, IHasBorder
|
||||
{
|
||||
if (obj is null)
|
||||
@ -51,7 +69,7 @@ namespace Spectre.Console
|
||||
/// <param name="obj">The object to set the border color for.</param>
|
||||
/// <param name="color">The border color to set.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
public static T SetBorderColor<T>(this T obj, Color color)
|
||||
public static T BorderColor<T>(this T obj, Color color)
|
||||
where T : class, IHasBorder
|
||||
{
|
||||
if (obj is null)
|
||||
@ -59,7 +77,7 @@ namespace Spectre.Console
|
||||
throw new ArgumentNullException(nameof(obj));
|
||||
}
|
||||
|
||||
obj.BorderStyle = (obj.BorderStyle ?? Style.Plain).WithForeground(color);
|
||||
obj.BorderStyle = (obj.BorderStyle ?? Style.Plain).Foreground(color);
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,25 @@ namespace Spectre.Console
|
||||
/// </summary>
|
||||
public static class HasBoxBorderExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Sets the border.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">An object type with a border.</typeparam>
|
||||
/// <param name="obj">The object to set the border for.</param>
|
||||
/// <param name="border">The border to use.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
public static T Border<T>(this T obj, BoxBorder border)
|
||||
where T : class, IHasBoxBorder
|
||||
{
|
||||
if (obj is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(obj));
|
||||
}
|
||||
|
||||
obj.Border = border;
|
||||
return obj;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Do not display a border.
|
||||
/// </summary>
|
||||
@ -16,7 +35,7 @@ namespace Spectre.Console
|
||||
public static T NoBorder<T>(this T obj)
|
||||
where T : class, IHasBoxBorder
|
||||
{
|
||||
return SetBorder(obj, BoxBorder.None);
|
||||
return Border(obj, BoxBorder.None);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -28,7 +47,7 @@ namespace Spectre.Console
|
||||
public static T SquareBorder<T>(this T obj)
|
||||
where T : class, IHasBoxBorder
|
||||
{
|
||||
return SetBorder(obj, BoxBorder.Square);
|
||||
return Border(obj, BoxBorder.Square);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -40,7 +59,7 @@ namespace Spectre.Console
|
||||
public static T AsciiBorder<T>(this T obj)
|
||||
where T : class, IHasBoxBorder
|
||||
{
|
||||
return SetBorder(obj, BoxBorder.Ascii);
|
||||
return Border(obj, BoxBorder.Ascii);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -52,7 +71,7 @@ namespace Spectre.Console
|
||||
public static T RoundedBorder<T>(this T obj)
|
||||
where T : class, IHasBoxBorder
|
||||
{
|
||||
return SetBorder(obj, BoxBorder.Rounded);
|
||||
return Border(obj, BoxBorder.Rounded);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -64,7 +83,7 @@ namespace Spectre.Console
|
||||
public static T HeavyBorder<T>(this T obj)
|
||||
where T : class, IHasBoxBorder
|
||||
{
|
||||
return SetBorder(obj, BoxBorder.Heavy);
|
||||
return Border(obj, BoxBorder.Heavy);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -76,26 +95,7 @@ namespace Spectre.Console
|
||||
public static T DoubleBorder<T>(this T obj)
|
||||
where T : class, IHasBoxBorder
|
||||
{
|
||||
return SetBorder(obj, BoxBorder.Double);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the border.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">An object type with a border.</typeparam>
|
||||
/// <param name="obj">The object to set the border for.</param>
|
||||
/// <param name="border">The border to use.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
public static T SetBorder<T>(this T obj, BoxBorder border)
|
||||
where T : class, IHasBoxBorder
|
||||
{
|
||||
if (obj is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(obj));
|
||||
}
|
||||
|
||||
obj.Border = border;
|
||||
return obj;
|
||||
return Border(obj, BoxBorder.Double);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ namespace Spectre.Console
|
||||
/// <param name="obj">The object to set the culture for.</param>
|
||||
/// <param name="culture">The culture to set.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
public static T SetCulture<T>(this T obj, CultureInfo culture)
|
||||
public static T Culture<T>(this T obj, CultureInfo culture)
|
||||
where T : class, IHasCulture
|
||||
{
|
||||
if (obj is null)
|
||||
@ -39,16 +39,15 @@ namespace Spectre.Console
|
||||
/// <param name="obj">The object to set the culture for.</param>
|
||||
/// <param name="name">The culture to set.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
public static T SetCulture<T>(this T obj, string name)
|
||||
public static T Culture<T>(this T obj, string name)
|
||||
where T : class, IHasCulture
|
||||
{
|
||||
if (obj is null)
|
||||
if (name is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(obj));
|
||||
throw new ArgumentNullException(nameof(name));
|
||||
}
|
||||
|
||||
obj.Culture = CultureInfo.GetCultureInfo(name);
|
||||
return obj;
|
||||
return Culture(obj, CultureInfo.GetCultureInfo(name));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -56,18 +55,12 @@ namespace Spectre.Console
|
||||
/// </summary>
|
||||
/// <typeparam name="T">An object type with a culture.</typeparam>
|
||||
/// <param name="obj">The object to set the culture for.</param>
|
||||
/// <param name="name">The culture to set.</param>
|
||||
/// <param name="culture">The culture to set.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
public static T SetCulture<T>(this T obj, int name)
|
||||
public static T Culture<T>(this T obj, int culture)
|
||||
where T : class, IHasCulture
|
||||
{
|
||||
if (obj is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(obj));
|
||||
}
|
||||
|
||||
obj.Culture = CultureInfo.GetCultureInfo(name);
|
||||
return obj;
|
||||
return Culture(obj, CultureInfo.GetCultureInfo(culture));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ namespace Spectre.Console
|
||||
public static T NoBorder<T>(this T obj)
|
||||
where T : class, IHasTableBorder
|
||||
{
|
||||
return SetBorder(obj, TableBorder.None);
|
||||
return Border(obj, TableBorder.None);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -28,7 +28,7 @@ namespace Spectre.Console
|
||||
public static T SquareBorder<T>(this T obj)
|
||||
where T : class, IHasTableBorder
|
||||
{
|
||||
return SetBorder(obj, TableBorder.Square);
|
||||
return Border(obj, TableBorder.Square);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -40,7 +40,7 @@ namespace Spectre.Console
|
||||
public static T AsciiBorder<T>(this T obj)
|
||||
where T : class, IHasTableBorder
|
||||
{
|
||||
return SetBorder(obj, TableBorder.Ascii);
|
||||
return Border(obj, TableBorder.Ascii);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -52,7 +52,7 @@ namespace Spectre.Console
|
||||
public static T Ascii2Border<T>(this T obj)
|
||||
where T : class, IHasTableBorder
|
||||
{
|
||||
return SetBorder(obj, TableBorder.Ascii2);
|
||||
return Border(obj, TableBorder.Ascii2);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -64,7 +64,7 @@ namespace Spectre.Console
|
||||
public static T AsciiDoubleHeadBorder<T>(this T obj)
|
||||
where T : class, IHasTableBorder
|
||||
{
|
||||
return SetBorder(obj, TableBorder.AsciiDoubleHead);
|
||||
return Border(obj, TableBorder.AsciiDoubleHead);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -76,7 +76,7 @@ namespace Spectre.Console
|
||||
public static T RoundedBorder<T>(this T obj)
|
||||
where T : class, IHasTableBorder
|
||||
{
|
||||
return SetBorder(obj, TableBorder.Rounded);
|
||||
return Border(obj, TableBorder.Rounded);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -88,7 +88,7 @@ namespace Spectre.Console
|
||||
public static T MinimalBorder<T>(this T obj)
|
||||
where T : class, IHasTableBorder
|
||||
{
|
||||
return SetBorder(obj, TableBorder.Minimal);
|
||||
return Border(obj, TableBorder.Minimal);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -100,7 +100,7 @@ namespace Spectre.Console
|
||||
public static T MinimalHeavyHeadBorder<T>(this T obj)
|
||||
where T : class, IHasTableBorder
|
||||
{
|
||||
return SetBorder(obj, TableBorder.MinimalHeavyHead);
|
||||
return Border(obj, TableBorder.MinimalHeavyHead);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -112,7 +112,7 @@ namespace Spectre.Console
|
||||
public static T MinimalDoubleHeadBorder<T>(this T obj)
|
||||
where T : class, IHasTableBorder
|
||||
{
|
||||
return SetBorder(obj, TableBorder.MinimalDoubleHead);
|
||||
return Border(obj, TableBorder.MinimalDoubleHead);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -124,7 +124,7 @@ namespace Spectre.Console
|
||||
public static T SimpleBorder<T>(this T obj)
|
||||
where T : class, IHasTableBorder
|
||||
{
|
||||
return SetBorder(obj, TableBorder.Simple);
|
||||
return Border(obj, TableBorder.Simple);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -136,7 +136,7 @@ namespace Spectre.Console
|
||||
public static T SimpleHeavyBorder<T>(this T obj)
|
||||
where T : class, IHasTableBorder
|
||||
{
|
||||
return SetBorder(obj, TableBorder.SimpleHeavy);
|
||||
return Border(obj, TableBorder.SimpleHeavy);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -148,7 +148,7 @@ namespace Spectre.Console
|
||||
public static T HorizontalBorder<T>(this T obj)
|
||||
where T : class, IHasTableBorder
|
||||
{
|
||||
return SetBorder(obj, TableBorder.Horizontal);
|
||||
return Border(obj, TableBorder.Horizontal);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -160,7 +160,7 @@ namespace Spectre.Console
|
||||
public static T HeavyBorder<T>(this T obj)
|
||||
where T : class, IHasTableBorder
|
||||
{
|
||||
return SetBorder(obj, TableBorder.Heavy);
|
||||
return Border(obj, TableBorder.Heavy);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -172,7 +172,7 @@ namespace Spectre.Console
|
||||
public static T HeavyEdgeBorder<T>(this T obj)
|
||||
where T : class, IHasTableBorder
|
||||
{
|
||||
return SetBorder(obj, TableBorder.HeavyEdge);
|
||||
return Border(obj, TableBorder.HeavyEdge);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -184,7 +184,7 @@ namespace Spectre.Console
|
||||
public static T HeavyHeadBorder<T>(this T obj)
|
||||
where T : class, IHasTableBorder
|
||||
{
|
||||
return SetBorder(obj, TableBorder.HeavyHead);
|
||||
return Border(obj, TableBorder.HeavyHead);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -196,7 +196,7 @@ namespace Spectre.Console
|
||||
public static T DoubleBorder<T>(this T obj)
|
||||
where T : class, IHasTableBorder
|
||||
{
|
||||
return SetBorder(obj, TableBorder.Double);
|
||||
return Border(obj, TableBorder.Double);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -208,7 +208,7 @@ namespace Spectre.Console
|
||||
public static T DoubleEdgeBorder<T>(this T obj)
|
||||
where T : class, IHasTableBorder
|
||||
{
|
||||
return SetBorder(obj, TableBorder.DoubleEdge);
|
||||
return Border(obj, TableBorder.DoubleEdge);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -220,7 +220,7 @@ namespace Spectre.Console
|
||||
public static T MarkdownBorder<T>(this T obj)
|
||||
where T : class, IHasTableBorder
|
||||
{
|
||||
return SetBorder(obj, TableBorder.Markdown);
|
||||
return Border(obj, TableBorder.Markdown);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -230,7 +230,7 @@ namespace Spectre.Console
|
||||
/// <param name="obj">The object to set the border for.</param>
|
||||
/// <param name="border">The border to use.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
public static T SetBorder<T>(this T obj, TableBorder border)
|
||||
public static T Border<T>(this T obj, TableBorder border)
|
||||
where T : class, IHasTableBorder
|
||||
{
|
||||
if (obj is null)
|
||||
|
@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Spectre.Console
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains extension methods for <see cref="IAlignable"/>.
|
||||
/// </summary>
|
||||
public static class ObsoleteAlignableExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Sets the alignment for an <see cref="IAlignable"/> object.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The alignable object type.</typeparam>
|
||||
/// <param name="obj">The alignable object.</param>
|
||||
/// <param name="alignment">The alignment.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
[Obsolete("Use Alignment(..) instead.")]
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public static T SetAlignment<T>(this T obj, Justify alignment)
|
||||
where T : class, IAlignable
|
||||
{
|
||||
if (obj is null)
|
||||
{
|
||||
throw new System.ArgumentNullException(nameof(obj));
|
||||
}
|
||||
|
||||
obj.Alignment = alignment;
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Spectre.Console
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains extension methods for <see cref="Calendar"/>.
|
||||
/// </summary>
|
||||
public static class ObsoleteCalendarExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Sets the calendar's highlight <see cref="Style"/>.
|
||||
/// </summary>
|
||||
/// <param name="calendar">The calendar.</param>
|
||||
/// <param name="style">The highlight style.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
[Obsolete("Use HighlightStyle(..) instead.")]
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public static Calendar SetHighlightStyle(this Calendar calendar, Style? style)
|
||||
{
|
||||
if (calendar is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(calendar));
|
||||
}
|
||||
|
||||
calendar.HightlightStyle = style ?? Style.Plain;
|
||||
return calendar;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the calendar's header <see cref="Style"/>.
|
||||
/// </summary>
|
||||
/// <param name="calendar">The calendar.</param>
|
||||
/// <param name="style">The header style.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
[Obsolete("Use HeaderStyle(..) instead.")]
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public static Calendar SetHeaderStyle(this Calendar calendar, Style? style)
|
||||
{
|
||||
if (calendar is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(calendar));
|
||||
}
|
||||
|
||||
calendar.HeaderStyle = style ?? Style.Plain;
|
||||
return calendar;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Spectre.Console
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains extension methods for <see cref="IHasBorder"/>.
|
||||
/// </summary>
|
||||
public static class ObsoleteHasBorderExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Sets the border style.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">An object type with a border.</typeparam>
|
||||
/// <param name="obj">The object to set the border color for.</param>
|
||||
/// <param name="style">The border style to set.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
[Obsolete("Use BorderStyle(..) instead.")]
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public static T SetBorderStyle<T>(this T obj, Style style)
|
||||
where T : class, IHasBorder
|
||||
{
|
||||
if (obj is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(obj));
|
||||
}
|
||||
|
||||
obj.BorderStyle = style;
|
||||
return obj;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the border color.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">An object type with a border.</typeparam>
|
||||
/// <param name="obj">The object to set the border color for.</param>
|
||||
/// <param name="color">The border color to set.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
[Obsolete("Use BorderColor(..) instead.")]
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public static T SetBorderColor<T>(this T obj, Color color)
|
||||
where T : class, IHasBorder
|
||||
{
|
||||
if (obj is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(obj));
|
||||
}
|
||||
|
||||
obj.BorderStyle = (obj.BorderStyle ?? Style.Plain).Foreground(color);
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Spectre.Console
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains extension methods for <see cref="IHasBoxBorder"/>.
|
||||
/// </summary>
|
||||
public static class ObsoleteHasBoxBorderExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Sets the border.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">An object type with a border.</typeparam>
|
||||
/// <param name="obj">The object to set the border for.</param>
|
||||
/// <param name="border">The border to use.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
[Obsolete("Use Border(..) instead.")]
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public static T SetBorder<T>(this T obj, BoxBorder border)
|
||||
where T : class, IHasBoxBorder
|
||||
{
|
||||
if (obj is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(obj));
|
||||
}
|
||||
|
||||
obj.Border = border;
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Spectre.Console
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains extension methods for <see cref="IHasCulture"/>.
|
||||
/// </summary>
|
||||
public static class ObsoleteHasCultureExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Sets the culture.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">An object type with a culture.</typeparam>
|
||||
/// <param name="obj">The object to set the culture for.</param>
|
||||
/// <param name="culture">The culture to set.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
[Obsolete("Use Culture(..) instead.")]
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public static T SetCulture<T>(this T obj, CultureInfo culture)
|
||||
where T : class, IHasCulture
|
||||
{
|
||||
if (obj is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(obj));
|
||||
}
|
||||
|
||||
if (culture is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(culture));
|
||||
}
|
||||
|
||||
obj.Culture = culture;
|
||||
return obj;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the culture.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">An object type with a culture.</typeparam>
|
||||
/// <param name="obj">The object to set the culture for.</param>
|
||||
/// <param name="name">The culture to set.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
[Obsolete("Use Culture(..) instead.")]
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public static T SetCulture<T>(this T obj, string name)
|
||||
where T : class, IHasCulture
|
||||
{
|
||||
if (obj is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(obj));
|
||||
}
|
||||
|
||||
obj.Culture = CultureInfo.GetCultureInfo(name);
|
||||
return obj;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the culture.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">An object type with a culture.</typeparam>
|
||||
/// <param name="obj">The object to set the culture for.</param>
|
||||
/// <param name="name">The culture to set.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
[Obsolete("Use Culture(..) instead.")]
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public static T SetCulture<T>(this T obj, int name)
|
||||
where T : class, IHasCulture
|
||||
{
|
||||
if (obj is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(obj));
|
||||
}
|
||||
|
||||
obj.Culture = CultureInfo.GetCultureInfo(name);
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Spectre.Console
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains extension methods for <see cref="IHasTableBorder"/>.
|
||||
/// </summary>
|
||||
public static class ObsoleteHasTableBorderExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Sets the border.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">An object type with a border.</typeparam>
|
||||
/// <param name="obj">The object to set the border for.</param>
|
||||
/// <param name="border">The border to use.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
[Obsolete("Use Border(..) instead.")]
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public static T SetBorder<T>(this T obj, TableBorder border)
|
||||
where T : class, IHasTableBorder
|
||||
{
|
||||
if (obj is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(obj));
|
||||
}
|
||||
|
||||
obj.Border = border;
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Spectre.Console
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains extension methods for <see cref="IOverflowable"/>.
|
||||
/// </summary>
|
||||
public static class ObsoleteOverflowableExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Sets the overflow strategy.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">An object implementing <see cref="IOverflowable"/>.</typeparam>
|
||||
/// <param name="obj">The overflowable object instance.</param>
|
||||
/// <param name="overflow">The overflow strategy to use.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
[Obsolete("Use Overflow(..) instead.")]
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public static T SetOverflow<T>(this T obj, Overflow overflow)
|
||||
where T : class, IOverflowable
|
||||
{
|
||||
if (obj is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(obj));
|
||||
}
|
||||
|
||||
obj.Overflow = overflow;
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Spectre.Console
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains extension methods for <see cref="IPaddable"/>.
|
||||
/// </summary>
|
||||
public static class ObsoletePaddableExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Sets the left and right padding.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">An object implementing <see cref="IPaddable"/>.</typeparam>
|
||||
/// <param name="obj">The paddable object instance.</param>
|
||||
/// <param name="left">The left padding to apply.</param>
|
||||
/// <param name="top">The top padding to apply.</param>
|
||||
/// <param name="right">The right padding to apply.</param>
|
||||
/// <param name="bottom">The bottom padding to apply.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
[Obsolete("Use Padding(..) instead.")]
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public static T SetPadding<T>(this T obj, int left, int top, int right, int bottom)
|
||||
where T : class, IPaddable
|
||||
{
|
||||
return SetPadding(obj, new Padding(left, top, right, bottom));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the padding.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">An object implementing <see cref="IPaddable"/>.</typeparam>
|
||||
/// <param name="obj">The paddable object instance.</param>
|
||||
/// <param name="padding">The padding to apply.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
[Obsolete("Use Padding(..) instead.")]
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public static T SetPadding<T>(this T obj, Padding padding)
|
||||
where T : class, IPaddable
|
||||
{
|
||||
if (obj is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(obj));
|
||||
}
|
||||
|
||||
obj.Padding = padding;
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Spectre.Console
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains extension methods for <see cref="Panel"/>.
|
||||
/// </summary>
|
||||
public static class ObsoletePanelExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Sets the panel header.
|
||||
/// </summary>
|
||||
/// <param name="panel">The panel.</param>
|
||||
/// <param name="text">The header text.</param>
|
||||
/// <param name="style">The header style.</param>
|
||||
/// <param name="alignment">The header alignment.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
[Obsolete("Use Header(..) instead.")]
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public static Panel SetHeader(this Panel panel, string text, Style? style = null, Justify? alignment = null)
|
||||
{
|
||||
if (panel is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(panel));
|
||||
}
|
||||
|
||||
if (text is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(text));
|
||||
}
|
||||
|
||||
style ??= panel.Header?.Style;
|
||||
alignment ??= panel.Header?.Alignment;
|
||||
|
||||
return SetHeader(panel, new PanelHeader(text, style, alignment));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the panel header.
|
||||
/// </summary>
|
||||
/// <param name="panel">The panel.</param>
|
||||
/// <param name="header">The header to use.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
[Obsolete("Use Header(..) instead.")]
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public static Panel SetHeader(this Panel panel, PanelHeader header)
|
||||
{
|
||||
if (panel is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(panel));
|
||||
}
|
||||
|
||||
panel.Header = header;
|
||||
return panel;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Spectre.Console
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains extension methods for <see cref="RuleExtensions"/>.
|
||||
/// </summary>
|
||||
public static class ObsoleteRuleExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Sets the rule title.
|
||||
/// </summary>
|
||||
/// <param name="rule">The rule.</param>
|
||||
/// <param name="title">The title.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
[Obsolete("Use Title(..) instead.")]
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public static Rule SetTitle(this Rule rule, string title)
|
||||
{
|
||||
if (rule is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(rule));
|
||||
}
|
||||
|
||||
if (title is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(title));
|
||||
}
|
||||
|
||||
rule.Title = title;
|
||||
return rule;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the rule style.
|
||||
/// </summary>
|
||||
/// <param name="rule">The rule.</param>
|
||||
/// <param name="style">The rule style.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
[Obsolete("Use Style(..) instead.")]
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public static Rule SetStyle(this Rule rule, Style style)
|
||||
{
|
||||
if (rule is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(rule));
|
||||
}
|
||||
|
||||
if (style is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(style));
|
||||
}
|
||||
|
||||
rule.Style = style;
|
||||
return rule;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Spectre.Console
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains extension methods for <see cref="string"/>.
|
||||
/// </summary>
|
||||
public static class ObsoleteStringExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Escapes text so that it won’t be interpreted as markup.
|
||||
/// </summary>
|
||||
/// <param name="text">The text to escape.</param>
|
||||
/// <returns>A string that is safe to use in markup.</returns>
|
||||
[Obsolete("Use EscapeMarkup(..) instead.", false)]
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public static string SafeMarkup(this string text)
|
||||
{
|
||||
return text.EscapeMarkup();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,100 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Spectre.Console
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains extension methods for <see cref="Style"/>.
|
||||
/// </summary>
|
||||
public static class ObsoleteStyleExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new style from the specified one with
|
||||
/// the specified foreground color.
|
||||
/// </summary>
|
||||
/// <param name="style">The style.</param>
|
||||
/// <param name="color">The foreground color.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
[Obsolete("Use Foreground(..) instead.")]
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new style from the specified one with
|
||||
/// the specified background color.
|
||||
/// </summary>
|
||||
/// <param name="style">The style.</param>
|
||||
/// <param name="color">The background color.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
[Obsolete("Use Background(..) instead.")]
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new style from the specified one with
|
||||
/// the specified text decoration.
|
||||
/// </summary>
|
||||
/// <param name="style">The style.</param>
|
||||
/// <param name="decoration">The text decoration.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
[Obsolete("Use Decoration(..) instead.")]
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new style from the specified one with
|
||||
/// the specified link.
|
||||
/// </summary>
|
||||
/// <param name="style">The style.</param>
|
||||
/// <param name="link">The link.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
[Obsolete("Use Link(..) instead.")]
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public static Style WithLink(this Style style, string link)
|
||||
{
|
||||
if (style is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(style));
|
||||
}
|
||||
|
||||
return new Style(
|
||||
foreground: style.Foreground,
|
||||
background: style.Background,
|
||||
decoration: style.Decoration,
|
||||
link: link);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,113 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Spectre.Console.Internal;
|
||||
using Spectre.Console.Rendering;
|
||||
|
||||
namespace Spectre.Console
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains extension methods for <see cref="Table"/>.
|
||||
/// </summary>
|
||||
public static class ObsoleteTableExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Sets the table width.
|
||||
/// </summary>
|
||||
/// <param name="table">The table.</param>
|
||||
/// <param name="width">The width.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
[Obsolete("Use Width(..) instead.")]
|
||||
public static Table SetWidth(this Table table, int width)
|
||||
{
|
||||
if (table is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(table));
|
||||
}
|
||||
|
||||
table.Width = width;
|
||||
return table;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the table heading.
|
||||
/// </summary>
|
||||
/// <param name="table">The table.</param>
|
||||
/// <param name="text">The heading.</param>
|
||||
/// <param name="style">The style.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
[Obsolete("Use Heading(..) instead.")]
|
||||
public static Table SetHeading(this Table table, string text, Style? style = null)
|
||||
{
|
||||
if (table is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(table));
|
||||
}
|
||||
|
||||
if (text is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(text));
|
||||
}
|
||||
|
||||
return SetHeading(table, new TableTitle(text, style));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the table heading.
|
||||
/// </summary>
|
||||
/// <param name="table">The table.</param>
|
||||
/// <param name="heading">The heading.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
[Obsolete("Use Heading(..) instead.")]
|
||||
public static Table SetHeading(this Table table, TableTitle heading)
|
||||
{
|
||||
if (table is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(table));
|
||||
}
|
||||
|
||||
table.Heading = heading;
|
||||
return table;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the table footnote.
|
||||
/// </summary>
|
||||
/// <param name="table">The table.</param>
|
||||
/// <param name="text">The footnote.</param>
|
||||
/// <param name="style">The style.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
[Obsolete("Use Footnote(..) instead.")]
|
||||
public static Table SetFootnote(this Table table, string text, Style? style = null)
|
||||
{
|
||||
if (table is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(table));
|
||||
}
|
||||
|
||||
if (text is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(text));
|
||||
}
|
||||
|
||||
return SetFootnote(table, new TableTitle(text, style));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the table footnote.
|
||||
/// </summary>
|
||||
/// <param name="table">The table.</param>
|
||||
/// <param name="footnote">The footnote.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
[Obsolete("Use Footnote(..) instead.")]
|
||||
public static Table SetFootnote(this Table table, TableTitle footnote)
|
||||
{
|
||||
if (table is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(table));
|
||||
}
|
||||
|
||||
table.Footnote = footnote;
|
||||
return table;
|
||||
}
|
||||
}
|
||||
}
|
@ -21,7 +21,7 @@ namespace Spectre.Console
|
||||
throw new ArgumentNullException(nameof(obj));
|
||||
}
|
||||
|
||||
return SetOverflow(obj, Overflow.Fold);
|
||||
return Overflow(obj, Console.Overflow.Fold);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -38,7 +38,7 @@ namespace Spectre.Console
|
||||
throw new ArgumentNullException(nameof(obj));
|
||||
}
|
||||
|
||||
return SetOverflow(obj, Overflow.Crop);
|
||||
return Overflow(obj, Console.Overflow.Crop);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -55,7 +55,7 @@ namespace Spectre.Console
|
||||
throw new ArgumentNullException(nameof(obj));
|
||||
}
|
||||
|
||||
return SetOverflow(obj, Overflow.Ellipsis);
|
||||
return Overflow(obj, Console.Overflow.Ellipsis);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -65,7 +65,7 @@ namespace Spectre.Console
|
||||
/// <param name="obj">The overflowable object instance.</param>
|
||||
/// <param name="overflow">The overflow strategy to use.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
public static T SetOverflow<T>(this T obj, Overflow overflow)
|
||||
public static T Overflow<T>(this T obj, Overflow overflow)
|
||||
where T : class, IOverflowable
|
||||
{
|
||||
if (obj is null)
|
||||
|
@ -22,7 +22,7 @@ namespace Spectre.Console
|
||||
throw new ArgumentNullException(nameof(obj));
|
||||
}
|
||||
|
||||
return SetPadding(obj, new Padding(left, obj.Padding.Top, obj.Padding.Right, obj.Padding.Bottom));
|
||||
return Padding(obj, new Padding(left, obj.Padding.Top, obj.Padding.Right, obj.Padding.Bottom));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -40,7 +40,7 @@ namespace Spectre.Console
|
||||
throw new ArgumentNullException(nameof(obj));
|
||||
}
|
||||
|
||||
return SetPadding(obj, new Padding(obj.Padding.Left, top, obj.Padding.Right, obj.Padding.Bottom));
|
||||
return Padding(obj, new Padding(obj.Padding.Left, top, obj.Padding.Right, obj.Padding.Bottom));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -58,7 +58,7 @@ namespace Spectre.Console
|
||||
throw new ArgumentNullException(nameof(obj));
|
||||
}
|
||||
|
||||
return SetPadding(obj, new Padding(obj.Padding.Left, obj.Padding.Top, right, obj.Padding.Bottom));
|
||||
return Padding(obj, new Padding(obj.Padding.Left, obj.Padding.Top, right, obj.Padding.Bottom));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -76,7 +76,7 @@ namespace Spectre.Console
|
||||
throw new ArgumentNullException(nameof(obj));
|
||||
}
|
||||
|
||||
return SetPadding(obj, new Padding(obj.Padding.Left, obj.Padding.Top, obj.Padding.Right, bottom));
|
||||
return Padding(obj, new Padding(obj.Padding.Left, obj.Padding.Top, obj.Padding.Right, bottom));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -89,10 +89,10 @@ namespace Spectre.Console
|
||||
/// <param name="right">The right padding to apply.</param>
|
||||
/// <param name="bottom">The bottom padding to apply.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
public static T SetPadding<T>(this T obj, int left, int top, int right, int bottom)
|
||||
public static T Padding<T>(this T obj, int left, int top, int right, int bottom)
|
||||
where T : class, IPaddable
|
||||
{
|
||||
return SetPadding(obj, new Padding(left, top, right, bottom));
|
||||
return Padding(obj, new Padding(left, top, right, bottom));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -102,7 +102,7 @@ namespace Spectre.Console
|
||||
/// <param name="obj">The paddable object instance.</param>
|
||||
/// <param name="padding">The padding to apply.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
public static T SetPadding<T>(this T obj, Padding padding)
|
||||
public static T Padding<T>(this T obj, Padding padding)
|
||||
where T : class, IPaddable
|
||||
{
|
||||
if (obj is null)
|
||||
|
@ -15,7 +15,7 @@ namespace Spectre.Console
|
||||
/// <param name="style">The header style.</param>
|
||||
/// <param name="alignment">The header alignment.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
public static Panel SetHeader(this Panel panel, string text, Style? style = null, Justify? alignment = null)
|
||||
public static Panel Header(this Panel panel, string text, Style? style = null, Justify? alignment = null)
|
||||
{
|
||||
if (panel is null)
|
||||
{
|
||||
@ -27,7 +27,69 @@ namespace Spectre.Console
|
||||
throw new ArgumentNullException(nameof(text));
|
||||
}
|
||||
|
||||
return SetHeader(panel, new PanelHeader(text, style, alignment));
|
||||
style ??= panel.Header?.Style;
|
||||
alignment ??= panel.Header?.Alignment;
|
||||
|
||||
return Header(panel, new PanelHeader(text, style, alignment));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the panel header style.
|
||||
/// </summary>
|
||||
/// <param name="panel">The panel.</param>
|
||||
/// <param name="style">The header style.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
public static Panel HeaderStyle(this Panel panel, Style style)
|
||||
{
|
||||
if (panel is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(panel));
|
||||
}
|
||||
|
||||
if (style is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(style));
|
||||
}
|
||||
|
||||
if (panel.Header != null)
|
||||
{
|
||||
// Update existing style
|
||||
panel.Header.Style = style;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Create header
|
||||
Header(panel, string.Empty, style, null);
|
||||
}
|
||||
|
||||
return panel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the panel header alignment.
|
||||
/// </summary>
|
||||
/// <param name="panel">The panel.</param>
|
||||
/// <param name="alignment">The header alignment.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
public static Panel HeaderAlignment(this Panel panel, Justify alignment)
|
||||
{
|
||||
if (panel is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(panel));
|
||||
}
|
||||
|
||||
if (panel.Header != null)
|
||||
{
|
||||
// Update existing style
|
||||
panel.Header.Alignment = alignment;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Create header
|
||||
Header(panel, string.Empty, null, alignment);
|
||||
}
|
||||
|
||||
return panel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -36,7 +98,7 @@ namespace Spectre.Console
|
||||
/// <param name="panel">The panel.</param>
|
||||
/// <param name="header">The header to use.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
public static Panel SetHeader(this Panel panel, PanelHeader header)
|
||||
public static Panel Header(this Panel panel, PanelHeader header)
|
||||
{
|
||||
if (panel is null)
|
||||
{
|
||||
|
@ -13,7 +13,7 @@ namespace Spectre.Console
|
||||
/// <param name="rule">The rule.</param>
|
||||
/// <param name="title">The title.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
public static Rule SetTitle(this Rule rule, string title)
|
||||
public static Rule RuleTitle(this Rule rule, string title)
|
||||
{
|
||||
if (rule is null)
|
||||
{
|
||||
@ -29,34 +29,13 @@ namespace Spectre.Console
|
||||
return rule;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the rule style.
|
||||
/// </summary>
|
||||
/// <param name="rule">The rule.</param>
|
||||
/// <param name="style">The rule style string.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
public static Rule SetStyle(this Rule rule, string style)
|
||||
{
|
||||
if (rule is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(rule));
|
||||
}
|
||||
|
||||
if (style is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(style));
|
||||
}
|
||||
|
||||
return SetStyle(rule, Style.Parse(style));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the rule style.
|
||||
/// </summary>
|
||||
/// <param name="rule">The rule.</param>
|
||||
/// <param name="style">The rule style.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
public static Rule SetStyle(this Rule rule, Style style)
|
||||
public static Rule RuleStyle(this Rule rule, Style style)
|
||||
{
|
||||
if (rule is null)
|
||||
{
|
||||
|
@ -1,5 +1,3 @@
|
||||
using System;
|
||||
|
||||
namespace Spectre.Console
|
||||
{
|
||||
/// <summary>
|
||||
@ -23,16 +21,5 @@ namespace Spectre.Console
|
||||
.Replace("[", "[[")
|
||||
.Replace("]", "]]");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Escapes text so that it won’t be interpreted as markup.
|
||||
/// </summary>
|
||||
/// <param name="text">The text to escape.</param>
|
||||
/// <returns>A string that is safe to use in markup.</returns>
|
||||
[Obsolete("Use EscapeMarkup extension instead.", false)]
|
||||
public static string SafeMarkup(this string text)
|
||||
{
|
||||
return EscapeMarkup(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ namespace Spectre.Console
|
||||
/// <param name="style">The style.</param>
|
||||
/// <param name="color">The foreground color.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
public static Style WithForeground(this Style style, Color color)
|
||||
public static Style Foreground(this Style style, Color color)
|
||||
{
|
||||
if (style is null)
|
||||
{
|
||||
@ -34,7 +34,7 @@ namespace Spectre.Console
|
||||
/// <param name="style">The style.</param>
|
||||
/// <param name="color">The background color.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
public static Style WithBackground(this Style style, Color color)
|
||||
public static Style Background(this Style style, Color color)
|
||||
{
|
||||
if (style is null)
|
||||
{
|
||||
@ -54,7 +54,7 @@ namespace Spectre.Console
|
||||
/// <param name="style">The style.</param>
|
||||
/// <param name="decoration">The text decoration.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
public static Style WithDecoration(this Style style, Decoration decoration)
|
||||
public static Style Decoration(this Style style, Decoration decoration)
|
||||
{
|
||||
if (style is null)
|
||||
{
|
||||
@ -74,7 +74,7 @@ namespace Spectre.Console
|
||||
/// <param name="style">The style.</param>
|
||||
/// <param name="link">The link.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
public static Style WithLink(this Style style, string link)
|
||||
public static Style Link(this Style style, string link)
|
||||
{
|
||||
if (style is null)
|
||||
{
|
||||
|
@ -5,7 +5,7 @@ namespace Spectre.Console.Rendering
|
||||
/// <summary>
|
||||
/// Contains extension methods for <see cref="TableBorder"/>.
|
||||
/// </summary>
|
||||
public static class BorderExtensions
|
||||
public static class TableBorderExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the safe border for a border.
|
@ -134,7 +134,7 @@ namespace Spectre.Console
|
||||
/// <param name="table">The table.</param>
|
||||
/// <param name="width">The width.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
public static Table SetWidth(this Table table, int width)
|
||||
public static Table Width(this Table table, int width)
|
||||
{
|
||||
if (table is null)
|
||||
{
|
||||
@ -184,7 +184,7 @@ namespace Spectre.Console
|
||||
/// <param name="text">The heading.</param>
|
||||
/// <param name="style">The style.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
public static Table SetHeading(this Table table, string text, Style? style = null)
|
||||
public static Table Heading(this Table table, string text, Style? style = null)
|
||||
{
|
||||
if (table is null)
|
||||
{
|
||||
@ -196,7 +196,7 @@ namespace Spectre.Console
|
||||
throw new ArgumentNullException(nameof(text));
|
||||
}
|
||||
|
||||
return SetHeading(table, new TableTitle(text, style));
|
||||
return Heading(table, new TableTitle(text, style));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -205,7 +205,7 @@ namespace Spectre.Console
|
||||
/// <param name="table">The table.</param>
|
||||
/// <param name="heading">The heading.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
public static Table SetHeading(this Table table, TableTitle heading)
|
||||
public static Table Heading(this Table table, TableTitle heading)
|
||||
{
|
||||
if (table is null)
|
||||
{
|
||||
@ -223,7 +223,7 @@ namespace Spectre.Console
|
||||
/// <param name="text">The footnote.</param>
|
||||
/// <param name="style">The style.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
public static Table SetFootnote(this Table table, string text, Style? style = null)
|
||||
public static Table Footnote(this Table table, string text, Style? style = null)
|
||||
{
|
||||
if (table is null)
|
||||
{
|
||||
@ -235,7 +235,7 @@ namespace Spectre.Console
|
||||
throw new ArgumentNullException(nameof(text));
|
||||
}
|
||||
|
||||
return SetFootnote(table, new TableTitle(text, style));
|
||||
return Footnote(table, new TableTitle(text, style));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -244,7 +244,7 @@ namespace Spectre.Console
|
||||
/// <param name="table">The table.</param>
|
||||
/// <param name="footnote">The footnote.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
public static Table SetFootnote(this Table table, TableTitle footnote)
|
||||
public static Table Footnote(this Table table, TableTitle footnote)
|
||||
{
|
||||
if (table is null)
|
||||
{
|
||||
|
Reference in New Issue
Block a user