/// <summary> /// Adds a change to the diff. /// </summary> /// <param name="change">Change to add.</param> public void Add(ValueChange <T> change) { if (IsFinalized) { throw new Exception("Cannot add change to a finalized diff."); } if (change.OldValue.Equals(change.NewValue)) { throw new Exception("Cannot add change to diff that does not change a value."); } _changes.Add(change); // Change means its worth potentially minimizing, as this change might duplicate previous ones IsCompressed = false; }
/// <summary> /// Compares the two changes according to their positions and values. /// </summary> /// <param name="other"/> /// <returns>True if the two value changes represent the same change, false otherwise.</returns> public bool Matches(ValueChange <T> other) => Equals(other);
/// <inheritdoc /> public bool Equals(ValueChange <T> other) => Position.Equals(other.Position) && OldValue.Equals(other.OldValue) && NewValue.Equals(other.NewValue);