refactor(DIExtensions): Verbesserung der Registrierung von AsymCrypt-Diensten und Vereinfachung von Overloads
- `AddAsymCryptService` aktualisiert, um eine Standardimplementierung mit `AsymCryptParams` ohne generische Typen bereitzustellen. - Neue Überladung von `AddAsymCryptService` hinzugefügt, die eine `IConfigurationSection` für Standardparameter akzeptiert. - Lebensdauer der Service-Registrierungen für `IAsymCryptService` von `Scoped` auf `Singleton` geändert, um Konsistenz und geringeren Overhead zu gewährleisten.
This commit is contained in:
parent
6a92466490
commit
7da93c6719
@ -40,10 +40,8 @@ namespace DigitalData.Core.Security
|
||||
get
|
||||
{
|
||||
foreach (var decryptor in Decryptors)
|
||||
{
|
||||
yield return decryptor.Encryptor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -23,8 +23,8 @@ namespace DigitalData.Core.Security
|
||||
|
||||
private static IServiceCollection AddAsymCryptService<TAsymCryptParams>(this IServiceCollection services, bool setAsDefault = false) where TAsymCryptParams : AsymCryptParams
|
||||
=> setAsDefault
|
||||
? services.AddScoped<IAsymCryptService, AsymCryptService<TAsymCryptParams>>()
|
||||
: services.AddScoped<IAsymCryptService<TAsymCryptParams>, AsymCryptService<TAsymCryptParams>>();
|
||||
? services.AddSingleton<IAsymCryptService, AsymCryptService<TAsymCryptParams>>()
|
||||
: services.AddSingleton<IAsymCryptService<TAsymCryptParams>, AsymCryptService<TAsymCryptParams>>();
|
||||
|
||||
/// <summary>
|
||||
/// Registers a custom asym crypt service with specified parameters from the given configuration section.
|
||||
@ -38,6 +38,16 @@ namespace DigitalData.Core.Security
|
||||
where TAsymCryptParams : AsymCryptParams
|
||||
=> services.Configure<TAsymCryptParams>(section).AddAsymCryptService<TAsymCryptParams>(setAsDefault: setAsDefault);
|
||||
|
||||
/// <summary>
|
||||
/// Registers a custom asym crypt service with default parameters from the given configuration section.
|
||||
/// </summary>
|
||||
/// <param name="services"></param>
|
||||
/// <param name="section"></param>
|
||||
/// <param name="setAsDefault"></param>
|
||||
/// <returns></returns>
|
||||
public static IServiceCollection AddAsymCryptService(this IServiceCollection services, IConfigurationSection section, bool setAsDefault = false)
|
||||
=> services.Configure<AsymCryptParams>(section).AddAsymCryptService<AsymCryptParams>(setAsDefault: setAsDefault);
|
||||
|
||||
/// <summary>
|
||||
/// Registers an asym crypt service with the specified parameters from the given instance. Optionally, sets it as the default factory.
|
||||
/// </summary>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user