The problem i am trying to solve is that i want all properties for a given class to escape invalid characters depending on whether a given attribute has been applied.
Take following class:
public class MyClass
{
[EscapeInvalid]
public string Prop1 {get; set;}
public string Prop2 {get; set;}
}
Here is my defined attribute class
public class EscapeInvalidAttribute : Attribute
{
string escapedValue;
public string EscapedValue
{
get
{
return escapedValue;
}
set
{
escapedValue= Escape(value);
}
}
}
In a nutshell if the property for a given class has the [EscapeInvalid] applied i want to have the setter escape the value.
Is this possible?
I understand that i can just update each setter to apply the escape but was looking for a cleaner way to do this. Thanks in advance for any guidance.