mirror of https://github.com/abpframework/abp
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1.2 KiB
34 lines
1.2 KiB
using System;
|
|
using Volo.Abp.DependencyInjection;
|
|
using Volo.Abp.Options;
|
|
|
|
namespace Microsoft.Extensions.DependencyInjection
|
|
{
|
|
public static class ServiceCollectionPreConfigureExtensions
|
|
{
|
|
public static IServiceCollection PreConfigure<TOptions>(this IServiceCollection services, Action<TOptions> optionsAction)
|
|
{
|
|
services.GetPreConfigureActions<TOptions>().Add(optionsAction);
|
|
return services;
|
|
}
|
|
|
|
public static TOptions ExecutePreConfiguredActions<TOptions>(this IServiceCollection services, TOptions options)
|
|
{
|
|
services.GetPreConfigureActions<TOptions>().Configure(options);
|
|
return options;
|
|
}
|
|
|
|
public static PreConfigureActionList<TOptions> GetPreConfigureActions<TOptions>(this IServiceCollection services)
|
|
{
|
|
var actionList = services.GetSingletonInstanceOrNull<IObjectAccessor<PreConfigureActionList<TOptions>>>()?.Value;
|
|
if (actionList == null)
|
|
{
|
|
actionList = new PreConfigureActionList<TOptions>();
|
|
services.AddObjectAccessor(actionList);
|
|
}
|
|
|
|
return actionList;
|
|
}
|
|
}
|
|
}
|