Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.81 KB | None | 0 0
  1. public abstract class ValueObject
  2. {
  3.     public override bool Equals(object obj)
  4.     {
  5.         if (ReferenceEquals(obj, null))
  6.         {
  7.             return false;
  8.         }
  9.  
  10.         return StructuralComparer.AreEqual(this, obj);
  11.     }
  12.  
  13.     public override int GetHashCode()
  14.     {
  15.         return StructuralHashCodeCalculator.CalculateHashCode(this);
  16.     }
  17.  
  18.     public static bool operator ==(ValueObject a, ValueObject b)
  19.     {
  20.         if (ReferenceEquals(a, null) && ReferenceEquals(b, null))
  21.         {
  22.             return true;
  23.         }
  24.  
  25.         if (ReferenceEquals(a, null) || ReferenceEquals(b, null))
  26.         {
  27.             return false;
  28.         }
  29.  
  30.         return a.Equals(b);
  31.     }
  32.  
  33.     public static bool operator !=(ValueObject a, ValueObject b)
  34.     {
  35.         return !(a == b);
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement