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
TObject
The type of the object.
TKey
The type of the key.
- Implements
-
IEquatable<Change<TObject, TKey>>
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
reason
ChangeReasonThe reason.
key
TKeyThe key.
current
TObjectThe current.
previous
Optional<TObject>The previous.
currentIndex
intValue of the current.
previousIndex
intValue 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
reason
ChangeReasonThe reason.
key
TKeyThe key.
current
TObjectThe current.
index
intThe 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
key
TKeyThe key.
current
TObjectThe current.
currentIndex
intThe CurrentIndex.
previousIndex
intCurrentIndex 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
other
Change<TObject, TKey>
Returns
Equals(object?)
public override bool Equals(object? obj)
Parameters
obj
object
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
left
Change<TObject, TKey>The left value to compare.
right
Change<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
left
Change<TObject, TKey>The left value to compare.
right
Change<TObject, TKey>The right value to compare.
Returns
- bool
If the two values are not equal to each other.