In my wpf app, I have a ModelBase class that all my models inherit from, that inherits IDataErrorInfo. I also have methods that map all of my models back to a DataSet type, as the database is behind a webservice, and requires datasets to work with.
For my mappings, I created an attribute MappingIgnoreAttribute to force it to ignore the properties not required for the model (e.g. the IDataErrorInfo properties). For example:
[MappingIgnore]
public string Error
{
get { ... }
set { ... }
}
This works great, but I have a problem with the indexer created for the class by IDataErrorInfo:
[MappingIgnore]
public string this[string propertyName]
{
get { ... }
}
I've just learned that the compiler creates a property Item for a class with an indexer. Now, when I loop through my properties to map them, it's breaking on the property Item, as it's not marked MappingIgnore. Is there a way to attribute that compiler created property, or am I simply required to hardcode my mapping layer to ignore the property Item?
Hard-coding it would not be ideal, as this layer will be re-used by many teams within my company, who should certainly be able to have a property Item on their models.
Thanks for any guidance.
Aucun commentaire:
Enregistrer un commentaire