示例#1
0
        internal static void ReadPreCookies(FileStream fs, long offset, int pageSize, LinkedList <CacheFileCookie> cookieList, int capacity)
        {
            BinaryFormatter binaryFormatter = ExchangeBinaryFormatterFactory.CreateBinaryFormatter(null);

            CacheFileCookieSerializer.SetOffsetAndPageSize(fs, binaryFormatter, offset, ref pageSize);
            for (int i = 0; i < pageSize; i++)
            {
                long position = fs.Position;
                if (position == fs.Length)
                {
                    return;
                }
                CacheFileCookie cacheFileCookie = (CacheFileCookie)binaryFormatter.Deserialize(fs);
                cacheFileCookie.NextCookieOffset = fs.Position;
                cookieList.AddFirst(cacheFileCookie);
                if (cookieList.Count > capacity)
                {
                    cookieList.RemoveLast();
                }
                if (cacheFileCookie.PreCookieOffset < 0L)
                {
                    return;
                }
                fs.Seek(cacheFileCookie.PreCookieOffset, SeekOrigin.Begin);
            }
        }
示例#2
0
        internal static CacheFileCookie ReadCookie(FileStream fs, long offset)
        {
            LinkedList <CacheFileCookie> linkedList = CacheFileCookieSerializer.ReadCookieList(fs, offset, 1);

            if (linkedList.First == null)
            {
                return(null);
            }
            return(linkedList.First.Value);
        }
示例#3
0
        internal static CacheFileCookie ReadLastCookie(FileStream fs)
        {
            LinkedList <CacheFileCookie> linkedList = CacheFileCookieSerializer.ReadCookieList(fs, -1L, -1);

            if (linkedList.Last == null)
            {
                return(null);
            }
            return(linkedList.Last.Value);
        }
示例#4
0
        internal static LinkedList <CacheFileCookie> ReadCookieList(FileStream fs, long offset, int pageSize)
        {
            LinkedList <CacheFileCookie> linkedList = new LinkedList <CacheFileCookie>();
            BinaryFormatter binaryFormatter         = ExchangeBinaryFormatterFactory.CreateBinaryFormatter(null);

            CacheFileCookieSerializer.SetOffsetAndPageSize(fs, binaryFormatter, offset, ref pageSize);
            for (int i = 0; i < pageSize; i++)
            {
                long position = fs.Position;
                if (position == fs.Length)
                {
                    break;
                }
                CacheFileCookie cacheFileCookie = (CacheFileCookie)binaryFormatter.Deserialize(fs);
                cacheFileCookie.NextCookieOffset = fs.Position;
                linkedList.AddLast(cacheFileCookie);
            }
            return(linkedList);
        }
示例#5
0
 internal static LinkedList <CacheFileCookie> ReadCookieList(FileStream fs)
 {
     return(CacheFileCookieSerializer.ReadCookieList(fs, -1L, -1));
 }