public void ProcessCommand(CommandGetMetadata command, CtpNetStream encoder) { var repository = m_repository; if (repository.ContainsTable(command.Table)) { var table = repository[command.Table]; var columns = new List <MetadataColumn>(); var columnIndexes = new List <int>(); if (command.Columns == null || command.Columns.Count == 0) { columns.AddRange(table.Columns); for (int x = 0; x < columns.Count; x++) { columnIndexes.Add(x); } } else { foreach (var column in command.Columns) { var c = table.Columns.FindIndex(x => x.Name == column); if (c < 0) { encoder.Send(new CommandMetadataRequestFailed("Syntax Error", "Could not find the specified column " + column)); return; } columnIndexes.Add(c); columns.Add(table.Columns[c]); } } byte channelID = 1; int rowCount = 0; var rowEncoder = new MetadataRowEncoder(columns); CtpObject[] values = new CtpObject[columns.Count]; encoder.Send(new CommandBeginMetadataResponse(channelID, Guid.Empty, repository.RuntimeID, repository.VersionNumber, command.Table, columns)); foreach (var row in table.Rows) { for (int x = 0; x < values.Length; x++) { values[x] = row.Fields[columnIndexes[x]]; } rowEncoder.AddRow(values); if (rowEncoder.Size > 30000) { throw new NotImplementedException(); //encoder.SendRaw(rowEncoder.ToArray(), channelID); rowEncoder.Clear(); } rowCount++; } if (rowEncoder.Size > 0) { throw new NotImplementedException(); //encoder.SendRaw(rowEncoder.ToArray(), channelID); rowEncoder.Clear(); } encoder.Send(new CommandEndMetadataResponse(channelID, rowCount)); } else { encoder.Send(new CommandMetadataRequestFailed("Syntax Error", "Could not find the specified table " + command.Table)); } }