In the classes whose instances I save using the database of objects, I have to do this:
private string _name; public string Name { get { return this._name; } set { _name = value; this.Save(); } }
whereas I would rather print this:
[PersistedProperty(Name)] private string _name;
where the PersistedProperty attributes generate the Getter and Setter in the same way as the default [Property ()] attribute, except that I want to add a line of code to the generated Setter.
Is there a way to create an attribute that does this? Hope that works with Intellisense.
How does the default attribute [Property ()] even do this? If I saw the code, I could transform it ...
Note: I actually do this in Boo, but I thought I would give C # code, as more and more people can answer this, however, if there is a specific Boo solution, I'm all ears!
Update:
My goal was just to cut down on typing and get in the way. Turns out the easiest way to do this was with a script that generates partial classes based on the markup in my classes.
The self-generating source code from markup (in tandem with partial classes) is simple and actually looks like a very promising way to get around some problems that we usually try to solve with the help of inheritance and general types.
source share