Extension of all model types

Topics: Extensibility, Getting Started
Oct 10, 2012 at 1:05 PM

I have some additional features I want to add to all view models in my project (like an IDataErrorInfo implementation, for example), but I'm not sure what the typical CM way of doing this would be.

Based on the documentation, it seems that my view models will typically inherit from screen if they need activation logic, or just PropertyChangedBase if it's simpler.  And a few might inherit from Conductor<IScreen>.Collection.???Active

So how do I extend all these types without repeating all my code four times?  Conceptually, what I'm really looking to do is insert some code just above PropertyChangedBase in the inheritance hierarchy so that my VMs can inherit from that, or any of the Screen/Conductor classes and have the capabilities.

How is this typically done in a CM app?  Right now the only thing I can think of is creating a MyPropertyChangedBase class, and a MyScreen and a MyConductorOneActive class, and a MyConductorAllActive class, and then repeat my logic in each one.  Obviously, that has a lot of code smell.  :-)

Thanks,

Oct 11, 2012 at 7:54 AM

+1! I am using the same code in 4 screen classes (Screen, Conductor, -OneActive, -AllActive). Hardly DRY.