'How to use annotation to change the behavior of a get/set?

I think the first question here is "It`s possible to change set/get behavior from a property using the annotation attached to it?"

I'm trying to automate a dictionary where when a property in the object is changed he will change the dictionary as well

This is an example from what I`m trying to do

public class Example : Dictionary<string, object> {

    public string Name { get => this["Name"].ToString(); set => this["Name"] = value; }

}

Making this automated would be something like:

public class Example : Dictionary<string, object> {
    
    [Field] //or [Field="name"]
    public string Name { get; set; }

}

and the annotation "Field" will make the set and get work properly with the dictionary. Is it possible?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source