#region ========================================================================= USING =====================================================================================
using Nemera.Plugins.Contracts.Core.Metadata;
using Nemera.Plugins.ID3.Core;
using Nemera.Plugins.ID3.Core.Tags;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using System;
#endregion
namespace Nemera.Plugins.ID3.Common.DependencyInjection;
///
/// Utility class for registering the services of the ID3 metadata provider into the Dependency Injection container.
///
internal static class Id3Services
{
///
/// Registers the services of the ID3 metadata providers 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 AddId3MetadataProviders(this IServiceCollection services, Guid pluginId)
{
ArgumentNullException.ThrowIfNull(services);
// The reader is scoped, so that the tags of a single file are read only once across the artist, album and track providers of the same enrichment scope.
services.TryAddScoped();
// Register the metadata providers as keyed by pluginId transient services, so they can be resolved specifically among other IMetadataProvider implementations.
// A single plugin exposes one provider per entity type, because the metadata contract is typed to a single lookup and metadata pair.
services.AddKeyedTransient(pluginId);
services.AddKeyedTransient(pluginId);
services.AddKeyedTransient(pluginId);
return services;
}
}