Skip to content

Commit

Permalink
refactor: implement missing items for spectre.console
Browse files Browse the repository at this point in the history
  • Loading branch information
AdmiringWorm committed Jun 2, 2022
1 parent 47f4c57 commit a0d00f1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/CCVARN/DependencyInject/TypeRegistrar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,15 @@ public void RegisterInstance(Type service, object implementation)
}
this.container.RegisterInstance(service, implementation);
}

public void RegisterLazy(Type service, Func<object> factory)
{
if (service == typeof(BaseSettings))
{
this.container.RegisterDelegate(typeof(BaseSettings), (_) => factory());
}

this.container.RegisterDelegate(service, (_) => factory());
}
}
}
6 changes: 4 additions & 2 deletions src/CCVARN/IO/ConsoleWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,20 @@ public class ConsoleWriter : IConsoleWriter

public ConsoleWriter()
{
StandardOut = Console.Out;
StandardError = Console.Error;
Console.OutputEncoding = Encoding.UTF8;
this.console = AnsiConsole.Create(new AnsiConsoleSettings
{
Ansi = AnsiSupport.Detect,
ColorSystem = ColorSystemSupport.Detect,
Out = StandardOut = Console.Out,
Out = new AnsiConsoleOutput(StandardOut),
});
this.errorConsole = AnsiConsole.Create(new AnsiConsoleSettings
{
Ansi = AnsiSupport.Detect,
ColorSystem = ColorSystemSupport.Detect,
Out = StandardError = Console.Error,
Out = new AnsiConsoleOutput(StandardError),
});
}

Expand Down

0 comments on commit a0d00f1

Please sign in to comment.