星火微课系统客户端
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

EntityBase.cs 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System;
  2. using System.Linq.Expressions;
  3. namespace XHWK.Model
  4. {
  5. /// <summary>
  6. /// singba:20120807
  7. /// 这个基类只作为INotifyPropertyChanged的实现,不再是Entity的基类
  8. /// </summary>
  9. public class EntityBase : System.ComponentModel.INotifyPropertyChanged
  10. {
  11. #region INotifyPropertyChanged Members
  12. public virtual event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
  13. protected virtual void RaisePropertyChanged(string name)
  14. {
  15. if (PropertyChanged != null)
  16. {
  17. PropertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(name));
  18. }
  19. }
  20. protected virtual void RaisePropertyChanged<TProperty>(Expression<Func<TProperty>> property)
  21. {
  22. LambdaExpression lambda = property;
  23. MemberExpression memberExpression;
  24. if (lambda.Body is UnaryExpression)
  25. {
  26. UnaryExpression unaryExpression = (UnaryExpression)lambda.Body;
  27. memberExpression = (MemberExpression)unaryExpression.Operand;
  28. }
  29. else
  30. {
  31. memberExpression = (MemberExpression)lambda.Body;
  32. }
  33. RaisePropertyChanged(memberExpression.Member.Name);
  34. }
  35. #endregion INotifyPropertyChanged Members
  36. }
  37. }