/
ChangeResult.cs
31 lines (30 loc) · 1.16 KB
/
ChangeResult.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
namespace Meadow
{
/// <summary>
/// Represents a change result from an event. Contains a `New` and an optional
/// `Old` value which will likely be null on the first result within an event
/// series.
/// </summary>
/// <typeparam name="UNIT">A unit type that carries the result data. Must be
/// a `struct`. Will most often be a unit such as `Temperature` or `Mass`,
/// but can also be a primitive type such as `int`, `float`, or even
/// `DateTime`.</typeparam>
public struct ChangeResult<UNIT> : IChangeResult<UNIT>
where UNIT : struct
{
/// <inheritdoc/>
public UNIT New { get; set; }
/// <inheritdoc/>
public UNIT? Old { get; set; }
/// <summary>
/// Creates a new ChangeResult.
/// </summary>
/// <param name="newValue">The value at the time of this event or notification.</param>
/// <param name="oldValue">The previous value before this event or notification, or null if there was no previous value.</param>
public ChangeResult(UNIT newValue, UNIT? oldValue)
{
New = newValue;
Old = oldValue;
}
}
}