| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Linq;
- using System.Runtime.CompilerServices;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- namespace Team.FFFeederService.Models
- {
- /// <summary>
- /// Feeder地址信息
- /// </summary>
- public class FeederNetworkInterfaceInfo : INotifyPropertyChanged
- {
- /// <summary>
- /// 名称
- /// </summary>
- public string FeederType { get; set; }
- /// <summary>
- /// 固件版本
- /// </summary>
- public string Version { get; set; }
- /// <summary>
- /// IP
- /// </summary>
- public string IP { get; set; }
- /// <summary>
- /// 端口
- /// </summary>
- public int Port { get; set; }
- /// <summary>
- /// 掩码
- /// </summary>
- public string Subnet { get; set; }
- /// <summary>
- /// 网关
- /// </summary>
- public string Gateway { get; set; }
- /// <summary>
- /// MAC
- /// </summary>
- public string MAC { get; set; }
- private bool _IsAccessible;
- /// <summary>
- /// 可到达的
- /// </summary>
- public bool IsAccessible
- {
- get { return _IsAccessible; }
- set { SetProperty(ref _IsAccessible,value); }
- }
- /// <summary>
- /// 网卡信息
- /// </summary>
- public NetworkInterfaceInfo Network { get; set; }
- //
- // 摘要:
- // Occurs when a property value changes.
- public event PropertyChangedEventHandler PropertyChanged;
- //
- // 摘要:
- // Checks if a property already matches a desired value. Sets the property and notifies
- // listeners only when necessary.
- //
- // 参数:
- // storage:
- // Reference to a property with both getter and setter.
- //
- // value:
- // Desired value for the property.
- //
- // propertyName:
- // Name of the property used to notify listeners. This value is optional and can
- // be provided automatically when invoked from compilers that support CallerMemberName.
- //
- //
- // 类型参数:
- // T:
- // Type of the property.
- //
- // 返回结果:
- // True if the value was changed, false if the existing value matched the desired
- // value.
- protected virtual bool SetProperty<T>(ref T storage, T value, [CallerMemberName] string propertyName = null)
- {
- if (EqualityComparer<T>.Default.Equals(storage, value))
- {
- return false;
- }
- storage = value;
- RaisePropertyChanged(propertyName);
- return true;
- }
- //
- // 摘要:
- // Checks if a property already matches a desired value. Sets the property and notifies
- // listeners only when necessary.
- //
- // 参数:
- // storage:
- // Reference to a property with both getter and setter.
- //
- // value:
- // Desired value for the property.
- //
- // propertyName:
- // Name of the property used to notify listeners. This value is optional and can
- // be provided automatically when invoked from compilers that support CallerMemberName.
- //
- //
- // onChanged:
- // Action that is called after the property value has been changed.
- //
- // 类型参数:
- // T:
- // Type of the property.
- //
- // 返回结果:
- // True if the value was changed, false if the existing value matched the desired
- // value.
- protected virtual bool SetProperty<T>(ref T storage, T value, Action onChanged, [CallerMemberName] string propertyName = null)
- {
- if (EqualityComparer<T>.Default.Equals(storage, value))
- {
- return false;
- }
- storage = value;
- onChanged?.Invoke();
- RaisePropertyChanged(propertyName);
- return true;
- }
- //
- // 摘要:
- // Raises this object's PropertyChanged event.
- //
- // 参数:
- // propertyName:
- // Name of the property used to notify listeners. This value is optional and can
- // be provided automatically when invoked from compilers that support System.Runtime.CompilerServices.CallerMemberNameAttribute.
- protected void RaisePropertyChanged([CallerMemberName] string propertyName = null)
- {
- OnPropertyChanged(new PropertyChangedEventArgs(propertyName));
- }
- //
- // 摘要:
- // Raises this object's PropertyChanged event.
- //
- // 参数:
- // args:
- // The PropertyChangedEventArgs
- protected virtual void OnPropertyChanged(PropertyChangedEventArgs args)
- {
- this.PropertyChanged?.Invoke(this, args);
- }
- }
- }
|