none
C# 自定义 Attribute 怎么添加描述,以使它在 webapi help 中显示出这个描述 RRS feed

  • Question

  • C# 自定义 Attribute 怎么添加描述,以使用它在 webapi help 中显示出这个描述

    显示在蓝框中。。

    /// <summary>/// 验证码/// </summary> [RequiredLy] publicstring verifyCode { getset; }

    /// <summary>/// 登录密码MD5,AES加密/// 新密码MD5,AES加密/// 先MD5再加密/// </summary> [RequiredLy("MemberLogin")] publicstring password { getset; }

    根据反编译到的代码加上了

    ///// <summary>///// 必须有值///// </summary>public RequiredLyAttribute():base(() => "RequiredLy") {     //AllowEmptyStrings = true; } /// <summary>/// /// </summary>/// <param name="name"></param>/// <returns></returns>publicoverridestring FormatErrorMessage(string name)         {             string str = "RequiredLy";             return name+ str;         }

    /// <summary>/// 动态请求状态/// linyee/// </summary> [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false)] publicclassRequiredLyAttribute : ValidationAttributeIDictionary<stringRequiredLinyeeAttribute>, ICustomTypeDescriptor

    尝试了多种方案,依然没有效果

    想要实现的效果就是自定义的特性,可以在Additional information一栏显示一些基本要求。。

    Required,显示Required,StringLength显示出长度要求。


    Wednesday, August 16, 2017 2:19 AM

Answers

  • Hi 灵易,

    This forum discusses and asks questions about the Visual Basic programming language, since your issue is more related to asp.net web API, I would suggest that you could post your issue on asp.net web api for suitable support.

    https://forums.asp.net/1246.aspx/1?Web+API

    Thanks for your understanding.

    In addition, since the forum is an English forum, I would suggest that you could post your issue in English, it will be beneficial to resolve the issue.

    Best regards,

    Cole


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, August 16, 2017 7:34 AM

All replies

  • Hi 灵易,

    This forum discusses and asks questions about the Visual Basic programming language, since your issue is more related to asp.net web API, I would suggest that you could post your issue on asp.net web api for suitable support.

    https://forums.asp.net/1246.aspx/1?Web+API

    Thanks for your understanding.

    In addition, since the forum is an English forum, I would suggest that you could post your issue in English, it will be beneficial to resolve the issue.

    Best regards,

    Cole


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, August 16, 2017 7:34 AM
  • 已经解决,
    Saturday, August 19, 2017 12:19 AM