https://github.com/feast107/requestmapper
Auto map model from request by attribute
https://github.com/feast107/requestmapper
attribute-based automapper http-requests netstandard objectmapper
Last synced: about 2 months ago
JSON representation
Auto map model from request by attribute
- Host: GitHub
- URL: https://github.com/feast107/requestmapper
- Owner: feast107
- License: mit
- Created: 2023-03-09T05:53:48.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2023-05-14T07:18:21.000Z (almost 3 years ago)
- Last Synced: 2025-10-31T00:01:48.615Z (5 months ago)
- Topics: attribute-based, automapper, http-requests, netstandard, objectmapper
- Language: C#
- Homepage:
- Size: 82 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# RequestMapper
通过注解自动映射到实例的类库,适用于请求结构复杂,传统的参数注解无法映射的情况
## Effect

## Start
+ 在需要映射的模型上添加注解,内置提供了一部分,他们在命名空间 `Feast.RequestMapper.Attribute` 下
```CSharp
[FromQuery]
public class Model
{
public string Id { get; set; }
public string? Name { get; init; }
[FromForm]
public IFormFile Logo { get; init; }
[FromForm]
public IReadOnlyList Pictures { get; init; }
}
```
> 在 `class` 上添加的注解会自动应用到全部的 `property` ,在 `property` 上添加的注解会优先于 `class` 上的注解
+ 如果需要使用自定义注解或者内置注解,可以通过注册
```CSharp
RequestMapper.RegisterAttribute(Registry.AsYourWish);
```
+ 通过请求的报文来生成
```CSharp
var model = new Model();
var newModel = RequestMappper.Generate(this.Request);
model.Map(this.Request);
```
## Preview
+ :construction: 映射处理系统(真的需要吗)