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

Support Typed models #108

Closed Ron-Brouwer closed 7 years ago

Ron-Brouwer commented 7 years ago

Nice addition for Nested Content Property Value Converter: PublishedContentModelFactoryResolver.Current.Factory.CreateModel(value) That will also solve the issue with multiple types in one nested content

leekelleher commented 7 years ago

Thanks @Ron-Brouwer. It would be great to see an example of how this could be implemented. Since I don't use the ModelsBuilder feature, I'm curious if there'd be any impact in calling the CreateModel method?

Ron-Brouwer commented 7 years ago

Hi @leekelleher,

There is almost no impact if you check for a used factory. All the factory does is invoke a constructor which is already cached in a dictionary: Func<IPublishedContent, IPublishedContent> constructor; return _constructors.TryGetValue(contentTypeAlias, out constructor) ? constructor(content) : content;

I've implemented it for you in a pull request: "Call the model factory to support typed models when used." https://github.com/umco/umbraco-nested-content/pull/110

Hope you'll use it.

leekelleher commented 7 years ago

Thanks @Ron-Brouwer - we'll review the PR, (I've had a quick look, seems good 👍).

I'll close this issue, we can have any follow-up on PR #110.