using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
|
namespace LB_SmartVisionCommon
|
{
|
/// <summary>
|
/// 泛型权限控制特性
|
/// </summary>
|
[AttributeUsage(AttributeTargets.Property, Inherited = true, AllowMultiple = false)]
|
public class PermissionAttribute : Attribute
|
{
|
/// <summary>
|
/// 角色
|
/// </summary>
|
public Type RoleType { get; }
|
/// <summary>
|
/// 最小权限
|
/// </summary>
|
public object MinimumRole { get; }
|
/// <summary>
|
/// 泛型权限控制特性
|
/// </summary>
|
/// <param name="roleType">角色</param>
|
/// <param name="minimumRole">最小权限</param>
|
/// <exception cref="ArgumentException"></exception>
|
public PermissionAttribute(Type roleType, object minimumRole)
|
{
|
if (!roleType.IsEnum)
|
throw new ArgumentException("roleType 必须是枚举类型", nameof(roleType));
|
|
RoleType = roleType;
|
MinimumRole = minimumRole;
|
}
|
}
|
}
|