How to create duplicate allowed attributes

前端 未结 6 1795
旧巷少年郎
旧巷少年郎 2021-02-02 04:58

I\'m using a custom attribute inherited from an attribute class. I\'m using it like this:

[MyCustomAttribute(\"CONTROL\")]
[MyCustomAttribute(\"ALT\")]
[MyCustom         


        
6条回答
  •  一向
    一向 (楼主)
    2021-02-02 05:25

    As an alternative, think about redesigning your attribute to allow for a sequence.

    [MyCustomAttribute(Sequence="CONTROL,ALT,SHIFT,D")]
    

    or

    [MyCustomAttribute("CONTROL-ALT-SHIFT-D")]
    

    then parse the values to configure your attribute.

    For an example of this check out the AuthorizeAttribute in ASP.NET MVC source code at www.codeplex.com/aspnet.

提交回复
热议问题