Beispiel #1
0
        /// <summary>
        /// Shallow copy the Collection into a new instance and return it.
        /// </summary>
        public virtual object Clone()
        {
            var lid = new LinkedListOnDisk
            {
                File            = File,
                DataBlockSize   = DataBlockSize,
                HintSizeOnDisk  = HintSizeOnDisk,
                currentEntry    = currentEntry,
                DataAddress     = DataAddress,
                MruManager      = MruManager,
                MruMinCapacity  = MruMinCapacity,
                MruMaxCapacity  = MruMaxCapacity,
                SyncRoot        = this.SyncRoot,
                DataBlockDriver = this.DataBlockDriver,
                FirstItem       = new LinkedItemOnDisk(File.DataBlockSize)
            };

            lid.CurrentItem = lid.FirstItem;
            lid.LastItem    = new LinkedItemOnDisk(File.DataBlockSize);
            int systemDetectedBlockSize;

            lid.FileStream         = File.UnbufferedOpen(out systemDetectedBlockSize);
            lid.isOpen             = true;
            lid.IsCloned           = true;
            lid.Name               = Name; // string.Format("{0} Clone", Name);
            lid.OnDiskBinaryWriter = new OnDiskBinaryWriter(File.Server.Encoding);
            lid.OnDiskBinaryReader = new OnDiskBinaryReader(File.Server.Encoding);
            return(lid);
        }
        /// <summary>
        /// Shared Block on Disk purifies data and only saves one
        /// copy of Meta data in it.
        /// </summary>
        /// <param name="biod"></param>
        /// <param name="db"></param>
        protected override void PurifyMeta(LinkedItemOnDisk biod, Sop.DataBlock db)
        {
            if (db.SizeOccupied > 0)
            {
                //** purify data by separating meta data from it so meta data won't be serialized more than once
                int    metaDataSize = LinkedListOnDisk.SizeOfMetaData(this);
                int    newSize      = db.SizeOccupied - metaDataSize;
                byte[] newData      = new byte[newSize];
                Array.Copy(db.Data, metaDataSize, newData, 0, newSize);

                //** assign data to block for serialization
                biod.Data = newData;
            }
        }
Beispiel #3
0
 public ListOnDiskEnumerator(LinkedListOnDisk lid)
 {
     this._listOnDisk = lid;
     this.Reset();
 }