我正在try 为ComponentModel DataAnnotation编写一个c#MinimalApi Endpoint过滤器验证器.我所拥有的是在传递要验证的类型时工作得很好,但我正在try 使从InvocationContext的[FromBody]属性中拉出类型变得更通用一些.下面是我的最大努力,但示例调用返回空值:
var fromBody = invocationContext.Arguments
.Where(w => Attribute.GetCustomAttribute(w.GetType(), typeof(FromBodyAttribute)) is not null);
我不确定这是否可能,但如果有任何建议,我会很高兴.