using System;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using StellaOps.Cryptography;
using StellaOps.Cryptography.PluginLoader;
namespace StellaOps.Cryptography.DependencyInjection;
public static partial class CryptoPluginServiceCollectionExtensions
{
///
/// Registers crypto providers with plugin loading and compliance profile configuration.
///
/// Service collection.
/// Application configuration.
/// Optional plugin configuration.
/// Optional compliance configuration.
/// The service collection.
public static IServiceCollection AddStellaOpsCryptoWithPluginsAndCompliance(
this IServiceCollection services,
IConfiguration configuration,
Action? configurePlugins = null,
Action? configureCompliance = null)
{
ArgumentNullException.ThrowIfNull(services);
ArgumentNullException.ThrowIfNull(configuration);
services.AddStellaOpsCryptoWithPlugins(configuration, configurePlugins);
services.Configure(options =>
{
configuration.GetSection(CryptoComplianceOptions.SectionKey).Bind(options);
configureCompliance?.Invoke(options);
});
return services;
}
}