zoukankan      html  css  js  c++  java
  • NotificationObject.cs

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.ComponentModel;
    using System.Linq.Expressions;
    using System.Reflection;

    namespace SC
    {
        /// <summary>
        /// notification object base class
        /// </summary>
        public abstract class NotificationObject : INotifyPropertyChanged
        {
            /// <summary>
            /// property changed handler
            /// </summary>
            public event PropertyChangedEventHandler PropertyChanged;

            /// <summary>
            /// raise property changed handler
            /// </summary>
            /// <param name="propertyName">property name to raise</param>
            protected virtual void RaisePropertyChanged(string propertyName)
            {
                PropertyChangedEventHandler handler = this.PropertyChanged;
                if (handler != null)
                {
                    handler(this, new PropertyChangedEventArgs(propertyName));
                }
            }

            /// <summary>
            /// raise many property changed handler
            /// </summary>
            /// <param name="propertyNames">properties to raise</param>
            protected void RaisePropertyChanged(params string[] propertyNames)
            {
                if (propertyNames == null)
                {
                    throw new ArgumentNullException("propertyNames");
                }

                foreach (var propertyName in propertyNames)
                {
                    this.RaisePropertyChanged(() => propertyName);
                }
            }

            /// <summary>
            /// Raises the <see cref="PropertyChanged"/> event using expression.
            /// </summary>
            /// <typeparam name="TP">Expression</typeparam>
            /// <param name="property">Property</param>
            protected void RaisePropertyChanged<T>(Expression<Func<T>> property)
            {
                var propertyInfo = (property.Body as MemberExpression).Member as PropertyInfo;

                if (null == propertyInfo)
                {
                    throw new ArgumentException("The lambda expression 'property' should point to a valid Property");
                }

                RaisePropertyChanged(propertyInfo.Name);
            }
        }
    }

  • 相关阅读:
    把Chrome浏览器变成文本编辑器
    pigcms 标签读不出
    全排列函数
    线性基(二
    线性基(一
    fabs() abs()
    字面量声明的函数,后边最好加一个分号,否则的话,在控制台执行有问题的
    mongo集群
    linux的查找命令
    mysql 解决Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’错误
  • 原文地址:https://www.cnblogs.com/zisezhixin/p/3971967.html
Copyright © 2011-2022 走看看