Exemple #1
0
        /// <summary>
        /// Default ctor
        /// </summary>
        internal StringPool(ResReader reader)
            : base(reader, ChunkTypes.RES_STRING_POOL_TYPE)
        {
            var stringCount      = reader.ReadInt32();
            var styleOffsetCount = reader.ReadInt32();
            var flags            = (StringPoolFlags)reader.ReadInt32();

            IsUtf8 = ((flags & StringPoolFlags.UTF8_FLAG) != 0);
            var stringsStart = reader.ReadInt32();
            var stylesStart  = reader.ReadInt32();

            var stringOffsets = reader.ReadIntArray(stringCount);

            if (styleOffsetCount != 0)
            {
                styleOffsets = reader.ReadIntArray(styleOffsetCount);
            }
            byte[] stringData;
            {
                var size = ((stylesStart == 0) ? Size : stylesStart) - stringsStart;
                if ((size % 4) != 0)
                {
                    throw new IOException(string.Format("String data size is not multiple of 4 ({0}).", size));
                }
                stringData = reader.ReadByteArray(size);
            }
            if (stylesStart != 0)
            {
                var size = (Size - stylesStart);
                if ((size % 4) != 0)
                {
                    throw new IOException(string.Format("Style data size is not multiple of 4 ({0}).", size));
                }
                styles = reader.ReadIntArray(size / 4);
            }

            var count = (stringOffsets != null) ? stringOffsets.Length : 0;

            for (var i = 0; i != count; ++i)
            {
                list.Add(new Entry(GetRaw(i, stringOffsets, stringData, IsUtf8, reader), -1));
            }
        }
            /// <summary>
            /// Read ctor
            /// </summary>
            internal Configuration(ResReader reader)
            {
                var size = reader.ReadInt32();

                data = reader.ReadByteArray(size - 4);
            }