DataPermissionNameComparer.cs 830 B

1234567891011121314151617181920212223242526272829303132
  1. using System.Collections.Generic;
  2. namespace IwbZero.Authorization.Base.Permissions
  3. {
  4. internal class DataPermissionNameComparer : IEqualityComparer<string>
  5. {
  6. public static DataPermissionNameComparer Instance => new DataPermissionNameComparer();
  7. public bool Equals(string x, string y)
  8. {
  9. if (string.IsNullOrEmpty(x) && string.IsNullOrEmpty(y))
  10. {
  11. return true;
  12. }
  13. if (string.IsNullOrEmpty(x) || string.IsNullOrEmpty(y))
  14. {
  15. return false;
  16. }
  17. if (x.EndsWith($"@{(int)OperType.All}"))
  18. {
  19. return true;
  20. }
  21. return x == y;
  22. }
  23. public int GetHashCode(string obj)
  24. {
  25. return obj.GetHashCode();
  26. }
  27. }
  28. }