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:
Patrik Svensson
2020-10-22 00:32:07 +02:00
committed by Patrik Svensson
parent 037a215a78
commit 041bd016a2
53 changed files with 1021 additions and 245 deletions

View File

@ -7,21 +7,33 @@ namespace EmojiExample
public static void Main(string[] args)
{
// No title
Render(new Rule().SetStyle("yellow"));
WrapInPanel(
new Rule()
.RuleStyle(Style.Parse("yellow"))
.LeftAligned());
// Left aligned title
Render(new Rule("[white]Left aligned[/]").LeftAligned().SetStyle("red"));
WrapInPanel(
new Rule("[white]Left aligned[/]")
.RuleStyle(Style.Parse("red"))
.LeftAligned());
// Centered title
Render(new Rule("[silver]Centered[/]").Centered().SetStyle("green"));
WrapInPanel(
new Rule("[silver]Centered[/]")
.RuleStyle(Style.Parse("green"))
.Centered());
// Right aligned title
Render(new Rule("[grey]Right aligned[/]").RightAligned().SetStyle("blue"));
WrapInPanel(
new Rule("[grey]Right aligned[/]")
.RuleStyle(Style.Parse("blue"))
.RightAligned());
}
private static void Render(Rule rule)
private static void WrapInPanel(Rule rule)
{
AnsiConsole.Render(new Panel(rule).Expand().SetBorderStyle(Style.Parse("grey")));
AnsiConsole.Render(new Panel(rule).Expand().BorderStyle(Style.Parse("grey")));
AnsiConsole.WriteLine();
}
}