How to get and modify a property value through a custom Attribute?

后端 未结 4 1600
遇见更好的自我
遇见更好的自我 2020-12-06 10:18

I want to create a custom attribute that can be used on a property like:

[TrimInputString]
public string FirstName { get; set; }

that will

4条回答
  •  情深已故
    2020-12-06 10:38

    As Matti pointed out, this is not how attributes work. However, you could use the PostSharp AOP framework to accomplish this, probably overriding OnMethodBoundaryAspect. But this is not trivial.

提交回复
热议问题