public static Task <TResponse?> ReadMessageAsync <TResponse>( Stream responseStream, //ILogger logger, Func <DeserializationContext, TResponse> deserializer, string grpcEncoding, int?maximumMessageSize, Dictionary <string, ICompressionProvider> compressionProviders, bool singleMessage, CancellationToken cancellationToken) where TResponse : class { var tempChannel = GrpcChannel.ForAddress("http://localhost", new GrpcChannelOptions { MaxReceiveMessageSize = maximumMessageSize, CompressionProviders = compressionProviders?.Values.ToList(), HttpHandler = new NullHttpHandler() }); var tempCall = new TestGrpcCall(new CallOptions(), tempChannel, typeof(TResponse)); var task = responseStream.ReadMessageAsync(tempCall, deserializer, grpcEncoding, singleMessage, cancellationToken); #if !NET472 return(task.AsTask()); #else return(task); #endif }
private GrpcCallSerializationContext CreateSerializationContext(string?requestGrpcEncoding = null, int?maxSendMessageSize = null) { var channelOptions = new GrpcChannelOptions(); channelOptions.MaxSendMessageSize = maxSendMessageSize; var call = new TestGrpcCall(new CallOptions(), GrpcChannel.ForAddress("http://localhost", channelOptions)); call.RequestGrpcEncoding = requestGrpcEncoding ?? "identity"; return(new GrpcCallSerializationContext(call)); }