Beispiel #1
0
 internal void AddEntry(string folderId, PublicFolderViewStatesEntry newEntry)
 {
     while (this.cacheEntries.Count >= 50 && this.RemoveTheOldestEntry())
     {
     }
     this.cacheEntries.Add(folderId, newEntry);
 }
Beispiel #2
0
 private void ParseRoot(XmlTextReader reader)
 {
     if (reader.NodeType == XmlNodeType.Element)
     {
         if (reader.IsEmptyElement)
         {
             this.ThrowParserException(reader);
             return;
         }
         if (!string.Equals("Entry", reader.Name, StringComparison.OrdinalIgnoreCase))
         {
             this.ThrowParserException(reader);
             return;
         }
         if (this.cacheEntries.Count < 100)
         {
             PublicFolderViewStatesEntry publicFolderViewStatesEntry = new PublicFolderViewStatesEntry();
             publicFolderViewStatesEntry.ParseEntry(reader);
             PublicFolderViewStatesEntry publicFolderViewStatesEntry2 = this[publicFolderViewStatesEntry.FolderId];
             if (publicFolderViewStatesEntry2 != null)
             {
                 if (!publicFolderViewStatesEntry2.Dirty)
                 {
                     long lastAccessedDateTimeTicks = publicFolderViewStatesEntry2.LastAccessedDateTimeTicks;
                     if (publicFolderViewStatesEntry.LastAccessedDateTimeTicks < lastAccessedDateTimeTicks)
                     {
                         publicFolderViewStatesEntry.LastAccessedDateTimeTicks = lastAccessedDateTimeTicks;
                     }
                     this.cacheEntries[publicFolderViewStatesEntry.FolderId] = publicFolderViewStatesEntry;
                 }
             }
             else
             {
                 this.cacheEntries.Add(publicFolderViewStatesEntry.FolderId, publicFolderViewStatesEntry);
             }
             this.state = PublicFolderViewStatesCache.XmlParseState.Child;
             return;
         }
     }
     else
     {
         if (reader.NodeType == XmlNodeType.EndElement && string.Equals("PublicFolderViewStates", reader.Name, StringComparison.OrdinalIgnoreCase))
         {
             this.state = PublicFolderViewStatesCache.XmlParseState.Finished;
             return;
         }
         this.ThrowParserException(reader);
     }
 }
Beispiel #3
0
 private void RenderXml(TextWriter writer)
 {
     using (XmlTextWriter xmlTextWriter = new XmlTextWriter(writer))
     {
         xmlTextWriter.WriteStartElement("PublicFolderViewStates");
         PublicFolderViewStatesEntry[] array = new PublicFolderViewStatesEntry[this.cacheEntries.Count];
         this.cacheEntries.Values.CopyTo(array, 0);
         Array.Sort <PublicFolderViewStatesEntry>(array, new PublicFolderViewStatesEntry.LastAccessDateTimeTicksComparer());
         int num = 0;
         while (num < array.Length && num < 50)
         {
             array[num].RenderEntryXml(xmlTextWriter, "Entry");
             num++;
         }
         xmlTextWriter.WriteFullEndElement();
     }
 }
Beispiel #4
0
        private bool RemoveTheOldestEntry()
        {
            PublicFolderViewStatesEntry publicFolderViewStatesEntry = null;

            foreach (PublicFolderViewStatesEntry publicFolderViewStatesEntry2 in this.cacheEntries.Values)
            {
                if (publicFolderViewStatesEntry == null || publicFolderViewStatesEntry.LastAccessedDateTimeTicks > publicFolderViewStatesEntry2.LastAccessedDateTimeTicks)
                {
                    publicFolderViewStatesEntry = publicFolderViewStatesEntry2;
                }
            }
            if (publicFolderViewStatesEntry != null)
            {
                this.cacheEntries.Remove(publicFolderViewStatesEntry.FolderId);
                return(true);
            }
            return(false);
        }