mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-07-06 04:28:15 +08:00
Register the console lazily in CLI type registrar
This should fix a strange bug we're seeing in Cake on macOS.
This commit is contained in:

committed by
Patrik Svensson

parent
fd217ffc83
commit
28e9c14de4
@ -37,6 +37,19 @@ namespace Spectre.Console.Testing
|
||||
}
|
||||
}
|
||||
|
||||
public void RegisterLazy(Type service, Func<object> factory)
|
||||
{
|
||||
if (factory is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(factory));
|
||||
}
|
||||
|
||||
if (!Instances.ContainsKey(service))
|
||||
{
|
||||
Instances.Add(service, new List<object> { factory() });
|
||||
}
|
||||
}
|
||||
|
||||
public ITypeResolver Build()
|
||||
{
|
||||
return _resolver;
|
||||
|
Reference in New Issue
Block a user