Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

提供Req别名化的绑定支持 #1

Closed
vipwan opened this issue Sep 23, 2023 · 2 comments
Closed

提供Req别名化的绑定支持 #1

vipwan opened this issue Sep 23, 2023 · 2 comments

Comments

@vipwan
Copy link
Owner

vipwan commented Sep 23, 2023

    public class HelloApiRequest : BaseRequest<HelloApiRequest>
    {
        public string? Name { get; set; } = "default";

        /// <summary>
        /// 别名测试
        /// </summary>
        [AliasAs("a")]
        public string? Alias { get; set; }

        public HelloApiRequest()
        {
            RuleFor(x => x.Name).NotNull().Length(5, 10);
        }
    }

如果Req的属性配置的别名 级别为最高绑定特征

@vipwan
Copy link
Owner Author

vipwan commented Sep 23, 2023

    public class HelloApiResponse : BaseResponse
    {
        public string? Message { get; set; }

        /// <summary>
        /// 返回字段的别名测试
        /// </summary>
        ///[AliasAs("a")]
        [JsonPropertyName("a")]
        public string? Alias { get; set; }
    }

请注意Rsp也是支持标记AliasAs的, 但是我们强烈建议你使用**[JsonPropertyName]**特性, 因为AliasAs不支持多级属性和驼峰模式

@vipwan
Copy link
Owner Author

vipwan commented Oct 12, 2023

当前页提供对原生绑定特性的支持, 建议使用 [FromQuery] [FromRoute]标记 而不是 [AliasAs] #6

vipwan added a commit that referenced this issue May 9, 2024
vipwan added a commit that referenced this issue May 10, 2024
vipwan added a commit that referenced this issue May 11, 2024
新增了一个`EventExtensions.cs`文件,定义了一个`EventExtensions`静态类,该类中定义了一个`PublishAsync`扩展方法,该方法允许`IEvent`类型的对象直接调用`PublishAsync`方法进行事件发布。

相关工作项: #1
@vipwan vipwan closed this as not planned Won't fix, can't repro, duplicate, stale May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant