Struct Change<TObject, TKey>
- Namespace
- DynamicData
- Assembly
- DynamicData.dll
Container to describe a single change to a cache.
public readonly struct Change<TObject, TKey> : IEquatable<Change<TObject, TKey>> where TObject : notnull where TKey : notnull
Type Parameters
TObjectThe type of the object.
TKeyThe type of the key.
- Implements
-
IEquatable<Change<TObject, TKey>>
- Extension Methods
Constructors
Change(ChangeReason, TKey, TObject, in Optional<TObject>, int, int)
Initializes a new instance of the Change<TObject, TKey> struct.
public Change(ChangeReason reason, TKey key, TObject current, in Optional<TObject> previous, int currentIndex = -1, int previousIndex = -1)
Parameters
reasonChangeReasonThe reason.
keyTKeyThe key.
currentTObjectThe current.
previousOptional<TObject>The previous.
currentIndexintValue of the current.
previousIndexintValue of the previous.
Exceptions
- ArgumentException
For ChangeReason.Add, a previous value cannot be specified or For ChangeReason.Change, must supply previous value.
Change(ChangeReason, TKey, TObject, int)
Initializes a new instance of the Change<TObject, TKey> struct.
public Change(ChangeReason reason, TKey key, TObject current, int index = -1)
Parameters
reasonChangeReasonThe reason.
keyTKeyThe key.
currentTObjectThe current.
indexintThe index.
Change(TKey, TObject, int, int)
Initializes a new instance of the Change<TObject, TKey> struct. Constructor for ChangeReason.Move.
public Change(TKey key, TObject current, int currentIndex, int previousIndex)
Parameters
keyTKeyThe key.
currentTObjectThe current.
currentIndexintThe CurrentIndex.
previousIndexintCurrentIndex of the previous.
Exceptions
- ArgumentException
CurrentIndex must be greater than or equal to zero or PreviousIndex must be greater than or equal to zero.
Properties
Current
Gets the item which has changed.
public TObject Current { get; }
Property Value
- TObject
CurrentIndex
Gets the current index.
public int CurrentIndex { get; }
Property Value
Key
Gets the unique key of the item which has changed.
public TKey Key { get; }
Property Value
- TKey
Previous
Gets the previous change.
This is only when Reason==ChangeReason.Replace.
public Optional<TObject> Previous { get; }
Property Value
- Optional<TObject>
PreviousIndex
Gets the previous change.
This is only when Reason==ChangeReason.Update or ChangeReason.Move.
public int PreviousIndex { get; }
Property Value
Reason
Gets the reason for the change.
public ChangeReason Reason { get; }
Property Value
Methods
Equals(Change<TObject, TKey>)
public bool Equals(Change<TObject, TKey> other)
Parameters
otherChange<TObject, TKey>
Returns
Equals(object?)
public override bool Equals(object? obj)
Parameters
objobject
Returns
GetHashCode()
public override int GetHashCode()
Returns
ToString()
public override string ToString()
Returns
Operators
operator ==(in Change<TObject, TKey>, in Change<TObject, TKey>)
Determines whether the specified objects are equal.
public static bool operator ==(in Change<TObject, TKey> left, in Change<TObject, TKey> right)
Parameters
leftChange<TObject, TKey>The left value to compare.
rightChange<TObject, TKey>The right value to compare.
Returns
- bool
If the two values are equal to each other.
operator !=(in Change<TObject, TKey>, in Change<TObject, TKey>)
Determines whether the specified objects are equal.
public static bool operator !=(in Change<TObject, TKey> left, in Change<TObject, TKey> right)
Parameters
leftChange<TObject, TKey>The left value to compare.
rightChange<TObject, TKey>The right value to compare.
Returns
- bool
If the two values are not equal to each other.