Beispiel #1
0
        public void Serialize()
        {
            if (InfoObj != null)
            {
                Tags.Add(new UInt32Tag(TagId.ObjectInfoLink, InfoObj.ID));
            }

            if (LinkObj != null)
            {
                Tags.Add(new UInt32Tag(TagId.Link, LinkObj.ID));
            }

            uint[] ids = new uint[m_lstChildren.Count];
            int    i   = 0;

            foreach (BBeBObject c in m_lstChildren)
            {
                ids[i++] = c.ID;
            }
            Tags.Add(new UInt32ArrayTag(TagId.PageObjectIds, ids));

            StreamTagGroup  streamTags = new StreamTagGroup();
            MemoryStream    stream     = new MemoryStream();
            BBeBinaryWriter writer     = new BBeBinaryWriter(stream);

            BBeBSerializer.SerializeTags(m_StreamTags, writer);
            writer.Flush();

            byte[] data = new byte[writer.Position];
            Array.Copy(stream.GetBuffer(), data, writer.Position);
            streamTags.Data = data;

            Tags.Add(streamTags);
        }
Beispiel #2
0
        private void Deserialize()
        {
            Debug.Assert(!m_bEntriesParsed);

            StreamTagGroup data = (StreamTagGroup)FindFirstTag(TagId.StreamGroup);

            if (data == null)
            {
                return;
            }

            BBeBinaryReader reader = new BBeBinaryReader(new MemoryStream(data.Data));

            uint dwLabelCount = reader.ReadUInt32();
            uint i;

            // The offsets are the byte offset to the start of the TOC label entry
            // relative to the first TOC label entry (AKA the end of this table)
            uint[] offsets = new uint[dwLabelCount];
            for (i = 0; i < dwLabelCount; i++)
            {
                offsets[i] = reader.ReadUInt32();
            }

            long dwEndOfTablePos = reader.BaseStream.Position;

            for (i = 0; i < dwLabelCount; i++)
            {
                if (offsets[i] != reader.BaseStream.Position - dwEndOfTablePos)
                {
                    throw new InvalidDataException("TOC entry didn't start at specified offset");
                }

                uint refpage = reader.ReadUInt32();
                uint refobj  = reader.ReadUInt32();

                string labelText = reader.ReadString();

                AddEntry(refpage, refobj, labelText);
            }
        }