예제 #1
0
 /// <summary>
 /// Configure the dependency injection system with services
 /// </summary>
 /// <param name="services"></param>
 private void ConfigureServices(IServiceCollection services)
 {
     services.AddLogging(this.ConfigureLogging);
     services.Configure <SessionOptions>(this.Configuration.GetSection("MorphicService"));
     services.Configure <UpdateOptions>(this.Configuration.GetSection("Update"));
     services.AddSingleton <IServiceCollection>(services);
     services.AddSingleton <IServiceProvider>(provider => provider);
     services.AddSingleton <SessionOptions>(serviceProvider => serviceProvider.GetRequiredService <IOptions <SessionOptions> >().Value);
     services.AddSingleton(new StorageOptions {
         RootPath = AppPaths.GetConfigDir("Data")
     });
     services.AddSingleton(new KeychainOptions {
         Path = AppPaths.GetConfigDir("keychain")
     });
     services.AddSingleton <UpdateOptions>(serviceProvider => serviceProvider.GetRequiredService <IOptions <UpdateOptions> >().Value);
     services.AddSingleton <IDataProtection, DataProtector>();
     services.AddSingleton <IUserSettings, WindowsUserSettings>();
     services.AddSingleton <Solutions>();
     services.AddSingleton <Keychain>();
     services.AddSingleton <Storage>();
     services.AddSingleton <MorphicSession>();
     services.AddTransient <TravelWindow>();
     services.AddTransient <CreateAccountPanel>();
     services.AddTransient <CapturePanel>();
     services.AddTransient <TravelCompletedPanel>();
     services.AddTransient <LoginWindow>();
     services.AddTransient <LoginPanel>();
     services.AddTransient <CreateAccountPanel>();
     services.AddTransient <AboutWindow>();
     services.AddTransient <CopyStartPanel>();
     services.AddTransient <ApplyPanel>();
     services.AddTransient <RestoreWindow>();
     services.AddSingleton <Backups>();
     services.AddTransient <BarData>();
     services.AddSingleton <BarPresets>(s => BarPresets.Default);
     services.AddSolutionsRegistryServices();
     services.AddSingleton <Solutions>(s => Solutions.FromFile(s, AppPaths.GetAppFile("solutions.json5")));
 }