public void RevertTransaction(ConnectionPointsTransaction transaction) { // FIXME: We want to know if this is the last transaction created for the wires. // We want to delete the wires that where created and recreate the ones removed foreach (var wire in transaction.CreatedWires ?? Enumerable.Empty <Wire>()) { if (WiresList.Remove(wire) == false) { Console.WriteLine($"Warn: Removing non-existent wire when reverting transaction! ({wire})"); } } foreach (var wire in transaction.DeletedWires ?? Enumerable.Empty <Wire>()) { WiresList.Add(wire); } foreach (var point in transaction.ControlPoints) { if (ConnectionPoints.Remove(point) == false) { Console.WriteLine($"Warn: Removing non-existent connection point when reverting transaction! ({point})"); } } }
public void ApplyTransaction(ConnectionPointsTransaction transaction) { // Now we have figured out all of the additions and deletions. // So now we can actually add and remove the appropriate wires. if (transaction.DeletedWires != null) { foreach (var dwire in transaction.DeletedWires) { if (WiresList.Remove(dwire) == false) { Console.WriteLine($"Warn: Tried to remove a wire that didn't exist! {dwire}"); } } } if (transaction.CreatedWires != null) { foreach (var awire in transaction.CreatedWires) { WiresList.Add(awire); } } ConnectionPoints.AddRange(transaction.ControlPoints); }