using KanSan.ViewModel;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
namespace KanSan
{
///
/// Interaction logic for App.xaml
///
public partial class App : Application
{
public App()
{
Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("MjM0MjUzQDMxMzgyZTMxMmUzMG8wTDNQcm5mN3UxaU9MbjdkVUlQbDgzWHcvUXZCOHdaVVY3c2I5S3BvN0U9");
}
public static IServiceProvider ServiceProvider { get; private set; }
protected override void OnStartup(StartupEventArgs e)
{
FrameworkElement.StyleProperty.OverrideMetadata(typeof(Window), new FrameworkPropertyMetadata
{
DefaultValue = FindResource(typeof(Window))
});
FrameworkElement.StyleProperty.OverrideMetadata(typeof(UserControl), new FrameworkPropertyMetadata
{
DefaultValue = FindResource(typeof(UserControl))
});
ServiceProvider = CreateServiceProvider();
Window window = ServiceProvider.GetRequiredService();
window.Show();
base.OnStartup(e);
}
private IServiceProvider CreateServiceProvider()
{
IServiceCollection services = new ServiceCollection();
services.AddSingleton();
services.AddScoped();
services.AddScoped(s => new MainWindow(s.GetRequiredService()));
return services.BuildServiceProvider();
}
}
}