/// <inheritdoc /> public bool UpdateCurrentValue(DeviceStatusFlags currentConfiguration) { this.VerifyWriteAccess <T>(); // throws if read-only var newValue = ConvertDeviceStatusFlagsToValue(currentConfiguration); var valueChanged = INotifyPropertyChangedHelpers.SafeDidValueChangeCompare(newValue, CurrentValue); CurrentValue = newValue; return(valueChanged); }
/// <inheritdoc /> public override void SetValueOnDevice(IPeripheral device, T newValue) { this.VerifyWriteAccess <T>(); // throws if read-only if (INotifyPropertyChangedHelpers.SafeDidValueChangeCompare(newValue, CurrentValue)) { var locutus = (Device)device; var newConfiguration = GetUpdatedConfigurationFlags(locutus, newValue); HasPendingValue = true; PendingValue = newValue; locutus.SetConfiguration(newConfiguration, (c, p, r) => SuccessHandler(locutus, c), (m, e) => ErrorHandler(locutus, m, e)); } }
/// <summary> /// Updates a property and raises the PropertyChanged event if the current value is modified. /// </summary> /// <typeparam name="T">Type of the property.</typeparam> /// <param name="name">The name of the property.</param> /// <param name="customAction">Custom action to execute prior to raising the property changed event.</param> /// <param name="newValue">The new value for the property.</param> /// <param name="currentValue">The current value of the property.</param> /// <returns>If the value is changed, return <c>true</c>, otherwise <c>false</c>.</returns> /// <remarks>The custom action executes before the PropertyChange event is raised.</remarks> protected bool UpdateProperty <T>(string name, System.Action <string, T> customAction, T newValue, T currentValue) { return(INotifyPropertyChangedHelpers.UpdateProperty(this, PropertyChanged, name, customAction, newValue, currentValue)); }
/// <summary> /// Assigns and updates the property. /// </summary> /// <typeparam name="T">Data type of the property.</typeparam> /// <param name="name">Name of the property.</param> /// <param name="newValue">New value of the property.</param> /// <param name="currentValue">Current value of the property.</param> /// <param name="customAction">Custom action to execute when property value changes, executed prior to raising the PropertyChanged event.</param> /// <returns><c>true</c>, if the property value changed (and was assigned), <c>false</c> otherwise.</returns> protected bool AssignAndUpdateProperty <T>(string name, T newValue, ref T currentValue, System.Action <string, T> customAction) { return(INotifyPropertyChangedHelpers.AssignAndUpdateProperty(this, PropertyChanged, name, newValue, ref currentValue, customAction)); }
/// <summary> /// Raises the property changed. /// </summary> /// <typeparam name="T">Data type of the property.</typeparam> /// <param name="name">Name of the property.</param> /// <param name="customAction">Custom action to execute when property value changes, executed after the PropertyChanged event is raised.</param> /// <param name="newValue">New value of the property.</param> protected void RaisePropertyChanged <T>(string name, System.Action <string, T> customAction, T newValue) { INotifyPropertyChangedHelpers.RaisePropertyChanged(this, PropertyChanged, name, customAction, newValue); }
/// <summary> /// Raises the property changed event. /// </summary> /// <param name="propertyName">Property name.</param> protected void RaisePropertyChanged(string propertyName) { INotifyPropertyChangedHelpers.RaisePropertyChanged(this, PropertyChanged, propertyName); }