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.

LuPermissionAttribute.cs 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System;
  2. using Luticate2.Auth.Attributes.EntityAccessors;
  3. using Luticate2.Auth.Dbo.Permissions;
  4. namespace Luticate2.Auth.Attributes
  5. {
  6. [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
  7. public class LuPermissionAttribute : Attribute
  8. {
  9. public string PermissionName { get; protected set; }
  10. public string SrcEntityType { get; protected set; }
  11. public Type SrcEntityAccessor { get; protected set; }
  12. public string DstEntityType { get; protected set; }
  13. public Type DstEntityAccessor { get; protected set; }
  14. public object Id { get; protected set; }
  15. public LuPermissionAttribute(string permissionName, string srcEntityType, Type srcEntityAccessor,
  16. string dstEntityType, Type dstEntityAccessor, object id = null)
  17. {
  18. PermissionName = permissionName;
  19. SrcEntityType = srcEntityType;
  20. SrcEntityAccessor = srcEntityAccessor;
  21. DstEntityType = dstEntityType;
  22. DstEntityAccessor = dstEntityAccessor;
  23. Id = id;
  24. }
  25. public LuPermissionAttribute(string permissionName, string dstEntityType, Type dstEntityAccessor, object id = null)
  26. : this(permissionName, LuEntityTypes.LuUsers, typeof(LuAttrLoggedUserAccessor), dstEntityType, dstEntityAccessor, id)
  27. {
  28. }
  29. public LuPermissionAttribute(string permissionName, string dstEntityType, object id = null)
  30. : this(permissionName, dstEntityType, typeof(LuAttrArgumentAccessor), id)
  31. {
  32. }
  33. }
  34. }