OneFrameInputs.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. using System;
  2. using System.Collections.Generic;
  3. namespace ET
  4. {
  5. public partial class OneFrameInputs
  6. {
  7. protected bool Equals(OneFrameInputs other)
  8. {
  9. return Equals(this.Inputs, other.Inputs);
  10. }
  11. public void CopyTo(OneFrameInputs to)
  12. {
  13. to.Frame = this.Frame;
  14. to.Inputs.Clear();
  15. foreach (var kv in this.Inputs)
  16. {
  17. to.Inputs.Add(kv.Key, kv.Value);
  18. }
  19. }
  20. public override bool Equals(object obj)
  21. {
  22. if (ReferenceEquals(null, obj))
  23. {
  24. return false;
  25. }
  26. if (ReferenceEquals(this, obj))
  27. {
  28. return true;
  29. }
  30. if (obj.GetType() != this.GetType())
  31. {
  32. return false;
  33. }
  34. return Equals((OneFrameInputs) obj);
  35. }
  36. public override int GetHashCode()
  37. {
  38. return HashCode.Combine(this.Inputs);
  39. }
  40. public static bool operator==(OneFrameInputs a, OneFrameInputs b)
  41. {
  42. if (a is null || b is null)
  43. {
  44. if (a is null && b is null)
  45. {
  46. return true;
  47. }
  48. return false;
  49. }
  50. if (a.Frame != b.Frame)
  51. {
  52. return false;
  53. }
  54. if (a.Inputs.Count != b.Inputs.Count)
  55. {
  56. return false;
  57. }
  58. foreach (var kv in a.Inputs)
  59. {
  60. if (!b.Inputs.TryGetValue(kv.Key, out LSInput inputInfo))
  61. {
  62. return false;
  63. }
  64. if (kv.Value != inputInfo)
  65. {
  66. return false;
  67. }
  68. }
  69. return true;
  70. }
  71. public static bool operator !=(OneFrameInputs a, OneFrameInputs b)
  72. {
  73. return !(a == b);
  74. }
  75. }
  76. }