예제 #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 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);
        }