Exemplo n.º 1
0
        public List <BlockHeaderEntity> FromMemory(Stream stream)
        {
            var reader = new BinaryReader(stream);
            var mapper = new BlendAddressMapper(BinaryUtil.ReadBytesFromStream(stream));

            var context = new ReadValueContext()
            {
                reader = reader, mapper = mapper
            };
            var declList = _ReadDna1Block(context);

            //var sortedDeclList = _SortByTypeDependency(declList);

            // before create member type, register a parent type
            foreach (var decl in declList)
            {
                var parentType = BlendStructureType.CreateImperfect(decl.name, decl.sdnaIndex);
                m_repository.Add(parentType);
            }

            // build member decls and set to parent
            foreach (var decl in declList)
            {
                var parentType = (BlendStructureType)m_repository.Find(decl.name);

                int fieldCount  = decl.fieldNames.Length;
                var memberDecls = new BlendStructureType.MemberDecl[fieldCount];
                for (int fieldIndex = 0; fieldIndex < fieldCount; ++fieldIndex)
                {
                    string type = decl.fieldTypes[fieldIndex];
                    string name = decl.fieldNames[fieldIndex];
                    int    tLen = decl.fieldLengths[fieldIndex];

                    var typeObj = m_repository.Find(type);
                    if (typeObj == null)
                    {
                        typeObj = new UnknownBlendType(type + " " + "name", tLen);
                    }

                    memberDecls[fieldIndex] = _ParseType(typeObj, name, tLen);
                }

                // set member decls
                parentType.SetMemberDecls(memberDecls);
            }

            stream.Seek(0, SeekOrigin.Begin);
            return(_CreateEntityList(context, m_repository));
        }
Exemplo n.º 2
0
 public BlendAddress(ulong address, BlendAddressMapper mapper)
 {
     m_address = address;
     m_mapper  = mapper;
 }