/// <summary>Adds an entry to the map.</summary> /// <param name="docFile">Info about the doc file containing the link.</param> /// <param name="codeFile">Info about the code file linked to.</param> /// <param name="docLine">The doc file line number that contains the link.</param> /// <param name="queryParams">The query parameters associated with the link.</param> /// <returns>True if the entry was added; otherwise, false.</returns> public bool Add(FileData docFile, FileData codeFile, int docLine, string queryParams) { var added = false; FileData doc, code; var link = new LinkData { DocLine = docLine, QueryParams = queryParams }; if (!DocFileIndex.ContainsKey(docFile)) { doc = docFile; DocFileIndex[doc] = new Dictionary <FileData, HashSet <LinkData> >(FileData.FileComparer); } else { // else if the key and the incoming docFile are not the same object, use the existing key. doc = DocFileIndex.Keys.First(k => FileData.FileComparer.Equals(k, docFile)); } if (!CodeFileIndex.ContainsKey(codeFile)) { code = codeFile; CodeFileIndex[code] = new Dictionary <FileData, HashSet <LinkData> >(FileData.FileComparer); } else { // else if the key and the incoming codeFile are not the same object, use the existing key. code = CodeFileIndex.Keys.First(k => FileData.FileComparer.Equals(k, codeFile)); } if (!DocFileIndex[doc].ContainsKey(code)) { DocFileIndex[doc][code] = new HashSet <LinkData>(LinkData.LinkComparer); } added |= DocFileIndex[doc][code].Add(link); if (!CodeFileIndex[code].ContainsKey(doc)) { CodeFileIndex[code][doc] = new HashSet <LinkData>(LinkData.LinkComparer); } added |= CodeFileIndex[code][doc].Add(link); // Every addition should be unique, unless we index the same line more than once. return(added); }
/// <summary>Removes all entries from the map.</summary> public void Clear() { DocFileIndex.Clear(); CodeFileIndex.Clear(); }