예제 #1
0
            /// <summary>
            /// Read ctor
            /// </summary>
            internal Map(EntryInstance parent, ResReader reader)
            {
                this.parent = parent;

                // header
                nameRef = TableRef.Read(reader);
                value = new Value(reader);
            }
예제 #2
0
            /// <summary>
            /// Read ctor
            /// </summary>
            internal Map(EntryInstance parent, ResReader reader)
            {
                this.parent = parent;

                // header
                nameRef = TableRef.Read(reader);
                value   = new Value(reader);
            }
예제 #3
0
            /// <summary>
            /// Read ctor
            /// </summary>
            internal Type(TypeSpec parent, ResReader reader)
                : base(reader, ChunkTypes.RES_TABLE_TYPE_TYPE)
            {
                this.parent = parent;

                var id = reader.ReadByte();

                reader.Skip(3); // reserved
                if (id != parent.Id)
                {
                    throw new IOException("Type id (" + id + ") " + "doesn't match parent id (" + parent.Id + ").");
                }
                var entryCount = reader.ReadInt32();

                if (entryCount != parent.EntryCount)
                {
                    throw new IOException(string.Format("Type entry count ({0}) doesn't match parent entry count ({1})", entryCount, parent.EntryCount));
                }
                var entriesStart = reader.ReadInt32();

                configuration = new Configuration(reader);
                // Data
                var offsets  = reader.ReadIntArray(entryCount);
                var dataSize = (Size - entriesStart);

                if ((dataSize % 4) != 0)
                {
                    throw new IOException("Type data size (" + dataSize + ") is not multiple of 4.");
                }
                for (var i = 0; i < entryCount; i++)
                {
                    if (offsets[i] != NO_ENTRY)
                    {
                        var actualOffset = reader.Position;
                        var instance     = EntryInstance.Read(this, reader);
                        parent.GetEntry(i).Add(instance);
                    }
                }
            }
예제 #4
0
 /// <summary>
 /// Try to get an instance for the given type.
 /// </summary>
 public bool TryGetInstance(Type type, out EntryInstance instance)
 {
     return(instances.TryGetValue(type, out instance));
 }
예제 #5
0
 /// <summary>
 /// Add the given instance
 /// </summary>
 public void Add(EntryInstance instance)
 {
     instances.Add(instance.Type, instance);
 }
예제 #6
0
 /// <summary>
 /// Try to get an instance for the given type.
 /// </summary>
 public bool TryGetInstance(Type type, out EntryInstance instance)
 {
     return instances.TryGetValue(type, out instance);
 }
예제 #7
0
 /// <summary>
 /// Add the given instance
 /// </summary>
 public void Add(EntryInstance instance)
 {
     instances.Add(instance.Type, instance);
 }