Terminal UI V2, advanced binding
This commit is contained in:
@@ -2,20 +2,52 @@
|
||||
using FileTime.App.Core.Configuration;
|
||||
using FileTime.ConsoleUI;
|
||||
using FileTime.ConsoleUI.App;
|
||||
using FileTime.ConsoleUI.Styles;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using TerminalUI.ConsoleDrivers;
|
||||
|
||||
(AppDataRoot, EnvironmentName) = Init.InitDevelopment();
|
||||
var configuration = new ConfigurationBuilder()
|
||||
.AddInMemoryCollection(MainConfiguration.Configuration)
|
||||
IConsoleDriver driver = new WindowsDriver();
|
||||
driver.Init();
|
||||
ITheme theme;
|
||||
if (driver.GetCursorPosition() is not {PosX: 0, PosY: 0})
|
||||
{
|
||||
driver = new DotnetDriver();
|
||||
driver.Init();
|
||||
theme = DefaultThemes.ConsoleColorTheme;
|
||||
}
|
||||
else
|
||||
{
|
||||
theme = DefaultThemes.Color256Theme;
|
||||
}
|
||||
|
||||
driver.SetCursorVisible(false);
|
||||
|
||||
try
|
||||
{
|
||||
(AppDataRoot, EnvironmentName) = Init.InitDevelopment();
|
||||
var configuration = new ConfigurationBuilder()
|
||||
.AddInMemoryCollection(MainConfiguration.Configuration)
|
||||
#if DEBUG
|
||||
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
|
||||
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
|
||||
#endif
|
||||
.Build();
|
||||
DI.Initialize(configuration);
|
||||
.Build();
|
||||
|
||||
var app = DI.ServiceProvider.GetRequiredService<IApplication>();
|
||||
app.Run();
|
||||
var serviceCollection = new ServiceCollection();
|
||||
serviceCollection.TryAddSingleton<IConsoleDriver>(driver);
|
||||
serviceCollection.TryAddSingleton<ITheme>(theme);
|
||||
|
||||
DI.Initialize(configuration, serviceCollection);
|
||||
|
||||
var app = DI.ServiceProvider.GetRequiredService<IApplication>();
|
||||
app.Run();
|
||||
}
|
||||
finally
|
||||
{
|
||||
driver.SetCursorVisible(true);
|
||||
driver.Dispose();
|
||||
}
|
||||
|
||||
public partial class Program
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user