/// <summary> /// Add a ChangeProposal to change list of a related PreviewGroup. /// </summary> /// <param name="previewGroup">Preview group this change will be added to.</param> /// <param name="change">The ChangeProposal.</param> internal void AddChange(RefactoringPreviewGroup previewGroup, ChangeProposal change) { ArgumentValidation.CheckForNullReference(previewGroup, "previewGroup"); ArgumentValidation.CheckForNullReference(change, "change"); // First check if changes for same location exists or not, if exist, we will not add it anymore var exist = false; foreach (var existingChanges in _changeList.Values) { if (existingChanges.Contains(change)) { exist = true; break; } } if (!exist) { HashSet <ChangeProposal> changes = null; if (_changeList.TryGetValue(previewGroup, out changes) == false) { // There is no change list for this preview group, // create one and add to the dictionary. changes = new HashSet <ChangeProposal>(); _changeList.Add(previewGroup, changes); } // Add change to the change list. changes.Add(change); } }
/// <summary> /// Get list of ChangeProposal for a RefactoringPreviewGroup in this file. /// </summary> /// <param name="previewGroup"></param> /// <returns>A list of ChangeProposal for a RefactoringPreviewGroup in this file.</returns> internal IList <ChangeProposal> GetChanges(RefactoringPreviewGroup previewGroup) { ArgumentValidation.CheckForNullReference(previewGroup, "previewGroup"); List <ChangeProposal> results = null; HashSet <ChangeProposal> changes = null; if (_changeList.TryGetValue(previewGroup, out changes) == false) { results = new List <ChangeProposal>(); } else { results = new List <ChangeProposal>(changes); } return(results); }
/// <summary> /// Get list of ChangeProposal for a RefactoringPreviewGroup in this file. /// </summary> /// <param name="previewGroup"></param> /// <returns>A list of ChangeProposal for a RefactoringPreviewGroup in this file.</returns> internal IList<ChangeProposal> GetChanges(RefactoringPreviewGroup previewGroup) { ArgumentValidation.CheckForNullReference(previewGroup, "previewGroup"); List<ChangeProposal> results = null; HashSet<ChangeProposal> changes = null; if (_changeList.TryGetValue(previewGroup, out changes) == false) { results = new List<ChangeProposal>(); } else { results = new List<ChangeProposal>(changes); } return results; }
/// <summary> /// Add a ChangeProposal to change list of a related PreviewGroup. /// </summary> /// <param name="previewGroup">Preview group this change will be added to.</param> /// <param name="change">The ChangeProposal.</param> internal void AddChange(RefactoringPreviewGroup previewGroup, ChangeProposal change) { ArgumentValidation.CheckForNullReference(previewGroup, "previewGroup"); ArgumentValidation.CheckForNullReference(change, "change"); // First check if changes for same location exists or not, if exist, we will not add it anymore var exist = false; foreach (var existingChanges in _changeList.Values) { if (existingChanges.Contains(change)) { exist = true; break; } } if (!exist) { HashSet<ChangeProposal> changes = null; if (_changeList.TryGetValue(previewGroup, out changes) == false) { // There is no change list for this preview group, // create one and add to the dictionary. changes = new HashSet<ChangeProposal>(); _changeList.Add(previewGroup, changes); } // Add change to the change list. changes.Add(change); } }