private static FastAccessList <object> DeserializeReferenceTracking(BinaryReader input) { var bf = SerializationHelper.DefaultFormatter; var referenceTracking = new FastAccessList <object>(); var nbRef = input.ReadInt32(); for (var i = 0; i < nbRef; i++) { var tag = input.ReadInt32(); var type = SerializationHelper.TagToType[tag]; if (type == typeof(SqlVariable)) { referenceTracking.Add(SqlVariable.Deserialize(input)); } else if (type == typeof(TableMetadata)) { referenceTracking.Add(TableMetadata.Deserialize(input)); } else { referenceTracking.Add(bf.Deserialize(input.BaseStream)); } } return(referenceTracking); }
public static Metadatas Deserialize(BinaryReader stream, FastAccessList <object> referenceTracking = null) { var cTables = new Metadatas(); var nbServers = stream.ReadInt32(); for (var n = 0; n < nbServers; n++) { var serverId = stream.ReadString(); cTables.Add(serverId, new ServerMetadata()); var nbDatabases = stream.ReadInt32(); for (var j = 0; j < nbDatabases; j++) { var database = stream.ReadString(); cTables[serverId].Add(database, new DatabaseMetadata()); var nbSchemas = stream.ReadInt32(); for (var k = 0; k < nbSchemas; k++) { var schemaMetadata = new SchemaMetadata(); var schema = stream.ReadString(); var nbTablesFrom = stream.ReadInt32(); for (var l = 0; l < nbTablesFrom; l++) { TableMetadata table; if (referenceTracking == null) { table = TableMetadata.Deserialize(stream); } else { var id = stream.ReadInt32(); table = (TableMetadata)referenceTracking[id]; } schemaMetadata.Add(table); } cTables[serverId][database].Add(schema, schemaMetadata); } } } return(cTables); }