class Win32_DiskDrive : INotifyPropertyChanged { private readonly string _classname = "Win32_DiskDrive"; public string ClassName { get { return _classname; } } private string _caption; public string Caption { get { return _caption; } set { if ((value != _caption) || (value != null)) { _caption = value; UpdateDictionary(); OnPropertyChange(); } } } private string _serialNo; public string SerialNumber { get { return _serialNo; } set { if ((value != _serialNo) || (value != null)) { _serialNo = value; UpdateDictionary(); OnPropertyChange(); } } } private IDictionary<string,string> _diskDriveProperties = new ObservableDictionary<String, String>(); public IDictionary<string, string> PropertiesDictionary { get { return _diskDriveProperties; } set { _diskDriveProperties = value; } } private void UpdateDictionary([CallerMemberName] string propertyname = null) { _diskDriveProperties[propertyname] = this.GetType().GetProperty(propertyname).GetValue(this).ToString(); } public event PropertyChangedEventHandler PropertyChanged; private void OnPropertyChange([CallerMemberName] string propertyname = null) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyname)); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)