示例#1
0
        public static void UsingMessageFormatter <T>(this IHandledFormatters formatter, T response)
        {
            Task Formatter(Exception x, HttpContext c, HandlerContext b)
            {
                c.Response.ContentType = null;
                c.WriteAsyncObject(response);
                return(Task.CompletedTask);
            }

            formatter.UsingMessageFormatter(Formatter);
        }
        public static void UsingMessageFormatter <T, TException>(this IHandledFormatters <TException> formatter, Func <TException, HttpContext, HandlerContext, T> f) where TException : Exception
        {
            Task Formatter(Exception e, HttpContext c, HandlerContext b)
            {
                c.Response.ContentType = null;
                c.WriteAsyncObject(f((TException)e, c, b));
                return(Task.CompletedTask);
            }

            formatter.WithBody(Formatter);
        }
        public static void WithBody <T, TException>(this IHandledFormatters <TException> formatter, T response) where TException : Exception
        {
            Task Formatter(Exception x, HttpContext c, HandlerContext b)
            {
                c.Response.ContentType = null;
                c.WriteAsyncObject(response);
                return(Task.CompletedTask);
            }

            formatter.WithBody(Formatter);
        }
 public static void UsingMessageFormatter <T, TException>(this IHandledFormatters <TException> formatter, Func <Exception, T> f) where TException : Exception
 => WithBody(formatter, f);
 public static void UsingMessageFormatter <T, TException>(this IHandledFormatters <TException> formatter, T response) where TException : Exception
 => WithBody(formatter, response);