Exemple #1
0
        /// <summary>
        /// Unpack this item for DeSerialization from Stream
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="reader"></param>
        public virtual void Unpack(IInternalPersistent parent, System.IO.BinaryReader reader)
        {
            bool?r = CollectionOnDisk.ReadPersistentData(parent, reader, ref Key);

            if (r == null)
            {
                if (((BTreeAlgorithm)parent).onKeyUnpack != null)
                {
                    Key = ((BTreeAlgorithm)parent).onKeyUnpack(reader);
                }
                else
                {
                    throw new SopException("Can't Deserialize Custom persisted 'Key'.");
                }
            }
            if (Value == null)
            {
                var f = (File.File)InternalPersistent.GetParent(parent, typeof(File.File));
                Value = new ItemOnDisk(f.DataBlockSize);
            }
            bool valueIsReference = reader.ReadBoolean();

            if (valueIsReference)
            {
                Value.DiskBuffer.DataAddress = reader.ReadInt64();
            }
            else
            {
                object o = Value;
                CollectionOnDisk.ReadPersistentData(parent, reader, ref o);
                Value = (ItemOnDisk)o;
                if (Value.DataIsUserDefined && ((BTreeAlgorithm)parent).onValueUnpack != null)
                {
                    Value.Data = ((BTreeAlgorithm)parent).onValueUnpack(reader);
                }
            }
            IsDirty = false;
        }
Exemple #2
0
 public BTreeItemOnDisk(DataBlockSize dataBlockSize, object key, object value)
 {
     Key   = key;
     Value = new ItemOnDisk(dataBlockSize, value);
 }