Guest User

Untitled

a guest
Jan 4th, 2018
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. using System;
  2. using System.Drawing;
  3.  
  4. namespace yournamespace
  5. {
  6. public class Gizmo : IEquatable<Gizmo>
  7. {
  8. public string Name { get; set; }
  9. public string Pattern { get; set; }
  10. public Color ForegroundColor { get; set; }
  11. public Color BackgroundColor { get; set; }
  12.  
  13. public override bool Equals(object obj)
  14. {
  15. if (obj == null)
  16. {
  17. return false;
  18. }
  19.  
  20. return Equals(obj as Gizmo);
  21. }
  22.  
  23. public bool Equals(Gizmo other)
  24. {
  25. if ((object)other == null)
  26. {
  27. return false;
  28. }
  29.  
  30. return
  31. Name == other.Name &&
  32. Pattern == other.Pattern &&
  33. ForegroundColor == other.ForegroundColor &&
  34. BackgroundColor == other.BackgroundColor;
  35. }
  36.  
  37. public override int GetHashCode()
  38. {
  39. return new HashCode()
  40. .Hash(Name)
  41. .Hash(Pattern)
  42. .Hash(ForegroundColor)
  43. .Hash(BackgroundColor)
  44. .Value;
  45. }
  46.  
  47. public static bool operator ==(Gizmo left, Gizmo right)
  48. {
  49. if (object.ReferenceEquals(left, right))
  50. {
  51. return true;
  52. }
  53.  
  54. if (((object)left == null) || ((object)right == null))
  55. {
  56. return false;
  57. }
  58.  
  59. return left.Equals(right);
  60. }
  61.  
  62. public static bool operator !=(Gizmo left, Gizmo right)
  63. {
  64. return !(left == right);
  65. }
  66. }
  67. }
Add Comment
Please, Sign In to add comment