DeviceProcessorConfiguration.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. namespace Edge.Core.Configuration
  5. {
  6. public class DeviceProcessorConfiguration
  7. {
  8. public List<Processor> Processor { get; set; }
  9. public override bool Equals(object obj)
  10. {
  11. if (obj == null) return false;
  12. if (!(obj is DeviceProcessorConfiguration target)) return false;
  13. else
  14. {
  15. if (this.Processor.Count != target.Processor.Count) return false;
  16. for (int i = 0; i < this.Processor.Count; i++)
  17. if (!this.Processor[i].Equals(target.Processor[i])) return false;
  18. return true;
  19. }
  20. }
  21. }
  22. public class Processor
  23. {
  24. /// <summary>
  25. /// Unique for each processor configuration in settings.xml
  26. /// </summary>
  27. public string Name { get; set; }
  28. public string DeviceProcessorType
  29. {
  30. get; set;
  31. }
  32. public bool Complex
  33. {
  34. get; set;
  35. }
  36. public string ConstructorArg
  37. {
  38. get; set;
  39. }
  40. //public bool IsComplex
  41. //{
  42. // get; set;
  43. //}
  44. public string Description
  45. {
  46. get; set;
  47. }
  48. /// <summary>
  49. /// the high numbers have the earlier initial time.
  50. /// </summary>
  51. //public int InitPriority { get; set; }
  52. public List<ProcessorParameter> Parameter { get; set; }
  53. public override bool Equals(object obj)
  54. {
  55. if (obj == null) return false;
  56. if (!(obj is Processor target)) return false;
  57. else
  58. {
  59. if (this.Name != target.Name || this.DeviceProcessorType != target.DeviceProcessorType
  60. //|| this.SerialNumber != target.SerialNumber
  61. )
  62. return false;
  63. if (this.Parameter == null && target.Parameter == null) return true;
  64. if (this.Parameter.Count != target.Parameter.Count) return false;
  65. for (int i = 0; i < this.Parameter.Count; i++)
  66. if (!this.Parameter[i].Equals(target.Parameter[i])) return false;
  67. return true;
  68. }
  69. }
  70. }
  71. public class ProcessorParameter
  72. {
  73. public string Name
  74. {
  75. get; set;
  76. }
  77. public string Value
  78. {
  79. get; set;
  80. }
  81. public bool Complex
  82. {
  83. get; set;
  84. }
  85. public string ConstructorArg
  86. {
  87. get; set;
  88. }
  89. public string Description
  90. {
  91. get; set;
  92. }
  93. public override bool Equals(object obj)
  94. {
  95. if (obj == null) return false;
  96. if (!(obj is ProcessorParameter target)) return false;
  97. else
  98. {
  99. if (this.Name != target.Name || this.Value != target.Value
  100. || this.ConstructorArg != target.ConstructorArg)
  101. return false;
  102. return true;
  103. }
  104. }
  105. }
  106. }