private static async Task MakeInvertRequestAsync <T>(Inverter <Box <T> > .InverterClient client, params T[] requests) { Console.WriteLine($"Starting Invert for type {typeof(T).Name}."); using (var clientStream = client.InvertAsync()) { foreach (var request in requests) { await clientStream.RequestStream.WriteAsync(Message.From(Box.Create(request))); if (await clientStream.ResponseStream.MoveNext()) { var result = clientStream.ResponseStream.Current.Payload.Deserialize().value; Console.WriteLine($"{request} inverted is {result}"); } else { throw new Exception($"Unexpected end of response stream after request {request}"); } } } Console.WriteLine($"Invert for type {typeof(T).Name} done."); Console.WriteLine(); }