mirror of
https://github.com/spectreconsole/spectre.console.git
synced 2025-10-25 15:19:23 +00:00
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.
60 lines
1.7 KiB
C#
60 lines
1.7 KiB
C#
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;
|
|
}
|
|
}
|
|
}
|