31 lines
841 B
C#
31 lines
841 B
C#
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
|
using System;
|
|
|
|
namespace StellaOps.Cryptography.Plugin.CryptoPro;
|
|
|
|
public static class CryptoProCryptoServiceCollectionExtensions
|
|
{
|
|
public static IServiceCollection AddCryptoProGostProvider(
|
|
this IServiceCollection services,
|
|
Action<CryptoProGostProviderOptions>? configure = null)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(services);
|
|
|
|
if (configure is not null)
|
|
{
|
|
services.Configure(configure);
|
|
}
|
|
|
|
if (!OperatingSystem.IsWindows())
|
|
{
|
|
return services;
|
|
}
|
|
|
|
services.TryAddEnumerable(
|
|
ServiceDescriptor.Singleton<StellaOps.Cryptography.ICryptoProvider, CryptoProGostCryptoProvider>());
|
|
return services;
|
|
}
|
|
}
|