SignalState.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System;
  2. namespace StatementMachineService.Model
  3. {
  4. public class SignalState : IComparable
  5. {
  6. public SignalState(string name)
  7. {
  8. this.Name = name;
  9. }
  10. public string Name { get; private set; }
  11. public override bool Equals(object obj)
  12. {
  13. if (ReferenceEquals(null, obj))
  14. {
  15. return false;
  16. }
  17. if (ReferenceEquals(this, obj))
  18. {
  19. return true;
  20. }
  21. if (obj.GetType() != this.GetType())
  22. {
  23. return false;
  24. }
  25. return this.Equals((SignalState)obj);
  26. }
  27. public override int GetHashCode()
  28. {
  29. return this.Name != null ? this.Name.GetHashCode() : 0;
  30. }
  31. public int CompareTo(object obj)
  32. {
  33. throw new InvalidOperationException("state machine should not use CompareTo");
  34. }
  35. protected bool Equals(SignalState other)
  36. {
  37. return string.Equals(this.Name, other.Name);
  38. }
  39. }
  40. }