Beispiel #1
0
        private static async Task <object> PayloadFor(this HttpContext context, IRequestCommandHandler handler)
        {
            var payloadType = handler.GetType().GetInterfaces().Single(x => x.Name == typeof(IRequestCommandHandler <>).Name).GenericTypeArguments.Single();

            using var reader = new StreamReader(context.Request.Body);
            return((await reader.ReadToEndAsync()).Deserialize(payloadType));
        }
Beispiel #2
0
 private static async Task <HttpStatusCode> Execute(this IRequestCommandHandler handler, Request request, object payload)
 {
     return(await(handler.GetType().GetMethod("HandleAsync") !.Invoke(handler, System.Reflection.BindingFlags.DoNotWrapExceptions, null, new[] { request, payload }, null) as Task <HttpStatusCode>) !);
 }