I have some code I would like to simplify.
Here is the code:
private int id;
public int Id
{
get { return id; }
set
{
id = value;
base.OnPropertyChanged("Id");
}
}
I was thinking using an Attribute to only get:
[RaiseOnPropertyChanged()]
public int Id { get; set; }
How can that be done? Or can it be done using an attribute?
Alas, you can’t do that within the confines of C# itself; you’ll need to manipulate things at the IL level to get what you want. However, you can use aspect-oriented techniques like that provided by PostSharp to get the desired result.