| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 | using System;using System.Collections.Generic;using System.ComponentModel;using System.Linq;using System.Reflection;using System.Runtime.Serialization;using System.Text;using System.Threading.Tasks;using System.Windows.Input;using Aitex.Core.UI.MVVM;namespace MECF.Framework.Common.CommonData{    [Serializable]    [DataContract]    public class NotifiableItem : INotifyPropertyChanged    {        public event PropertyChangedEventHandler PropertyChanged;        public void InvokePropertyChanged(string propertyName)        {            if (PropertyChanged != null)            {                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));            }        }        public void InvokePropertyChanged()        {            PropertyInfo[] ps = this.GetType().GetProperties();            foreach (PropertyInfo p in ps)            {                InvokePropertyChanged(p.Name);                if (p.PropertyType == typeof(ICommand))                {                    DelegateCommand<string> cmd = p.GetValue(this, null) as DelegateCommand<string>;                    if (cmd != null)                        cmd.RaiseCanExecuteChanged();                }            }            FieldInfo[] fi = this.GetType().GetFields();            foreach (FieldInfo p in fi)            {                InvokePropertyChanged(p.Name);                if (p.FieldType == typeof(ICommand))                {                    DelegateCommand<string> cmd = p.GetValue(this) as DelegateCommand<string>;                    if (cmd != null)                        cmd.RaiseCanExecuteChanged();                }            }        }    }}
 |