private void AddEditComponent(string oneLineData, string commitHash) { var componentNewId = string.Empty; var existingKey = new HashId(); var oneLineSeparated = oneLineData.Split (new Char[] { '\t', ' ' }, StringSplitOptions.RemoveEmptyEntries); if (this.jsonConfig.TryMatchPath(oneLineSeparated[2], out componentNewId)) { var componentKey = new HashId { CommitHash = commitHash, ComponentId = componentNewId }; if (TryMatchComponent(componentKey, out existingKey)) { this.componentDictionary[existingKey].ComponentInsertions += GetNumberFromString(oneLineSeparated[0]); this.componentDictionary[existingKey].ComponentDeletions += GetNumberFromString(oneLineSeparated[1]); } else { var component = new ComponentData { ComponentInsertions = GetNumberFromString(oneLineSeparated[0]), ComponentDeletions = GetNumberFromString(oneLineSeparated[1]) }; this.componentDictionary.Add(componentKey, component); } } }
private bool TryMatchComponent(HashId data, out HashId existingKey) { existingKey = new HashId(); foreach (var dictionaryItem in this.componentDictionary) { if (dictionaryItem.Key.Equals(data)) { existingKey = dictionaryItem.Key; return(true); } } return(false); }