private void UndoMerge(UndoItem undo) { var votes = GetVoteEntries(undo.VoteType); votes[undo.Vote1].UnionWith(undo.Voters1); votes[undo.Vote2].Clear(); votes[undo.Vote2].UnionWith(undo.Voters2); }
private void UndoRemoveVoter(UndoItem undo) { var votes = GetVoteEntries(undo.VoteType); foreach (var vote in undo.Votes1) { votes[vote].Add(undo.Voter1); } }
private void UndoJoin(UndoItem undo) { var votes = GetVoteEntries(undo.VoteType); foreach (var vote in votes) { if (undo.Votes1.Contains(vote.Key)) { vote.Value.Add(undo.Voter1); } else { vote.Value.Remove(undo.Voter1); } } }
private void UndoRemoveVote(UndoItem undo) { var votes = GetVoteEntries(undo.VoteType); votes[undo.Vote1].UnionWith(undo.Voters1); }
private void PreserveRemovedVoter(Identity voter1, IEnumerable <VotePartition> voter1Votes, VoteType type) { var undoItem = new UndoItem(UndoItemType.RemoveVoter, type, voter1: voter1, votes1: voter1Votes); UndoBuffer.Push(undoItem); }
private void PreserveRemovedVote(VotePartition vote1, IEnumerable <Identity> vote1Voters, VoteType type) { var undoItem = new UndoItem(UndoItemType.RemoveVote, type, vote1: vote1, voters1: vote1Voters); UndoBuffer.Push(undoItem); }
private void PreserveJoin(Identity voter1, Identity voter2, IEnumerable <VotePartition> voter1Votes, VoteType type) { var undoItem = new UndoItem(UndoItemType.Join, type, voter1: voter1, voter2: voter2, votes1: voter1Votes); UndoBuffer.Push(undoItem); }
/// <summary> /// Preserves the specified state prior to a vote merge, to allow undoing it. /// </summary> /// <param name="vote1">The vote1.</param> /// <param name="vote2">The vote2.</param> /// <param name="voters1">The voters1.</param> /// <param name="voters2">The voters2.</param> /// <param name="type">The type.</param> private void PreserveMerge(VotePartition vote1, VotePartition vote2, IEnumerable <Identity> voters1, IEnumerable <Identity> voters2, VoteType type) { var undoItem = new UndoItem(UndoItemType.Merge, type, vote1: vote1, vote2: vote2, voters1: voters1, voters2: voters2); UndoBuffer.Push(undoItem); }