Beispiel #1
0
 public override void VisitMetadataRootHeader(MetadataRoot.MetadataRootHeader header)
 {
     m_binaryWriter.Write(header.Signature);
     m_binaryWriter.Write(header.MajorVersion);
     m_binaryWriter.Write(header.MinorVersion);
     m_binaryWriter.Write(header.Reserved);
     m_binaryWriter.Write(header.Version.Length + 3 & (~3));
     m_binaryWriter.Write(Encoding.ASCII.GetBytes(header.Version));
     m_binaryWriter.QuadAlign();
     m_binaryWriter.Write(header.Flags);
     m_binaryWriter.Write((ushort)m_root.Streams.Count);
 }
Beispiel #2
0
        public override void VisitMetadataRootHeader(MetadataRoot.MetadataRootHeader header)
        {
            long headpos = m_binaryReader.BaseStream.Position;

            header.Signature = m_binaryReader.ReadUInt32();

            if (header.Signature != MetadataRoot.MetadataRootHeader.StandardSignature)
            {
                throw new MetadataFormatException("Wrong magic number");
            }

            header.MajorVersion = m_binaryReader.ReadUInt16();
            header.MinorVersion = m_binaryReader.ReadUInt16();
            header.Reserved     = m_binaryReader.ReadUInt32();

            // read version
            uint length = m_binaryReader.ReadUInt32();

            if (length != 0)
            {
                long pos = m_binaryReader.BaseStream.Position;

                byte [] version, buffer = new byte [length];
                int     read            = 0;
                while (read < length)
                {
                    byte cur = (byte)m_binaryReader.ReadSByte();
                    if (cur == 0)
                    {
                        break;
                    }
                    buffer [read++] = cur;
                }
                version = new byte [read];
                Buffer.BlockCopy(buffer, 0, version, 0, read);
                header.Version = Encoding.UTF8.GetString(version, 0, version.Length);

                pos += length - headpos + 3;
                pos &= ~3;
                pos += headpos;

                m_binaryReader.BaseStream.Position = pos;
            }
            else
            {
                header.Version = string.Empty;
            }

            header.Flags   = m_binaryReader.ReadUInt16();
            header.Streams = m_binaryReader.ReadUInt16();
        }
 public override void VisitMetadataRootHeader(MetadataRoot.MetadataRootHeader header)
 {
     header.SetDefaultValues();
 }