The Labs \ Source Viewer \ SSCLI \ System.Net.Cache \ RequestCacheEntry

  1. //------------------------------------------------------------------------------
  2. // <copyright file="RequestCacheEntry.cs" company="Microsoft">
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. // </copyright>
  14. //------------------------------------------------------------------------------
  15. /*++   
  16. Abstract:
  17.     Describes the attributes of a cache entry.
  18. Author:
  19.     Alexei Vopilov    21-Dec-2002
  20. Revision History:
  21.     Aug 25 2003 moved to a new class, accomodated Whidbey-M3 changes
  22. --*/
  23. namespace System.Net.Cache
  24. {
  25.     using System;
  26.     using System.Diagnostics;
  27.     using System.Text;
  28.     using System.IO;
  29.     using System.Collections.Specialized;
  30.     using System.Threading;
  31.     using System.Globalization;
  32.    
  33.     internal class RequestCacheEntry
  34.     {
  35.         private bool m_IsPrivateEntry;
  36.         private long m_StreamSize;
  37.         private DateTime m_ExpiresUtc;
  38.         private int m_HitCount;
  39.         private DateTime m_LastAccessedUtc;
  40.         private DateTime m_LastModifiedUtc;
  41.         private DateTime m_LastSynchronizedUtc;
  42.         private TimeSpan m_MaxStale;
  43.         private int m_UsageCount;
  44.         private bool m_IsPartialEntry;
  45.        
  46.         private StringCollection m_EntryMetadata;
  47.         private StringCollection m_SystemMetadata;
  48.        
  49.        
  50.         internal RequestCacheEntry()
  51.         {
  52.             m_ExpiresUtc = m_LastAccessedUtc = m_LastModifiedUtc = m_LastSynchronizedUtc = DateTime.MinValue;
  53.         }
  54.        
  55.        
  56.         internal bool IsPrivateEntry {
  57.             get { return m_IsPrivateEntry; }
  58.             set { m_IsPrivateEntry = value; }
  59.         }
  60.         internal long StreamSize {
  61.             get { return m_StreamSize; }
  62.             set { m_StreamSize = value; }
  63.         }
  64.         internal DateTime ExpiresUtc {
  65.             get { return m_ExpiresUtc; }
  66.             set { m_ExpiresUtc = value; }
  67.         }
  68.         internal DateTime LastAccessedUtc {
  69.             get { return m_LastAccessedUtc; }
  70.             set { m_LastAccessedUtc = value; }
  71.         }
  72.         internal DateTime LastModifiedUtc {
  73.             get { return m_LastModifiedUtc; }
  74.             set { m_LastModifiedUtc = value; }
  75.         }
  76.         internal DateTime LastSynchronizedUtc {
  77.             get { return m_LastSynchronizedUtc; }
  78.             set { m_LastSynchronizedUtc = value; }
  79.         }
  80.         internal TimeSpan MaxStale {
  81.             get { return m_MaxStale; }
  82.             set { m_MaxStale = value; }
  83.         }
  84.         internal int HitCount {
  85.             get { return m_HitCount; }
  86.             set { m_HitCount = value; }
  87.         }
  88.         internal int UsageCount {
  89.             get { return m_UsageCount; }
  90.             set { m_UsageCount = value; }
  91.         }
  92.         internal bool IsPartialEntry {
  93.             get { return m_IsPartialEntry; }
  94.             set { m_IsPartialEntry = value; }
  95.         }
  96.        
  97.         internal StringCollection EntryMetadata {
  98.             get { return m_EntryMetadata; }
  99.             set { m_EntryMetadata = value; }
  100.         }
  101.         internal StringCollection SystemMetadata {
  102.             get { return m_SystemMetadata; }
  103.             set { m_SystemMetadata = value; }
  104.         }
  105.        
  106.         internal virtual string ToString(bool verbose)
  107.         {
  108.             StringBuilder sb = new StringBuilder(512);
  109.             sb.Append("\r\nIsPrivateEntry = ").Append(IsPrivateEntry);
  110.             sb.Append("\r\nIsPartialEntry = ").Append(IsPartialEntry);
  111.             sb.Append("\r\nStreamSize = ").Append(StreamSize);
  112.             sb.Append("\r\nExpires = ").Append(ExpiresUtc == DateTime.MinValue ? "" : ExpiresUtc.ToString("r", CultureInfo.CurrentCulture));
  113.             sb.Append("\r\nLastAccessed = ").Append(LastAccessedUtc == DateTime.MinValue ? "" : LastAccessedUtc.ToString("r", CultureInfo.CurrentCulture));
  114.             sb.Append("\r\nLastModified = ").Append(LastModifiedUtc == DateTime.MinValue ? "" : LastModifiedUtc.ToString("r", CultureInfo.CurrentCulture));
  115.             sb.Append("\r\nLastSynchronized = ").Append(LastSynchronizedUtc == DateTime.MinValue ? "" : LastSynchronizedUtc.ToString("r", CultureInfo.CurrentCulture));
  116.             sb.Append("\r\nMaxStale(sec) = ").Append(MaxStale == TimeSpan.MinValue ? "" : ((int)MaxStale.TotalSeconds).ToString(NumberFormatInfo.CurrentInfo));
  117.             sb.Append("\r\nHitCount = ").Append(HitCount.ToString(NumberFormatInfo.CurrentInfo));
  118.             sb.Append("\r\nUsageCount = ").Append(UsageCount.ToString(NumberFormatInfo.CurrentInfo));
  119.             sb.Append("\r\n");
  120.             if (verbose) {
  121.                 sb.Append("EntryMetadata:\r\n");
  122.                 if (m_EntryMetadata != null) {
  123.                     foreach (string s in m_EntryMetadata) {
  124.                         sb.Append(s).Append("\r\n");
  125.                     }
  126.                 }
  127.                 sb.Append("---\r\nSystemMetadata:\r\n");
  128.                 if (m_SystemMetadata != null) {
  129.                     foreach (string s in m_SystemMetadata) {
  130.                         sb.Append(s).Append("\r\n");
  131.                     }
  132.                 }
  133.             }
  134.             return sb.ToString();
  135.         }
  136.     }
  137. }

Developer Fusion