星火微课系统客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * author : singba singba@163.com
  3. * version : 20161221
  4. * source : AF.Core
  5. * license : free use or modify
  6. * description : 通用类型基类
  7. */
  8. using System;
  9. using System.Linq.Expressions;
  10. namespace ComeCapture.Models
  11. {
  12. /// <summary>
  13. /// singba:20120807
  14. /// 这个基类只作为INotifyPropertyChanged的实现,不再是Entity的基类
  15. /// </summary>
  16. public class EntityBase : System.ComponentModel.INotifyPropertyChanged
  17. {
  18. #region INotifyPropertyChanged Members
  19. public virtual event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
  20. protected virtual void RaisePropertyChanged(string name)
  21. {
  22. if (PropertyChanged != null)
  23. {
  24. PropertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(name));
  25. }
  26. }
  27. protected virtual void RaisePropertyChanged<TProperty>(Expression<Func<TProperty>> property)
  28. {
  29. LambdaExpression lambda = property;
  30. MemberExpression memberExpression;
  31. if (lambda.Body is UnaryExpression)
  32. {
  33. UnaryExpression unaryExpression = (UnaryExpression)lambda.Body;
  34. memberExpression = (MemberExpression)unaryExpression.Operand;
  35. }
  36. else
  37. {
  38. memberExpression = (MemberExpression)lambda.Body;
  39. }
  40. RaisePropertyChanged(memberExpression.Member.Name);
  41. }
  42. #endregion INotifyPropertyChanged Members
  43. }
  44. }