As part of my API, I have an abstract BaseEntity class. I would like to provide a way to somehow connect to the new properties that are introduced in the descendants of this class. I thought:
public class MyEntity : BaseEntity
{
[DataElement]
public int NewProperty { get; set; }
}
If I could write an attribute DataElementthat would connect to getter and setter, then my API would be notified of this property upon access.
Is it possible?
UPD: I will try to explain where it came from. I have this BaseEntity which has no data in itself. His descendants will declare what data they can store as properties. I want to be able to iterate all the data that an object has (in order to save them in a database in a very specific form). One way to do this is by reflection. But I was thinking about doing this using attributes that will log data whenever the resource is accessed.
source
share