Closed leekelleher closed 7 years ago
@mattbrailsford - re: unit-test - I couldn't figure out how to unit-test the DittoView
class - guessing you hit the same problem (since there aren't any existing tests for it)?
Merging in. We can look at the unit-test later. Thanks for the quick turnaround @mattbrailsford #h5yr
Yea, that's when it starts to get confusing to me as your start bringing in web contexts etc
@mattbrailsford - I'd found an scenario a while back where if a
DittoView<T>
page referenced anotherDittoView<T>
page, but the view-model was castable, the code wouldn't cast it and Ditto would recreate the object.That might sound like a mouthful, but I'll try to explain...
Say you've got these POCOs...
If you had
DittoView<OtherModel>
on a page template, andDittoView<MasterModel>
on the layout template, the DittoView code would be creating the object twice, rather than downcasting it to the inherited type.This PR adds in a check to see if the model object is a
DittoViewModel<>
and to unwrap the inner view-model, so it can be reused.Hopefully this makes sense? (and is backwards compatible / a non-breaking change)