예제 #1
0
 /// <summary>
 /// Configure the dependency injection system with services
 /// </summary>
 /// <param name="services"></param>
 private void ConfigureServices(IServiceCollection services)
 {
     services.AddLogging(ConfigureLogging);
     services.Configure <SessionOptions>(Configuration.GetSection("MorphicService"));
     services.Configure <UpdateOptions>(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 = Path.Combine(ApplicationDataFolderPath, "Data")
     });
     services.AddSingleton(new KeychainOptions {
         Path = Path.Combine(ApplicationDataFolderPath, "keychain")
     });
     services.AddSingleton <UpdateOptions>(serviceProvider => serviceProvider.GetRequiredService <IOptions <UpdateOptions> >().Value);
     services.AddSingleton <IDataProtection, DataProtector>();
     services.AddSingleton <IUserSettings, WindowsUserSettings>();
     services.AddSingleton <IRegistry, WindowsRegistry>();
     services.AddSingleton <IIniFileFactory, IniFileFactory>();
     services.AddSingleton <ISystemSettingFactory, SystemSettingFactory>();
     services.AddSingleton <ISystemParametersInfo, SystemParametersInfo>();
     services.AddSingleton <IFileManager, FileManager>();
     services.AddSingleton <SettingsManager>();
     services.AddSingleton <Keychain>();
     services.AddSingleton <Storage>();
     services.AddSingleton <Session>();
     services.AddSingleton <BuildInfo>(BuildInfo.FromJsonFile("build-info.json"));
     services.AddTransient <TravelWindow>();
     services.AddTransient <CreateAccountPanel>();
     services.AddTransient <CapturePanel>();
     services.AddTransient <TravelCompletedPanel>();
     services.AddTransient <QuickStripWindow>();
     services.AddTransient <LoginWindow>();
     services.AddTransient <AboutWindow>();
     services.AddMorphicSettingsHandlers(ConfigureSettingsHandlers);
 }