pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/feast107/RequestMapper

hub.githubassets.com/assets/primer-70be7debc79a8eff.css" /> GitHub - feast107/RequestMapper: Auto map model from request by attribute · GitHub
Skip to content

feast107/RequestMapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RequestMapper

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

Effect

Start

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

    [FromQuery]
    public class Model 
    {
        public string Id { get; set; }
        public string? Name { get; init; }
    
        [FromForm]
        public IFormFile Logo { get; init; }
        [FromForm]
        public IReadOnlyList<IFormFile> Pictures { get; init; }
    }

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

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

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

    var model = new Model();
    var newModel = RequestMappper.Generate(this.Request);
    model.Map(this.Request);

Preview

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

About

Auto map model from request by attribute

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy