PageRenderTime 26ms CodeModel.GetById 14ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 1ms

/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
16////using GalaSoft.Utilities.Attributes;
17
18namespace CBR.Core.Helpers
19{
20    /// <summary>
21    /// Passes a string property name (PropertyName) and a generic value
22    /// (<see cref="OldValue" /> and <see cref="NewValue" />) to a recipient.
23    /// This message type can be used to propagate a PropertyChanged event to
24    /// a recipient using the messenging system.
25    /// </summary>
26    /// <typeparam name="T">The type of the OldValue and NewValue property.</typeparam>
27    ////[ClassInfo(typeof(Messenger))]
28    public class PropertyChangedMessage<T> : PropertyChangedMessageBase
29    {
30        /// <summary>
31        /// Initializes a new instance of the <see cref="PropertyChangedMessage{T}" /> class.
32        /// </summary>
33        /// <param name="sender">The message's sender.</param>
34        /// <param name="oldValue">The property's value before the change occurred.</param>
35        /// <param name="newValue">The property's value after the change occurred.</param>
36        /// <param name="propertyName">The name of the property that changed.</param>
37        public PropertyChangedMessage(object sender, T oldValue, T newValue, string propertyName)
38            : base(sender, propertyName)
39        {
40            OldValue = oldValue;
41            NewValue = newValue;
42        }
43
44        /// <summary>
45        /// Initializes a new instance of the <see cref="PropertyChangedMessage{T}" /> class.
46        /// </summary>
47        /// <param name="oldValue">The property's value before the change occurred.</param>
48        /// <param name="newValue">The property's value after the change occurred.</param>
49        /// <param name="propertyName">The name of the property that changed.</param>
50        public PropertyChangedMessage(T oldValue, T newValue, string propertyName)
51            : base(propertyName)
52        {
53            OldValue = oldValue;
54            NewValue = newValue;
55        }
56
57        /// <summary>
58        /// Initializes a new instance of the <see cref="PropertyChangedMessage{T}" /> class.
59        /// </summary>
60        /// <param name="sender">The message's sender.</param>
61        /// <param name="target">The message's intended target. This parameter can be used
62        /// to give an indication as to whom the message was intended for. Of course
63        /// this is only an indication, amd may be null.</param>
64        /// <param name="oldValue">The property's value before the change occurred.</param>
65        /// <param name="newValue">The property's value after the change occurred.</param>
66        /// <param name="propertyName">The name of the property that changed.</param>
67        public PropertyChangedMessage(object sender, object target, T oldValue, T newValue, string propertyName)
68            : base(sender, target, propertyName)
69        {
70            OldValue = oldValue;
71            NewValue = newValue;
72        }
73
74        /// <summary>
75        /// Gets the value that the property has after the change.
76        /// </summary>
77        public T NewValue
78        {
79            get;
80            private set;
81        }
82
83        /// <summary>
84        /// Gets the value that the property had before the change.
85        /// </summary>
86        public T OldValue
87        {
88            get;
89            private set;
90        }
91    }
92}