umco / umbraco-nested-content

Nested Content for Umbraco 7.1 to 7.6
https://our.umbraco.org/projects/backoffice-extensions/nested-content
MIT License
45 stars 35 forks source link

Add support for .OfType<> and strongly typed models - #118 #124

Closed tompipe closed 7 years ago

tompipe commented 7 years ago

Updated the value converter to pass IPublishedContent through the model builder factory (if enabled), which will create strongly typed models. This will allow .OfType<> etc to work

Also implemented the IPropertyValueConverterMeta interface, which allows control over the return type, so for nested content properties where only one doctype is used as the blueprint, the converter will return the type for that strongly typed model, and models builder will use that when generating models

See https://github.com/umco/umbraco-nested-content/issues/118

leekelleher commented 7 years ago

@tompipe Thanks for the PR, it's very much appreciated! We'll review as soon as we can. 👍

tompipe commented 7 years ago

No probs - I had the code in one of my solutions anyway, I've just cleaned and adapted it to fit in with the NC converter.

Should probably caveat it, and say it probably needs testing in other solutions, with/without models builder - it works great for me here though :)

If you get a unit test project added, I'll add some tests when I get some time

leekelleher commented 7 years ago

Closing the PR, as the Umbraco core version of NC will natively support ModelBuilder / strongly-typed models for NC.

For the package version of NC, we have merged in PR #110 for the v0.5.0 release, which gives initial support for strongly-typed IPublishedContent models.