Skip to content

Repository files navigation

RequestMapper

通过注解自动映射到实例的类库,适用于请求结构复杂,传统的参数注解无法映射的情况

Effect

Start

  • 在需要映射的模型上添加注解,内置提供了一部分,他们在命名空间 Feast.RequestMapper.Attribute

    [FromQuery]publicclassModel{publicstringId{get;set;}publicstring?Name{get;init;}[FromForm]publicIFormFileLogo{get;init;}[FromForm]publicIReadOnlyList<IFormFile>Pictures{get;init;}}

    class 上添加的注解会自动应用到全部的 property ,在 property 上添加的注解会优先于 class 上的注解

  • 如果需要使用自定义注解或者内置注解,可以通过注册

    RequestMapper.RegisterAttribute<YourAttribute>(Registry.AsYourWish);
  • 通过请求的报文来生成

    varmodel=newModel();varnewModel=RequestMappper.Generate(this.Request);model.Map(this.Request);

Preview

  • 🚧 映射处理系统(真的需要吗)

About

Auto map model from request by attribute

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages