My current solution has the following setup:
This setup has been working fine for me until I had to add data validation to the WPF project. I must use IDataErrorInfo on the model. I'm a bit stuck since IDataErrorInfo isn't supported in a portable class library.
What I tried was adding a new model class with the same name to my WPF project for every model class in my portable class library and inherit from the class in my library. I could then add all the validation code in the subclass. Problem is of course that my WPF project uses the class library with my repositories, which return instances of my model base classes (from the portable class library). Casting every single occurence of a model class in my WPF project doesn't seem the way to go..
So my question is: could I somehow let the repositories class lib return different model objects depending on the project it's used in? (always the base ones, but the subclasses when used in the WPF project). (I do realize it's not the best idea to let the repositories lib know about my wpf project, but if that's what it takes I'm fine with that.)
If there are other ways to achieve my goal, please tell!
Sounds tricky. There are different solutions for that, that come to mind.
Make an interface for every model class you have.
Generate your classes/interfaces with T4
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With