NoKey.cs 980 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System;
  2. namespace Quadarax.Foundation.Core.Data.Entity
  3. {
  4. public class NoKey : IEquatable<NoKey>
  5. {
  6. public Guid Hash { get; } = Guid.NewGuid();
  7. public bool Equals(NoKey? other)
  8. {
  9. if (other == null!)
  10. return false;
  11. return Hash == other.Hash;
  12. }
  13. public override bool Equals(object? obj)
  14. {
  15. if (ReferenceEquals(null, obj)) return false;
  16. if (ReferenceEquals(this, obj)) return true;
  17. if (obj.GetType() != this.GetType()) return false;
  18. return Equals((NoKey)obj);
  19. }
  20. public override int GetHashCode()
  21. {
  22. return Hash.GetHashCode();
  23. }
  24. public static bool operator ==(NoKey? left, NoKey right)
  25. {
  26. return Equals(left, right);
  27. }
  28. public static bool operator !=(NoKey left, NoKey right)
  29. {
  30. return !Equals(left, right);
  31. }
  32. }
  33. }