Ejemplo n.º 1
0
        public override void Prepare(Vault vault)
        {
            List <KeyValuePair <string, VLTBaseType> > optionalDataColumns = (from pair in Collection.GetData()
                                                                              where !Collection.Class[pair.Key].IsInLayout
                                                                              select pair).ToList();

            _entries = new AttribEntry64[optionalDataColumns.Count];
            _types   = Collection.Class.BaseFields.Select(f => f.TypeName)
                       .Concat(optionalDataColumns.Select(c => Collection.Class[c.Key].TypeName))
                       .Select(s => VLT64Hasher.Hash(s)).Distinct().ToArray();

            for (var index = 0; index < optionalDataColumns.Count; index++)
            {
                var optionalDataColumn = optionalDataColumns[index];
                var entry = new AttribEntry64(Collection);

                entry.Key = VLT64Hasher.Hash(optionalDataColumn.Key);
                var vltClassField = Collection.Class[optionalDataColumn.Key];
                entry.TypeIndex = (ushort)Array.IndexOf(_types,
                                                        VLT64Hasher.Hash(vltClassField.TypeName));
                entry.NodeFlags = NodeFlagsEnum.Default;

                if (entry.IsInline())
                {
                    entry.InlineData = optionalDataColumn.Value;
                    entry.NodeFlags |= NodeFlagsEnum.IsInline;
                }
                else
                {
                    entry.InlineData = new VLTAttribType(Collection.Class, vltClassField, Collection)
                    {
                        Data = optionalDataColumn.Value
                    };
                }

                if (vltClassField.IsArray)
                {
                    entry.NodeFlags |= NodeFlagsEnum.IsArray;
                }

                _entries[index] = entry;
            }
        }
Ejemplo n.º 2
0
        public override void Read(Vault vault, BinaryReader br)
        {
            var mKey          = br.ReadUInt64();
            var mClass        = br.ReadUInt64();
            var mParent       = br.ReadUInt64();
            var mTableReserve = br.ReadUInt32();

            br.ReadUInt32();
            var mNumEntries = br.ReadUInt32();
            var mNumTypes   = br.ReadUInt32();

            _layoutPointer = br.ReadPointer();

            // NOTE: This is an artifact of structure alignment.
            br.ReadInt32();

            Debug.Assert(mTableReserve == mNumEntries);

            Collection = new VltCollection(vault, vault.Database.FindClass(HashManager.ResolveVLT(mClass)), HashManager.ResolveVLT(mKey));

            _types = new ulong[mNumTypes];
            for (var i = 0; i < mNumTypes; i++)
            {
                _types[i] = (br.ReadUInt64());
            }

            _entries = new AttribEntry64[mNumEntries];

            for (var i = 0; i < mNumEntries; i++)
            {
                var attribEntry = new AttribEntry64(Collection);
                attribEntry.Read(vault, br);
                _entries[i] = attribEntry;
            }

            // TODO: ParentKey
            //Collection.ParentKey = mParent;
            ParentKey = HashManager.ResolveVLT(mParent);
            vault.Database.RowManager.AddCollection(Collection);
        }