Advertisement
Guest User

Untitled

a guest
Oct 25th, 2014
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. protected bool Equals(Record other)
  2. {
  3. return Value == other.Value;
  4. }
  5.  
  6. public override bool Equals(object obj)
  7. {
  8. if (ReferenceEquals(null, obj)) return false;
  9. if (ReferenceEquals(this, obj)) return true;
  10. return obj.GetType() == GetType() && Equals((Record) obj);
  11. }
  12.  
  13. public override int GetHashCode()
  14. {
  15. return Value.GetHashCode();
  16. }
  17.  
  18. public int CompareTo(Record other)
  19. {
  20. if (this > other) return 1;
  21. if (this < other) return -1;
  22. return 0;
  23. }
  24.  
  25. public static bool operator ==(Record r1, Record r2)
  26. {
  27. return Equals(r1,r2);
  28. }
  29.  
  30. public static bool operator !=(Record r1, Record r2)
  31. {
  32. return !(r1 == r2);
  33. }
  34.  
  35. public static bool operator >(Record r1, Record r2)
  36. {
  37. var i1 = r1.IsInteger();
  38. var i2 = r2.IsInteger();
  39. if ((i1 && i2) || (!i1 && !i2))
  40. {
  41. return r1.Value > r2.Value;
  42. }
  43. return r1.IsInteger();
  44. }
  45.  
  46. public static bool operator <(Record r1, Record r2)
  47. {
  48. return !(r1 >= r2);
  49. }
  50.  
  51. public static bool operator <=(Record r1, Record r2)
  52. {
  53. return (r1 < r2 || r1 == r2);
  54. }
  55.  
  56. public static bool operator >=(Record r1, Record r2)
  57. {
  58. return (r1 > r2 || r1 == r2);
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement