Change Serialization of Property by an Attribute

Is it possible to create an attribute that customize the serialization of a property?

This is the example:

public class SimpleDto
{
    [SerializationAttribute()]
    public string Prop1 { get; set; }

    public string Prop2 { get; set; }
}

Then I want to apply a function on Prop1 during the serialization process, based on a external condition.

Can I do this?
Thanks.

No custom behaviour possible at the property level only customizable per type.

1 Like