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

  • 相关阅读:
    分布式系统的负载均衡以及ngnix负载均衡的五种策略
    排序
    servlet+forward和direct区别
    https、socket、http协议
    类加载机制+变量初始化
    MySQL中的索引
    线程状态
    JVM的分区+查看GC对象是否存活+3种GC算法+7种垃圾收集器+如何减少GC次数
    ORACLE索引监控的简单使用
    如何验证所做的AIX系统备份是否可用
  • 原文地址:https://www.cnblogs.com/zisezhixin/p/3971967.html
Copyright © 2011-2022 走看看