public XPathNavigator GetContent(string identifier) { // get the document containing the identifier IndexedFile document = GetCachedDocument(identifier); if (document == null) { return(null); } // select the comment part of the document return(document.GetContent(identifier)); }
private IndexedFile GetCachedDocument(string identifier) { string file; if (idToFileMap.TryGetValue(identifier, out file)) { IndexedFile document; if (cache.TryGetValue(file, out document)) { // move the file from its current position to the head of the lru linked list lruLinkedList.Remove(document.ListNode); lruLinkedList.AddFirst(document.ListNode); } else { // not in the cache, so load and index a new source file document = new IndexedFile(file, valueExpression, keyExpression); if (cache.Count >= _cacheSize) { // the cache is full // the last node in the linked list has the path of the next file to remove from the cache if (lruLinkedList.Last != null) { cache.Remove(lruLinkedList.Last.Value); lruLinkedList.RemoveLast(); } } // add the new file to the cache and to the head of the lru linked list cache.Add(file, document); document.ListNode = lruLinkedList.AddFirst(file); } return(document); } else { return(null); } }
private IndexedFile GetCachedDocument(string identifier) { string file; if (idToFileMap.TryGetValue(identifier, out file)) { IndexedFile document; if (cache.TryGetValue(file, out document)) { // move the file from its current position to the head of the lru linked list lruLinkedList.Remove(document.ListNode); lruLinkedList.AddFirst(document.ListNode); } else { // not in the cache, so load and index a new source file document = new IndexedFile(file, valueExpression, keyExpression); if (cache.Count >= _cacheSize) { // the cache is full // the last node in the linked list has the path of the next file to remove from the cache if (lruLinkedList.Last != null) { cache.Remove(lruLinkedList.Last.Value); lruLinkedList.RemoveLast(); } } // add the new file to the cache and to the head of the lru linked list cache.Add(file, document); document.ListNode = lruLinkedList.AddFirst(file); } return (document); } else { return (null); } }