Add configuration options and license key support
Updated `DependencyInjection.cs` to include support for `ConfigurationOptions`, enabling queued configuration actions and the ability to configure `RecActionOptions` via delegates or `IConfiguration`. Added `LuckyPennySoftwareLicenseKey` property to `ConfigurationOptions` and integrated it into `AddAutoMapper` setup. Introduced `ApplyConfigurations` method to process queued actions. Updated `using` directives to include necessary namespaces.
This commit is contained in:
parent
46ef5e0d02
commit
988d48581b
@ -1,4 +1,6 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using ReC.Application.Common.Options;
|
||||
using System.Reflection;
|
||||
|
||||
namespace ReC.Application;
|
||||
@ -9,6 +11,7 @@ public static class DependencyInjection
|
||||
{
|
||||
var configOpt = new ConfigurationOptions();
|
||||
options.Invoke(configOpt);
|
||||
configOpt.ApplyConfigurations(services);
|
||||
|
||||
services.AddAutoMapper(cfg =>
|
||||
{
|
||||
@ -29,6 +32,29 @@ public static class DependencyInjection
|
||||
|
||||
public class ConfigurationOptions
|
||||
{
|
||||
private readonly Queue<Action<IServiceCollection>> _configActions = new();
|
||||
|
||||
internal void ApplyConfigurations(IServiceCollection services)
|
||||
{
|
||||
while (_configActions.Count > 0)
|
||||
{
|
||||
var action = _configActions.Dequeue();
|
||||
action(services);
|
||||
}
|
||||
}
|
||||
|
||||
public string? LuckyPennySoftwareLicenseKey { get; set; }
|
||||
|
||||
public ConfigurationOptions ConfigureRecActions(Action<RecActionOptions> configure)
|
||||
{
|
||||
_configActions.Enqueue(services => services.Configure(configure));
|
||||
return this;
|
||||
}
|
||||
|
||||
public ConfigurationOptions ConfigureRecActions(IConfiguration configuration)
|
||||
{
|
||||
_configActions.Enqueue(services => services.Configure<RecActionOptions>(configuration));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user