Is it possible to use an attribute to modify a model value?
eg.
[TrimInput]
public string SomeName {get;set;}
public string TrimInputAttribute : Attribute
{
/// do something here?
}
Is it possible to use an attribute to modify a model value?
eg.
[TrimInput]
public string SomeName {get;set;}
public string TrimInputAttribute : Attribute
{
/// do something here?
}
Yes, it is - but you need something to EXECUTE it. Attributes never execute any code.
What you can do is having a "ModelFixer" class that has a method that you call - and that is evaluationg the attributes and doing the operations.
All other attributes work like that - there is always a component USING the attribute (which sometimes is the runtime or the compiler).