FeederNetworkInterfaceInfo.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Linq;
  5. using System.Runtime.CompilerServices;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Windows;
  9. namespace Team.FFFeederService.Models
  10. {
  11. /// <summary>
  12. /// Feeder地址信息
  13. /// </summary>
  14. public class FeederNetworkInterfaceInfo : INotifyPropertyChanged
  15. {
  16. /// <summary>
  17. /// 名称
  18. /// </summary>
  19. public string FeederType { get; set; }
  20. /// <summary>
  21. /// 固件版本
  22. /// </summary>
  23. public string Version { get; set; }
  24. /// <summary>
  25. /// IP
  26. /// </summary>
  27. public string IP { get; set; }
  28. /// <summary>
  29. /// 端口
  30. /// </summary>
  31. public int Port { get; set; }
  32. /// <summary>
  33. /// 掩码
  34. /// </summary>
  35. public string Subnet { get; set; }
  36. /// <summary>
  37. /// 网关
  38. /// </summary>
  39. public string Gateway { get; set; }
  40. /// <summary>
  41. /// MAC
  42. /// </summary>
  43. public string MAC { get; set; }
  44. private bool _IsAccessible;
  45. /// <summary>
  46. /// 可到达的
  47. /// </summary>
  48. public bool IsAccessible
  49. {
  50. get { return _IsAccessible; }
  51. set { SetProperty(ref _IsAccessible,value); }
  52. }
  53. /// <summary>
  54. /// 网卡信息
  55. /// </summary>
  56. public NetworkInterfaceInfo Network { get; set; }
  57. //
  58. // 摘要:
  59. // Occurs when a property value changes.
  60. public event PropertyChangedEventHandler PropertyChanged;
  61. //
  62. // 摘要:
  63. // Checks if a property already matches a desired value. Sets the property and notifies
  64. // listeners only when necessary.
  65. //
  66. // 参数:
  67. // storage:
  68. // Reference to a property with both getter and setter.
  69. //
  70. // value:
  71. // Desired value for the property.
  72. //
  73. // propertyName:
  74. // Name of the property used to notify listeners. This value is optional and can
  75. // be provided automatically when invoked from compilers that support CallerMemberName.
  76. //
  77. //
  78. // 类型参数:
  79. // T:
  80. // Type of the property.
  81. //
  82. // 返回结果:
  83. // True if the value was changed, false if the existing value matched the desired
  84. // value.
  85. protected virtual bool SetProperty<T>(ref T storage, T value, [CallerMemberName] string propertyName = null)
  86. {
  87. if (EqualityComparer<T>.Default.Equals(storage, value))
  88. {
  89. return false;
  90. }
  91. storage = value;
  92. RaisePropertyChanged(propertyName);
  93. return true;
  94. }
  95. //
  96. // 摘要:
  97. // Checks if a property already matches a desired value. Sets the property and notifies
  98. // listeners only when necessary.
  99. //
  100. // 参数:
  101. // storage:
  102. // Reference to a property with both getter and setter.
  103. //
  104. // value:
  105. // Desired value for the property.
  106. //
  107. // propertyName:
  108. // Name of the property used to notify listeners. This value is optional and can
  109. // be provided automatically when invoked from compilers that support CallerMemberName.
  110. //
  111. //
  112. // onChanged:
  113. // Action that is called after the property value has been changed.
  114. //
  115. // 类型参数:
  116. // T:
  117. // Type of the property.
  118. //
  119. // 返回结果:
  120. // True if the value was changed, false if the existing value matched the desired
  121. // value.
  122. protected virtual bool SetProperty<T>(ref T storage, T value, Action onChanged, [CallerMemberName] string propertyName = null)
  123. {
  124. if (EqualityComparer<T>.Default.Equals(storage, value))
  125. {
  126. return false;
  127. }
  128. storage = value;
  129. onChanged?.Invoke();
  130. RaisePropertyChanged(propertyName);
  131. return true;
  132. }
  133. //
  134. // 摘要:
  135. // Raises this object's PropertyChanged event.
  136. //
  137. // 参数:
  138. // propertyName:
  139. // Name of the property used to notify listeners. This value is optional and can
  140. // be provided automatically when invoked from compilers that support System.Runtime.CompilerServices.CallerMemberNameAttribute.
  141. protected void RaisePropertyChanged([CallerMemberName] string propertyName = null)
  142. {
  143. OnPropertyChanged(new PropertyChangedEventArgs(propertyName));
  144. }
  145. //
  146. // 摘要:
  147. // Raises this object's PropertyChanged event.
  148. //
  149. // 参数:
  150. // args:
  151. // The PropertyChangedEventArgs
  152. protected virtual void OnPropertyChanged(PropertyChangedEventArgs args)
  153. {
  154. this.PropertyChanged?.Invoke(this, args);
  155. }
  156. }
  157. }