Beispiel #1
0
        /// <summary>
        /// Initialize this Object Server. NOTE: this is created for SOP internal use only.
        /// </summary>
        /// <param name="filename"></param>
        public void Initialize(string filename)
        {
            if (string.IsNullOrEmpty(filename))
            {
                throw new ArgumentNullException("filename");
            }

            if (!ReadOnly && !Sop.Utility.Utility.HasRequiredAccess(filename))
            {
                throw new InvalidOperationException(string.Format("No Write access on file '{0}'.", filename));
            }

            if (string.IsNullOrEmpty(Path))
            {
                Path = GetRootPath(filename);
            }

            //** Create/Open the System File object
            if (SystemFile == null)
            {
                if (Transaction != null)
                {
                    SystemFile =
                        ((Sop.Transaction.TransactionBase)
                             ((Sop.Transaction.ITransactionLogger)Transaction).GetOuterChild()).CreateFile();
                }
                else
                {
                    SystemFile = new File.File();
                }
            }
            if (Profile == null)
            {
                Profile = new Profile();
            }
            //90;
            //ProfileScheme.IsDataInKeySegment = true;
            ((File.File)SystemFile).Profile = Profile;
            ((IInternalPersistent)SystemFile).DiskBuffer.DataAddress = 0;
            ((File.IFile)SystemFile).Initialize(this, "SystemFile", filename, AccessMode.ReadWrite, null);
            ReadSystemFileAttributes();
            Open();
        }
Beispiel #2
0
        /// <summary>
        /// DeSerialize
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="reader"></param>
        public override void Unpack(IInternalPersistent parent,
                                    BinaryReader reader)
        {
            System.IO.BinaryReader binaryReader = reader;
            long l = binaryReader.ReadInt64();

            if (l >= 0)
            {
                DiskBuffer.DataAddress = l;
            }
            long cnt = binaryReader.ReadInt64();
            long saa = binaryReader.ReadInt64();

            if ((Count > 0 && cnt == 0) ||
                StartAllocatableAddress > 0 && saa == 0)
            {
                binaryReader.ReadInt64();
                binaryReader.ReadInt64();
                binaryReader.ReadInt64();
                binaryReader.ReadInt64();
                if (reader.ReadBoolean())
                {
                    var rs = new DeletedBlockInfo();
                    rs.Unpack(parent, reader);
                }
                return;
            }
            Count = cnt;                   //BinaryReader.ReadInt32();
            StartAllocatableAddress = saa; // BinaryReader.ReadInt64();
            EndAllocatableAddress   = binaryReader.ReadInt64();
            NextAllocatableAddress  = binaryReader.ReadInt64();
            long          obh = binaryReader.ReadInt64();
            long          obt = binaryReader.ReadInt64();
            DataBlockSize dataBlockSize;

            if (parent != null)
            {
                File.File f = (File.File)InternalPersistent.GetParent(parent, typeof(File.File), true);
                dataBlockSize = f.DataBlockSize;
            }
            else
            {
                dataBlockSize = (DataBlockSize)DiskBuffer.Length;
            }
            if (obh >= 0)
            {
                OccupiedBlocksHead             = new Sop.DataBlock(dataBlockSize);
                OccupiedBlocksHead.DataAddress = obh;
            }
            else if (OccupiedBlocksHead != null)
            {
                OccupiedBlocksHead = null;
            }
            if (obt >= 0)
            {
                OccupiedBlocksTail             = new Sop.DataBlock(dataBlockSize);
                OccupiedBlocksTail.DataAddress = obt;
            }
            else if (OccupiedBlocksTail != null)
            {
                OccupiedBlocksTail = null;
            }

            if (reader.ReadBoolean())
            {
                RecycledSegment = new DeletedBlockInfo();
                RecycledSegment.Unpack(parent, reader);
                RecycledSegmentBeforeTransaction = (DeletedBlockInfo)RecycledSegment.Clone();
            }
        }