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);
            }
        }
    }

  • 相关阅读:
    c语言实现BMP图像转换为灰度图
    360初赛溢出题
    vim的完全卸载
    小谈截断上传漏洞
    cmd提权的一些常用命令
    渗透测试方向概览
    字符编码以及python的编码解释
    BrainFuck 以及运用(idf)
    记一次加解密通关Nazo
    360 心情杂记
  • 原文地址:https://www.cnblogs.com/zisezhixin/p/3971967.html
Copyright © 2011-2022 走看看