DD.WellWorkover.Cloud/AsbCloudWebApi/PermissionAttribute.cs

64 lines
2.3 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
namespace AsbCloudWebApi
{
public static class CommonMasks
{
public const int Get = 1;
public const int Edit = 1 << 1;
public const int Delete = 1 << 15;
public const int Any = -1;
public const int Bit_00 = 1;
public const int Bit_01 = 1 << 1;
public const int Bit_02 = 1 << 2;
public const int Bit_03 = 1 << 3;
public const int Bit_04 = 1 << 4;
public const int Bit_05 = 1 << 5;
public const int Bit_06 = 1 << 6;
public const int Bit_07 = 1 << 7;
public const int Bit_08 = 1 << 8;
public const int Bit_09 = 1 << 9;
public const int Bit_10 = 1 << 10;
public const int Bit_11 = 1 << 11;
public const int Bit_12 = 1 << 12;
public const int Bit_13 = 1 << 13;
public const int Bit_14 = 1 << 14;
public const int Bit_15 = 1 << 15;
public const int Bit_16 = 1 << 16;
public const int Bit_17 = 1 << 17;
public const int Bit_18 = 1 << 18;
public const int Bit_19 = 1 << 19;
public const int Bit_20 = 1 << 20;
public const int Bit_21 = 1 << 21;
public const int Bit_22 = 1 << 22;
public const int Bit_23 = 1 << 23;
public const int Bit_24 = 1 << 24;
public const int Bit_25 = 1 << 25;
public const int Bit_26 = 1 << 26;
public const int Bit_27 = 1 << 27;
public const int Bit_28 = 1 << 28;
public const int Bit_29 = 1 << 29;
public const int Bit_30 = 1 << 30;
public const int Bit_31 = 1 << 31;
}
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
public class PermissionAttribute : Attribute
{
public static SortedSet<string> Registered { get; } = new SortedSet<string>();
public string Name { get; set; }
/// <summary>
/// Проверка наличия у пользователя разрешения.
/// </summary>
/// <param name="name">Имя разрешения (default = controllerName)</param>
public PermissionAttribute(string name = default)
{
Name = name;
Registered.Add(name);
}
}
}