#region ========================================================================= USING ===================================================================================== using Nemera.Plugins.Calibre.Core; using Nemera.Plugins.Contracts.Core.Metadata; using Microsoft.Extensions.DependencyInjection; using System; #endregion namespace Nemera.Plugins.Calibre.Common.DependencyInjection; /// /// Utility class for registering the services of the Calibre metadata and artwork providers into the Dependency Injection container. /// internal static class CalibreServices { /// /// Registers the services of the Calibre metadata provider into the Dependency Injection container. /// /// The service collection to add the services to. /// The unique identifier of the plugin that provides the metadata. /// The updated . internal static IServiceCollection AddCalibreBookMetadataProvider(this IServiceCollection services, Guid pluginId) { ArgumentNullException.ThrowIfNull(services); // Register the metadata provider as a keyed by pluginId transient service, so it can be resolved specifically among other IMetadataProvider implementations. services.AddKeyedTransient(pluginId); return services; } /// /// Registers the services of the Calibre artwork provider into the Dependency Injection container. /// /// The service collection to register the services into. /// The unique identifier of the plugin that provides the artwork. /// The service collection, for chaining. internal static IServiceCollection AddCalibreArtworkProvider(this IServiceCollection services, Guid pluginId) { ArgumentNullException.ThrowIfNull(services); // Register the artwork provider as a keyed by pluginId transient service, so it can be resolved specifically among other IArtworkProvider implementations. services.AddKeyedTransient(pluginId); return services; } }