示例#1
0
        public static void Notify <TMember>(
            this INotifyPropertyChanged sender,
            PropertyChangedEventHandler handler,
            Expression <Func <TMember> > expression)
        {
            if (sender == null)
            {
                throw new ArgumentNullException("sender");
            }

            if (expression == null)
            {
                throw new ArgumentNullException("expression");
            }

            var body = expression.Body as MemberExpression;

            if (body == null)
            {
                throw new ArgumentException("The expression must target a property or field.", "expression");
            }

            string propertyName = PropertyChangedExt.GetPropertyName(body, sender.GetType());

            PropertyChangedExt.NotifyCore(sender, handler, propertyName);
        }
示例#2
0
        private static bool PropertyChanged(MemberExpression expression, Type ownerType, PropertyChangedEventArgs e, bool targetPropertyOnly)
        {
            var propertyName = PropertyChangedExt.GetPropertyName(expression, ownerType);

            return(PropertyChangedExt.PropertyChanged(propertyName, e, targetPropertyOnly));
        }