/// <summary> /// Registers a set of scoped services for using Zero Install functionality. /// </summary> /// <typeparam name="TTaskHandler">A callback object used when the the user needs to be asked questions or informed about download and IO tasks.</typeparam> /// <param name="services">The service collection to add the services to.</param> public static IServiceCollection AddZeroInstall <TTaskHandler>(this IServiceCollection services) where TTaskHandler : class, ITaskHandler => services.AddScoped <ITaskHandler, TTaskHandler>() .AddScoped(x => Config.Load()) .AddScoped(x => ImplementationStores.Default()) .AddScoped(x => OpenPgp.Verifying()) .AddScoped(x => FeedCaches.Default(x.GetService <IOpenPgp>())) .AddScoped(x => TrustDB.LoadSafe()) .AddScoped <ITrustManager, TrustManager>() .AddScoped <IFeedManager, FeedManager>() .AddScoped <ICatalogManager, CatalogManager>() .AddScoped(x => PackageManagers.Default()) .AddScoped <ISelectionsManager, SelectionsManager>() .AddScoped <ISolver, BacktrackingSolver>() .AddScoped <IFetcher, SequentialFetcher>() .AddScoped <IExecutor, Executor>() .AddScoped <ISelectionCandidateProvider, SelectionCandidateProvider>();
/// <summary> /// Registers a set of scoped services for using Zero Install functionality. /// </summary> /// <typeparam name="TTaskHandler">A callback object used when the the user needs to be asked questions or informed about download and IO tasks.</typeparam> /// <param name="services">The service collection to add the services to.</param> /// <param name="configuration">An optional configuration source for building <see cref="Config"/> instead of the default config files.</param> public static IServiceCollection AddZeroInstall <TTaskHandler>(this IServiceCollection services, IConfiguration?configuration = null) where TTaskHandler : class, ITaskHandler => services.AddScoped <ITaskHandler, TTaskHandler>() .AddScoped(_ => (configuration == null) ? Config.Load() : Config.From(configuration)) .AddScoped(_ => ImplementationStores.Default()) .AddScoped(_ => OpenPgp.Verifying()) .AddScoped(provider => FeedCaches.Default(provider.GetRequiredService <IOpenPgp>())) .AddScoped(_ => TrustDB.LoadSafe()) .AddScoped <ITrustManager, TrustManager>() .AddScoped <IFeedManager, FeedManager>() .AddScoped <ICatalogManager, CatalogManager>() .AddScoped(_ => PackageManagers.Default()) .AddScoped <ISelectionsManager, SelectionsManager>() .AddScoped <ISolver, BacktrackingSolver>() .AddScoped <IFetcher, Fetcher>() .AddScoped <IExecutor, Executor>() .AddScoped <ISelectionCandidateProvider, SelectionCandidateProvider>();