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
{
///
/// Feeder地址信息
///
public class FeederNetworkInterfaceInfo : INotifyPropertyChanged
{
///
/// 名称
///
public string FeederType { get; set; }
///
/// 固件版本
///
public string Version { get; set; }
///
/// IP
///
public string IP { get; set; }
///
/// 端口
///
public int Port { get; set; }
///
/// 掩码
///
public string Subnet { get; set; }
///
/// 网关
///
public string Gateway { get; set; }
///
/// MAC
///
public string MAC { get; set; }
private bool _IsAccessible;
///
/// 可到达的
///
public bool IsAccessible
{
get { return _IsAccessible; }
set { SetProperty(ref _IsAccessible,value); }
}
///
/// 网卡信息
///
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(ref T storage, T value, [CallerMemberName] string propertyName = null)
{
if (EqualityComparer.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(ref T storage, T value, Action onChanged, [CallerMemberName] string propertyName = null)
{
if (EqualityComparer.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);
}
}
}