zhaolei
2020-11-20 921de2254ff5712a44ed8575ee8efe34252f6603
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
using Bootstrap.Security.Authorization;
using System;
 
namespace Microsoft.Extensions.DependencyInjection
{
    /// <summary>
    /// 按钮授权服务扩展类
    /// </summary>
    public static class ButtonAuthorizationServicesCollectionExtensions
    {
        /// <summary>
        /// 添加按钮授权服务到服务容器中
        /// </summary>
        /// <param name="services">容器服务集合</param>
        /// <param name="func">通过用户名获取授权按钮集合回调方法(userName, url, auths) => bool</param>
        /// <returns>容器服务集合</returns>
        public static IServiceCollection AddButtonAuthorization(this IServiceCollection services, Func<string, string, string, bool>? func = null)
        {
            services.AddSingleton<IButtonAuthorization>(new DefaultButtonAuthorization(func));
            return services;
        }
    }
}