コード例 #1
0
ファイル: Route.cs プロジェクト: lanicon/PingPongr
        /// <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);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: muratbeyaztas/Simple.Web
 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!");
     }
 }
コード例 #3
0
        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!");
            }
        }