Esempio n. 1
0
        /// <summary>
        /// </summary>
        /// <param name="entryId"></param>
        /// <param name="entry"></param>
        /// <exception cref="NotImplementedException"></exception>
        public void AddEntry(int entryId, CacheFileBase entry)
        {
            var binaryFileEntry = entry.ToBinaryFile();

            if (binaryFileEntry.Info == null)
            {
                binaryFileEntry.Info = new CacheFileInfo();
            }

            binaryFileEntry.Info.Index   = this.Info.Index;
            binaryFileEntry.Info.FileId  = this.Info.FileId;
            binaryFileEntry.Info.EntryId = entryId;

            this._entries.Add(entryId, binaryFileEntry);
        }
Esempio n. 2
0
        /// <summary>
        /// Writes a file to the cache.
        /// The file's info will be used to determine where and how to put the file in the cache.
        /// </summary>
        /// <param name="file"></param>
        /// <exception cref="ArgumentException"></exception>
        public void PutFile(CacheFileBase file)
        {
            if (file.Info.Index == CacheIndex.Undefined || file.Info.FileId == null)
            {
                throw new ArgumentException("A file must have an index and file id to be written.");
            }

            // TODO: #57
            if (file.Info.EntryId != null)
            {
                throw new ArgumentException("Entries can not be directly written to the cache. Use an entry file containing entries or remove the entry id from its info.");
            }

            var binaryFile = file.ToBinaryFile();

            this.PutBinaryFile(binaryFile);
            this.PutFileInfo(binaryFile.Info);
        }