Обновление свойства C#, UWP
Нужно добавить событие о том, что элемент внутри класса был изменен. Variable - экземпляр класса DataItem, в котором содержится последнее прочитанное значение переменной в свойстве Variable.Value(obj). Обновлением данных занят отдельный сервис. Для того, чтобы вывести полученное значение на экран, используется свойство Value (так как я не могу реализовать INotifyPropertyChanged в библиотеке и привести его к нормальному типу). Соответственно нужно обновить значение свойства Value при изменении Variable.Value методом Update. Я хочу сделать так, чтобы при изменении свойства Variable.Value в классе ExperienceValueObservable метод Update вызывался автоматически. Извиняюсь, если не корректно описываю проблему
public class ExperienceValueObservable<T> : ViewModelBase
{
private string _Name;
private T _Value;
public string Name
{
get { return _Name; }
set { Set(ref _Name, value); }
}
public T Value
{
get { return _Value; }
set { Set(ref _Value, value); }
}
public string Dimension { get; set; }
public DataItem Variable { get; set; }
public void Update()
{
if (Variable.Value != null)
{
Value = (T)Convert.ChangeType(Variable.Value, typeof(T));
}
}
}
//
// Сводка:
// Create an instance of a memory block that can be read by using ReadMultipleVars
public class DataItem
{
//
// Сводка:
// Create an instance of DataItem
public DataItem();
//
// Сводка:
// Memory area to read
public DataType DataType { get; set; }
//
// Сводка:
// Type of data to be read (default is bytes)
public VarType VarType { get; set; }
//
// Сводка:
// Address of memory area to read (example: for DB1 this value is 1, for T45 this
// value is 45)
public int DB { get; set; }
//
// Сводка:
// Address of the first byte to read
public int StartByteAdr { get; set; }
//
// Сводка:
// Addess of bit to read from StartByteAdr
public byte BitAdr { get; set; }
//
// Сводка:
// Number of variables to read
public int Count { get; set; }
//
// Сводка:
// Contains the value of the memory area after the read has been executed
public object? Value { get; set; }
//
// Сводка:
// Create an instance of S7.Net.Types.DataItem from the supplied address.
//
// Параметры:
// address:
// The address to create the DataItem for.
//
// Возврат:
// A new S7.Net.Types.DataItem instance with properties parsed from address.
//
// Примечания:
// The S7.Net.Types.DataItem.Count property is not parsed from the address.
public static DataItem FromAddress(string address);
//
// Сводка:
// Create an instance of S7.Net.Types.DataItem from the supplied address and value.
//
// Параметры:
// address:
// The address to create the DataItem for.
//
// value:
// The value to be applied to the DataItem.
//
// Возврат:
// A new S7.Net.Types.DataItem instance with properties parsed from address and
// the supplied value set.
public static DataItem FromAddressAndValue<T>(string address, T value);
}