public override Task <DiscordGetServersTableReply> GetDiscordServersTable(DiscordGetServersTableRequest request, ServerCallContext context) { Type discordContextServerType = typeof(DiscordContext.Server); PropertyInfo[] fields = discordContextServerType.GetProperties(); ConsoleTable table = new ConsoleTable(fields.Select(f => f.Name).ToArray()); foreach (DiscordContext.Server contextServer in Servers.DbSet) { table.AddRow(fields.Select(f => f.GetValue(contextServer)).ToArray()); } DiscordGetServersTableReply reply = new DiscordGetServersTableReply() { Table = table.ToString() }; return(Task.FromResult(reply)); }
public static void GetServersTable() { DiscordGetServersTableReply reply = Client.GetDiscordServersTable(new DiscordGetServersTableRequest()); Console.WriteLine(reply.Table); }