mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-04-24 04:02:50 +08:00
Obsolete the AnsiConsoleFactory class (#585)
`AnsiConsoleFactory` should be an internal static class. Creating an `IAnsiConsole` can be achieved through `Spectre.Console.AnsiConsole.Create(AnsiConsoleSettings)` Since `AnsiConsoleFactory` is public, it can't be changed from a non static class to a static class so obsoleting it is the second best thing to do. Eventually, when `AnsiConsoleFactory` becomes internal and static, `AnsiConsole.Create` can be simplified to this (and the private static field `_factory` can be removed) ``` public static IAnsiConsole Create(AnsiConsoleSettings settings) { return AnsiConsoleFactory.Create(settings); } ```
This commit is contained in:
parent
1d8154f9b0
commit
7998ece6b6
@ -56,8 +56,7 @@ public sealed class TestConsole : IAnsiConsole, IDisposable
|
|||||||
Input = new TestConsoleInput();
|
Input = new TestConsoleInput();
|
||||||
EmitAnsiSequences = false;
|
EmitAnsiSequences = false;
|
||||||
|
|
||||||
var factory = new AnsiConsoleFactory();
|
_console = AnsiConsole.Create(new AnsiConsoleSettings
|
||||||
_console = factory.Create(new AnsiConsoleSettings
|
|
||||||
{
|
{
|
||||||
Ansi = AnsiSupport.Yes,
|
Ansi = AnsiSupport.Yes,
|
||||||
ColorSystem = (ColorSystemSupport)ColorSystem.TrueColor,
|
ColorSystem = (ColorSystemSupport)ColorSystem.TrueColor,
|
||||||
|
@ -5,6 +5,10 @@ namespace Spectre.Console;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static partial class AnsiConsole
|
public static partial class AnsiConsole
|
||||||
{
|
{
|
||||||
|
#pragma warning disable CS0618 // 'AnsiConsoleFactory' is obsolete
|
||||||
|
private static readonly AnsiConsoleFactory _factory = new AnsiConsoleFactory();
|
||||||
|
#pragma warning restore CS0618
|
||||||
|
|
||||||
private static Recorder? _recorder;
|
private static Recorder? _recorder;
|
||||||
private static Lazy<IAnsiConsole> _console = new Lazy<IAnsiConsole>(
|
private static Lazy<IAnsiConsole> _console = new Lazy<IAnsiConsole>(
|
||||||
() =>
|
() =>
|
||||||
@ -61,8 +65,7 @@ public static partial class AnsiConsole
|
|||||||
/// <returns>An <see cref="IAnsiConsole"/> instance.</returns>
|
/// <returns>An <see cref="IAnsiConsole"/> instance.</returns>
|
||||||
public static IAnsiConsole Create(AnsiConsoleSettings settings)
|
public static IAnsiConsole Create(AnsiConsoleSettings settings)
|
||||||
{
|
{
|
||||||
var factory = new AnsiConsoleFactory();
|
return _factory.Create(settings);
|
||||||
return factory.Create(settings);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -3,6 +3,7 @@ namespace Spectre.Console;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Factory for creating an ANSI console.
|
/// Factory for creating an ANSI console.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Obsolete("Consider using AnsiConsole.Create instead.")]
|
||||||
public sealed class AnsiConsoleFactory
|
public sealed class AnsiConsoleFactory
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user