protected void VerifyValidDelegation(INotifyPropertyChanged foreignObject, string foreignProperty, string[] localProperties) { #if DEBUG VerifyPropertyExists.InDebugBuilds(this, localProperties); if (foreignObject == null) { throw new InvalidOperationException("Delegation to a null object"); } VerifyPropertyExists.InDebugBuilds(foreignObject, foreignProperty); #endif }
public static void WhenMemberChangesOnce(this INotifyPropertyChanged target, string member, Action action) { VerifyPropertyExists.InDebugBuilds((object)target, member); void method(object s, PropertyChangedEventArgs e) { if (e.PropertyName.Equals(member, StringComparison.Ordinal)) { action(); target.PropertyChanged -= method; } }; target.PropertyChanged += method; }
public static Action WhenMemberChanges(this INotifyPropertyChanged target, string member, Action action) { VerifyPropertyExists.InDebugBuilds((object)target, member); PropertyChangedEventHandler method = (s, e) => { if (e.PropertyName.Equals(member, StringComparison.Ordinal)) { action(); } }; target.PropertyChanged += method; return(() => target.PropertyChanged -= method); }
/// <summary> /// Notifies subscribers of the property change. /// </summary> /// <param name = "propertyName">SheetName of the property.</param> protected void OnPropertyChanged(string propertyName) { VerifyPropertyExists.InDebugBuilds(this, propertyName); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); }