ReadString() static private method

static private ReadString ( Stream s ) : string
s Stream
return string
        private Hashtable Load(Stream s)
        {
            Hashtable table     = new Hashtable();
            int       itemCount = Utils.ReadInt32(s);

            for (int i = 0; i < itemCount; i++)
            {
                try
                {
                    string     key = Utils.ReadString(s);
                    ICacheItem val = persister.Read(s);
                    if (val == null)                      // corrupt cache file
                    {
                        return(table);
                    }

                    table[key] = val;
                }
                catch (IOException)
                {
                    return(table);
                }
            }
            return(table);
        }
Exemplo n.º 2
0
        public override ICacheItem Read(Stream inputStream)
        {
            string s = Utils.ReadString(inputStream);

            string[] chunks       = s.Split('\n');
            string   url          = chunks[0];
            DateTime creationTime = new DateTime(long.Parse(chunks[1]));
            string   filename     = chunks[2];
            long     fileSize     = long.Parse(chunks[3]);

            PictureCacheItem pci = new PictureCacheItem();

            pci.url          = url;
            pci.creationTime = creationTime;
            pci.filename     = filename;
            pci.fileSize     = fileSize;
            return(pci);
        }
Exemplo n.º 3
0
        public override ICacheItem Read(Stream inputStream)
        {
            string s        = Utils.ReadString(inputStream);
            string response = Utils.ReadString(inputStream);

            string[] chunks = s.Split('\n');

            // Corrupted cache record, so throw IOException which is then handled and returns partial cache.
            if (chunks.Length != 2)
            {
                throw new IOException("Unexpected number of chunks found");
            }

            string            url          = chunks[0];
            DateTime          creationTime = new DateTime(long.Parse(chunks[1]));
            ResponseCacheItem item         = new ResponseCacheItem();

            item.Url          = url;
            item.CreationTime = creationTime;
            item.Response     = response;
            return(item);
        }