コード例 #1
0
ファイル: NotifyBase.cs プロジェクト: DrJohnMelville/Melville
        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
        }
コード例 #2
0
 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;
 }
コード例 #3
0
        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);
        }
コード例 #4
0
ファイル: NotifyBase.cs プロジェクト: DrJohnMelville/Melville
 /// <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));
 }