Esempio n. 1
0
        public T Get <T>() where T : BinaryModelBase
        {
            var id     = typeof(T).GetAttribute <XexHeaderAttribute>().Id;
            var header = OptionalHeaders.Single(h => h.Id == id);
            var offset = (int)header.Data;

            return(ModelFactory.GetModel <T>(Binary, offset));
        }
Esempio n. 2
0
        public List <T> GetList <T>() where T : BinaryModelBase
        {
            var id          = typeof(T).GetAttribute <XexHeaderAttribute>().Id;
            var header      = OptionalHeaders.Single(h => h.Id == id);
            var offset      = (int)header.Data;
            var length      = Binary.ReadInt(offset, EndianType.BigEndian);
            var i           = offset + 4;
            var list        = new List <T>();
            var offsetTable = ModelFactory.GetOffsetTable(typeof(T));
            var last        = offset + 4 + length;

            while (i + offsetTable.Size < last)
            {
                list.Add(ModelFactory.GetModel <T>(Binary, i));
                i += offsetTable.Size;
            }
            return(list);
        }