コード例 #1
0
        public static TypeMember InvalidModelAutoResponderAttribute() =>
        PUBLIC.CLASS("InvalidModelAutoResponderAttribute", () => {
            EXTENDS <ActionFilterAttribute>();

            PUBLIC.OVERRIDE.VOID("OnActionExecuting", () => {
                PARAMETER <ActionExecutingContext>("context", out MethodParameter @context);

                DO.IF(NOT(context.DOT("ModelState").DOT("Valid"))).THEN(() => {
                    @context.DOT("Result").ASSIGN(NEW <BadRequestObjectResult>(@context.DOT("ModelState")));
                });
            });
        });