PermissionGrantInfo.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. namespace IwbZero.Authorization.Base.Permissions
  2. {
  3. /// <summary>
  4. /// Represents a permission <see cref="Name"/> with <see cref="IsGranted"/> information.
  5. /// </summary>
  6. public class PermissionGrantInfo
  7. {
  8. /// <summary>
  9. /// Name of the permission.
  10. /// </summary>
  11. public string Name { get; private set; }
  12. /// <summary>
  13. /// OperType
  14. /// </summary>
  15. public int OperType { get; private set; }
  16. /// <summary>
  17. /// DataKey
  18. /// </summary>
  19. public string DataKey { get; private set; }
  20. /// <summary>
  21. /// Is this permission granted Prohibited?
  22. /// </summary>
  23. public bool IsGranted { get; private set; }
  24. /// <summary>
  25. /// Creates a new instance of <see cref="PermissionGrantInfo"/>.
  26. /// </summary>
  27. /// <param name="name"></param>
  28. /// <param name="isGranted"></param>
  29. public PermissionGrantInfo(string name, bool isGranted)
  30. {
  31. Name = name;
  32. IsGranted = isGranted;
  33. }
  34. /// <summary>
  35. /// Creates a new instance of <see cref="PermissionGrantInfo"/>.
  36. /// </summary>
  37. public PermissionGrantInfo(string name, int? operType, string dataKey, bool isGranted) : this(name, isGranted)
  38. {
  39. OperType = operType ?? 0;
  40. DataKey = dataKey;
  41. }
  42. /// <summary>
  43. /// Creates a new instance of <see cref="PermissionGrantInfo"/>.
  44. /// </summary>
  45. public PermissionGrantInfo(string name, OperType operType, string dataKey, bool isGranted) : this(name, (int)operType, dataKey, isGranted)
  46. {
  47. }
  48. }
  49. public enum OperType
  50. {
  51. All = 1,
  52. Create = 2,
  53. Update = 3,
  54. Delete = 4,
  55. Query = 5,
  56. }
  57. }