I'am playing around with the modelsbuilder and have a question regarding the generation of the models. Is it possible to define which object is returned by a property. For some properties I like to have a different type of object or a more specific type. for example:
For example:
A relatedlinks type now returns a JArray, but I have my own propertyvalue converter. The contentpicker returns an object but I like to have a different more specific type.
What I did with my own models builder was give the programmer full control over which types are generated by using a dictionary (in a T4 template, but I could be an xml file, or an implemementation of a specific interface as well). Maybe this is an Idea for the modelsbuilder (if there is not jet another solution);
Are you guys saying that the modelsbuilder does look into the propertyvalueconverters about which object is returned and that one is used to build the model? Because that's not the case at my side.. Maybe I do something wrong here than (forgot a setting?)
Thanks guys, you hit me in the right direction. I wasn't aware of the IPropertyValueConverterMeta http://issues.umbraco.org/issue/U4-4716 which is needed by the modelsbuilder to define the return type.
Happy to see a solution was already available and that I just forgot something.
ModelsBuilder PropertyValueConverter
Hi,
I'am playing around with the modelsbuilder and have a question regarding the generation of the models. Is it possible to define which object is returned by a property. For some properties I like to have a different type of object or a more specific type. for example:
For example: A relatedlinks type now returns a JArray, but I have my own propertyvalue converter. The contentpicker returns an object but I like to have a different more specific type.
What I did with my own models builder was give the programmer full control over which types are generated by using a dictionary (in a T4 template, but I could be an xml file, or an implemementation of a specific interface as well). Maybe this is an Idea for the modelsbuilder (if there is not jet another solution);
Hi Jeroen,
You can install this one : https://github.com/Jeavon/Umbraco-Core-Property-Value-Converters/tree/v2/Our.Umbraco.PropertyConverters
This has a property value convertor for the related links datatype. Should use this convertor after installing the package and rebuilding your models.
Dave
If you don't like those Converters you can also write your own. I've done this for the Hybrid Framework: https://github.com/jbreuer/Hybrid-Framework-for-Umbraco-v7-Best-Practises/tree/master/Umbraco.Extensions/PropertyConverters
Are you guys saying that the modelsbuilder does look into the propertyvalueconverters about which object is returned and that one is used to build the model? Because that's not the case at my side.. Maybe I do something wrong here than (forgot a setting?)
Yes that should be the case.
Dave
Thanks guys, you hit me in the right direction. I wasn't aware of the IPropertyValueConverterMeta http://issues.umbraco.org/issue/U4-4716 which is needed by the modelsbuilder to define the return type.
Happy to see a solution was already available and that I just forgot something.
is working on a reply...