/// <summary> /// Deserializes the request, resolve the <see cref="IRouteRequestHandler{TRequest, TResponse}"/>, then writes the response /// </summary> /// <param name="mediaHandler">Media handler for the request</param> /// <param name="context">request context</param> /// <returns>the awaitable task representing the routing operation</returns> public async Task Send(IMediaTypeHandler mediaHandler, IRequestContext context) { var req = await mediaHandler.Read <TRequest>(context); var handler = context.GetService <IRouteRequestHandler <TRequest, TResponse> >(); var resp = await handler.Handle(req, context.CancellationToken); await mediaHandler.Write(context, resp); }
private static void TestWriteMultiple(IMediaTypeHandler handler) { string actual; using (var stream = new StringBuilderStream()) { handler.Write<IEnumerable<Customer>>(TestData.MultipleContent, stream).Wait(); actual = stream.StringValue; } if (actual == null) { throw new Exception("No Output!"); } }
private static void TestWriteMultiple(IMediaTypeHandler handler) { string actual; using (var stream = new StringBuilderStream()) { handler.Write <IEnumerable <Customer> >(TestData.MultipleContent, stream).Wait(); actual = stream.StringValue; } if (actual == null) { throw new Exception("No Output!"); } }