| | | 1 | | // ----------------------------------------------------------------------- |
| | | 2 | | // <copyright file="PropertyChangedMessage.cs" company="Stéphane ANDRE"> |
| | | 3 | | // Copyright (c) Stéphane ANDRE. All rights reserved. |
| | | 4 | | // </copyright> |
| | | 5 | | // ----------------------------------------------------------------------- |
| | | 6 | | |
| | | 7 | | namespace MyNet.Messaging; |
| | | 8 | | |
| | | 9 | | /// <summary> |
| | | 10 | | /// Passes a string property name (PropertyName) and a generic value |
| | | 11 | | /// (<see cref="OldValue" /> and <see cref="NewValue" />) to a recipient. |
| | | 12 | | /// This message type can be used to propagate a PropertyChanged event to |
| | | 13 | | /// a recipient using the messenging system. |
| | | 14 | | /// </summary> |
| | | 15 | | /// <typeparam name="T">The type of the OldValue and NewValue property.</typeparam> |
| | | 16 | | public class PropertyChangedMessage<T> : PropertyChangedMessageBase |
| | | 17 | | { |
| | | 18 | | /// <summary> |
| | | 19 | | /// Initializes a new instance of the <see cref="PropertyChangedMessage{T}" /> class. |
| | | 20 | | /// </summary> |
| | | 21 | | /// <param name="sender">The message's sender.</param> |
| | | 22 | | /// <param name="oldValue">The property's value before the change occurred.</param> |
| | | 23 | | /// <param name="newValue">The property's value after the change occurred.</param> |
| | | 24 | | /// <param name="propertyName">The name of the property that changed.</param> |
| | | 25 | | public PropertyChangedMessage(object sender, T? oldValue, T? newValue, string propertyName) |
| | 0 | 26 | | : base(sender, propertyName) |
| | | 27 | | { |
| | 0 | 28 | | OldValue = oldValue; |
| | 0 | 29 | | NewValue = newValue; |
| | 0 | 30 | | } |
| | | 31 | | |
| | | 32 | | /// <summary> |
| | | 33 | | /// Initializes a new instance of the <see cref="PropertyChangedMessage{T}" /> class. |
| | | 34 | | /// </summary> |
| | | 35 | | /// <param name="oldValue">The property's value before the change occurred.</param> |
| | | 36 | | /// <param name="newValue">The property's value after the change occurred.</param> |
| | | 37 | | /// <param name="propertyName">The name of the property that changed.</param> |
| | | 38 | | public PropertyChangedMessage(T? oldValue, T? newValue, string propertyName) |
| | 0 | 39 | | : base(propertyName) |
| | | 40 | | { |
| | 0 | 41 | | OldValue = oldValue; |
| | 0 | 42 | | NewValue = newValue; |
| | 0 | 43 | | } |
| | | 44 | | |
| | | 45 | | /// <summary> |
| | | 46 | | /// Initializes a new instance of the <see cref="PropertyChangedMessage{T}" /> class. |
| | | 47 | | /// </summary> |
| | | 48 | | /// <param name="sender">The message's sender.</param> |
| | | 49 | | /// <param name="target">The message's intended target. This parameter can be used |
| | | 50 | | /// to give an indication as to whom the message was intended for. Of course |
| | | 51 | | /// this is only an indication, amd may be null.</param> |
| | | 52 | | /// <param name="oldValue">The property's value before the change occurred.</param> |
| | | 53 | | /// <param name="newValue">The property's value after the change occurred.</param> |
| | | 54 | | /// <param name="propertyName">The name of the property that changed.</param> |
| | | 55 | | public PropertyChangedMessage(object sender, object target, T? oldValue, T? newValue, string propertyName) |
| | 0 | 56 | | : base(sender, target, propertyName) |
| | | 57 | | { |
| | 0 | 58 | | OldValue = oldValue; |
| | 0 | 59 | | NewValue = newValue; |
| | 0 | 60 | | } |
| | | 61 | | |
| | | 62 | | /// <summary> |
| | | 63 | | /// Gets the value that the property has after the change. |
| | | 64 | | /// </summary> |
| | | 65 | | public T? NewValue |
| | | 66 | | { |
| | | 67 | | get; |
| | | 68 | | private set; |
| | | 69 | | } |
| | | 70 | | |
| | | 71 | | /// <summary> |
| | | 72 | | /// Gets the value that the property had before the change. |
| | | 73 | | /// </summary> |
| | | 74 | | public T? OldValue |
| | | 75 | | { |
| | | 76 | | get; |
| | | 77 | | private set; |
| | | 78 | | } |
| | | 79 | | } |
| | | 80 | | |