Exemple #1
0
        /// <summary>
        /// Create a tree for the given document
        /// </summary>
        public XmlTree(XDocument doc)
            : base(ChunkTypes.RES_XML_TYPE)
        {
            strings     = new StringPool();
            resourceMap = new ResourceMap();

            CreateNodes(doc.Root);
        }
Exemple #2
0
 /// <summary>
 /// Creation ctor
 /// </summary>
 internal Package(Table table, int id, string name)
     : base(ChunkTypes.RES_TABLE_PACKAGE_TYPE)
 {
     this.table  = table;
     this.id     = id;
     this.name   = name;
     keyStrings  = new StringPool();
     typeStrings = new StringPool();
 }
Exemple #3
0
        /// <summary>
        /// Default ctor
        /// </summary>
        internal Table(ResReader reader)
            : base(reader, ChunkTypes.RES_TABLE_TYPE)
        {
            var packageCount = reader.ReadInt32();

            strings = new StringPool(reader);
            for (var i = 0; i < packageCount; i++)
            {
                packages.Add(new Package(this, reader));
            }
        }
Exemple #4
0
            /// <summary>
            /// Default ctor
            /// </summary>
            internal Package(Table table, ResReader reader)
                : base(reader, ChunkTypes.RES_TABLE_PACKAGE_TYPE)
            {
                this.table = table;

                id   = reader.ReadInt32();
                name = reader.ReadFixedLenghtUnicodeString(128);
                var typeStringsOffset = reader.ReadInt32();
                var lastPublicType    = reader.ReadInt32();
                var keyStringsOffset  = reader.ReadInt32();
                var lastPublicKey     = reader.ReadInt32();

                // Record offset
                var dataOffset = reader.Position;

                // Data
                typeStrings = new StringPool(reader);
                keyStrings  = new StringPool(reader);

                TypeSpec currentTypeSpec = null;

                while (reader.Position - dataOffset < DataSize)
                {
                    var chunkType = reader.PeekChunkType();
                    if (chunkType == ChunkTypes.RES_TABLE_TYPE_SPEC_TYPE)
                    {
                        currentTypeSpec = Read(reader, () => new TypeSpec(this, reader));
                        typeSpecs.Add(currentTypeSpec);
                    }
                    else if (chunkType == ChunkTypes.RES_TABLE_TYPE_TYPE)
                    {
                        if (currentTypeSpec == null)
                        {
                            throw new IOException("Invalid chunk sequence: content read before typeSpec.");
                        }
                        var parent = currentTypeSpec;
                        var type   = Read(reader, () => new Type(parent, reader));
                        currentTypeSpec.Add(type);
                    }
                    else
                    {
                        throw new IOException("Unexpected chunk type (" + chunkType + ").");
                    }
                }
            }
Exemple #5
0
        /// <summary>
        /// Reading ctor
        /// </summary>
        public XmlTree(ResReader reader)
            : base(reader, ChunkTypes.RES_XML_TYPE)
        {
            strings     = new StringPool(reader);
            resourceMap = new ResourceMap(reader);

            while (true)
            {
                var  tag = reader.PeekChunkType();
                Node node;
                switch (tag)
                {
                case ChunkTypes.RES_XML_START_NAMESPACE_TYPE:
                    node = new StartNamespace(reader, this);
                    break;

                case ChunkTypes.RES_XML_START_ELEMENT_TYPE:
                    node = new StartElement(reader, this);
                    break;

                case ChunkTypes.RES_XML_CDATA_TYPE:
                    node = new CData(reader, this);
                    break;

                case ChunkTypes.RES_XML_END_ELEMENT_TYPE:
                    node = new EndElement(reader, this);
                    break;

                case ChunkTypes.RES_XML_END_NAMESPACE_TYPE:
                    node = new EndNamespace(reader, this);
                    break;

                default:
                    throw new IOException(string.Format("Unexpected tag: 0x{0:X}", (int)tag));
                }

                nodes.Add(node);
                if (tag == ChunkTypes.RES_XML_END_NAMESPACE_TYPE)
                {
                    break;
                }
            }
        }
Exemple #6
0
 /// <summary>
 /// Creation ctor
 /// </summary>
 public Table(string packageName)
     : base(ChunkTypes.RES_TABLE_TYPE)
 {
     strings = new StringPool();
     packages.Add(new Package(this, 0x7f, packageName));
 }