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 AttribEntry[optionalDataColumns.Count]; _types = Collection.Class.BaseFields.Select(f => f.TypeName) .Concat(optionalDataColumns.Select(c => Collection.Class[c.Key].TypeName)) .Select(s => VLT32Hasher.Hash(s)).Distinct().ToArray(); for (var index = 0; index < optionalDataColumns.Count; index++) { var optionalDataColumn = optionalDataColumns[index]; var entry = new AttribEntry(Collection); entry.Key = VLT32Hasher.Hash(optionalDataColumn.Key); var vltClassField = Collection.Class[optionalDataColumn.Key]; entry.TypeIndex = (ushort)Array.IndexOf(_types, VLT32Hasher.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; } }
public override void Read(Vault vault, BinaryReader br) { var mKey = br.ReadUInt32(); // 4 var mClass = br.ReadUInt32(); // 8 var mParent = br.ReadUInt32(); // 12 var mTableReserve = br.ReadUInt32(); // 16 br.ReadUInt32(); // 20 var mNumEntries = br.ReadUInt32(); // 24 var mNumTypes = br.ReadUInt32(); // 28 _layoutPointer = br.ReadPointer(); // 32 Debug.Assert(mTableReserve == mNumEntries); Collection = new VltCollection(vault, vault.Database.FindClass(HashManager.ResolveVLT(mClass)), HashManager.ResolveVLT(mKey)); _types = new uint[mNumTypes]; for (var i = 0; i < mNumTypes; i++) { _types[i] = (br.ReadUInt32()); } _entries = new AttribEntry[mNumEntries]; for (var i = 0; i < mNumEntries; i++) { var attribEntry = new AttribEntry(Collection); attribEntry.Read(vault, br); _entries[i] = attribEntry; } // TODO: ParentKey //Collection.ParentKey = mParent; ParentKey = HashManager.ResolveVLT(mParent); vault.Database.RowManager.AddCollection(Collection); }