PageRenderTime 35ms CodeModel.GetById 12ms RepoModel.GetById 1ms app.codeStats 0ms

/CBR/CBR.Core/Helpers/MVVM/Events/Messages/PropertyChangedMessage.cs

#
C# | 92 lines | 34 code | 6 blank | 52 comment | 0 complexity | 69ffdb04ab26bf7e37284ad817a51d01 MD5 | raw file
  1. // ****************************************************************************
  2. // <copyright file="PropertyChangedMessage.cs" company="GalaSoft Laurent Bugnion">
  3. // Copyright © GalaSoft Laurent Bugnion 2009-2011
  4. // </copyright>
  5. // ****************************************************************************
  6. // <author>Laurent Bugnion</author>
  7. // <email>laurent@galasoft.ch</email>
  8. // <date>13.4.2009</date>
  9. // <project>GalaSoft.MvvmLight.Messaging</project>
  10. // <web>http://www.galasoft.ch</web>
  11. // <license>
  12. // See license.txt in this project or http://www.galasoft.ch/license_MIT.txt
  13. // </license>
  14. // ****************************************************************************
  15. ////using GalaSoft.Utilities.Attributes;
  16. namespace CBR.Core.Helpers
  17. {
  18. /// <summary>
  19. /// Passes a string property name (PropertyName) and a generic value
  20. /// (<see cref="OldValue" /> and <see cref="NewValue" />) to a recipient.
  21. /// This message type can be used to propagate a PropertyChanged event to
  22. /// a recipient using the messenging system.
  23. /// </summary>
  24. /// <typeparam name="T">The type of the OldValue and NewValue property.</typeparam>
  25. ////[ClassInfo(typeof(Messenger))]
  26. public class PropertyChangedMessage<T> : PropertyChangedMessageBase
  27. {
  28. /// <summary>
  29. /// Initializes a new instance of the <see cref="PropertyChangedMessage{T}" /> class.
  30. /// </summary>
  31. /// <param name="sender">The message's sender.</param>
  32. /// <param name="oldValue">The property's value before the change occurred.</param>
  33. /// <param name="newValue">The property's value after the change occurred.</param>
  34. /// <param name="propertyName">The name of the property that changed.</param>
  35. public PropertyChangedMessage(object sender, T oldValue, T newValue, string propertyName)
  36. : base(sender, propertyName)
  37. {
  38. OldValue = oldValue;
  39. NewValue = newValue;
  40. }
  41. /// <summary>
  42. /// Initializes a new instance of the <see cref="PropertyChangedMessage{T}" /> class.
  43. /// </summary>
  44. /// <param name="oldValue">The property's value before the change occurred.</param>
  45. /// <param name="newValue">The property's value after the change occurred.</param>
  46. /// <param name="propertyName">The name of the property that changed.</param>
  47. public PropertyChangedMessage(T oldValue, T newValue, string propertyName)
  48. : base(propertyName)
  49. {
  50. OldValue = oldValue;
  51. NewValue = newValue;
  52. }
  53. /// <summary>
  54. /// Initializes a new instance of the <see cref="PropertyChangedMessage{T}" /> class.
  55. /// </summary>
  56. /// <param name="sender">The message's sender.</param>
  57. /// <param name="target">The message's intended target. This parameter can be used
  58. /// to give an indication as to whom the message was intended for. Of course
  59. /// this is only an indication, amd may be null.</param>
  60. /// <param name="oldValue">The property's value before the change occurred.</param>
  61. /// <param name="newValue">The property's value after the change occurred.</param>
  62. /// <param name="propertyName">The name of the property that changed.</param>
  63. public PropertyChangedMessage(object sender, object target, T oldValue, T newValue, string propertyName)
  64. : base(sender, target, propertyName)
  65. {
  66. OldValue = oldValue;
  67. NewValue = newValue;
  68. }
  69. /// <summary>
  70. /// Gets the value that the property has after the change.
  71. /// </summary>
  72. public T NewValue
  73. {
  74. get;
  75. private set;
  76. }
  77. /// <summary>
  78. /// Gets the value that the property had before the change.
  79. /// </summary>
  80. public T OldValue
  81. {
  82. get;
  83. private set;
  84. }
  85. }
  86. }