using System.Configuration; using System.Data; using System.IO; using System.Reflection; 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; /// /// Interaction logic for App.xaml /// 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(builder.Configuration.GetSection("Print")); builder.Services.AddHostedService(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddHyosung(builder.Configuration); _host = builder.Build(); } private void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { var logger = _host.Services.GetRequiredService>(); 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); } } }