73 lines
2.2 KiB
C#
73 lines
2.2 KiB
C#
using System.Configuration;
|
|
using System.Data;
|
|
using System.IO;
|
|
using System.Reflection;
|
|
using System.Runtime.InteropServices;
|
|
using System.Text;
|
|
using System.Windows;
|
|
using System.Windows.Threading;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
using Microsoft.Extensions.Logging;
|
|
using Seyounth.Hyosung.Core.Printer;
|
|
using Seyounth.Hyosung.Runtime;
|
|
using Seyounth.Hyosung.Services;
|
|
using Seyounth.Hyosung.ViewModels;
|
|
using Seyounth.Hyosung.Views;
|
|
using Seyounth.Hyosung.Views.Pages;
|
|
|
|
namespace Seyounth.Hyosung;
|
|
|
|
/// <summary>
|
|
/// Interaction logic for App.xaml
|
|
/// </summary>
|
|
public partial class App : Application
|
|
{
|
|
private static IHost _host;
|
|
|
|
public App()
|
|
{
|
|
var builder = Host
|
|
.CreateApplicationBuilder();
|
|
builder.Configuration.AddJsonFile("PrintTemp.json", true, true);
|
|
builder.Configuration.AddJsonFile("appsettings.json", true, true);
|
|
builder.Services.Configure<PrintTemp>(builder.Configuration.GetSection("Print"));
|
|
builder.Services.AddHostedService<ApplicationHostService>();
|
|
builder.Services.AddSingleton<MainWindow>();
|
|
builder.Services.AddSingleton<MainWindowViewModel>();
|
|
builder.Services.AddSingleton<VarietyPage>();
|
|
builder.Services.AddSingleton<VarietyViewModel>();
|
|
builder.Services.AddSingleton<HomeViewPage>();
|
|
builder.Services.AddSingleton<HomeViewModel>();
|
|
builder.Services.AddHyosung(builder.Configuration);
|
|
|
|
_host = builder.Build();
|
|
}
|
|
|
|
|
|
private void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
|
|
{
|
|
var logger = _host.Services.GetRequiredService<ILogger<App>>();
|
|
logger.LogError(e.Exception, "Unhandled exception");
|
|
}
|
|
|
|
private async void OnExit(object sender, ExitEventArgs e)
|
|
{
|
|
await _host.StopAsync();
|
|
_host.Dispose();
|
|
}
|
|
|
|
private void OnStartup(object sender, StartupEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
_host.Services.UseHyosung();
|
|
_host.StartAsync();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.WriteLine(ex.Message);
|
|
}
|
|
}
|
|
} |