but I would love to know if it's possible to throw a custom PropertyEditorValueConvert (or whatever it's called) after it - and how I might do that without compiling DLLs etc. :)
Yes, ModelsBuilder return an object by default unless there exists a property value converter to handle the return type, where the strongly typed syntax (and ModelsBuilder) know the return type.
I could add a property value converter for this in the package as requested here https://github.com/bjarnef/Switcher/issues/6 but I find it a bit overkill the add another assembly just to handle this and when Umbraco core already have property value converters for this.
Using Switcher with ModelsBuilder
Hi,
I use Switcher all the time, but I find it weird that ModelsBuilder doesn't know that it's "just" an
int
(it registers asobject
- not even abool
).I usually do this to get the value:
but I would love to know if it's possible to throw a custom
PropertyEditorValueConvert
(or whatever it's called) after it - and how I might do that without compiling DLLs etc. :)/Chriztian
Hi Chriztain,
I have the code below, You can just added it your own solution. You can add it into App_Code folder if want but its not recommended :)
Matt
Thanks Matt - that one goes straight into my folder of good stuff :-)
/Chriztian
Hi Chriztian
Yes, ModelsBuilder return an
object
by default unless there exists a property value converter to handle the return type, where the strongly typed syntax (and ModelsBuilder) know the return type.I could add a property value converter for this in the package as requested here https://github.com/bjarnef/Switcher/issues/6 but I find it a bit overkill the add another assembly just to handle this and when Umbraco core already have property value converters for this.
I have created a issue here that it should be possible to re-use property value converters for simple types https://github.com/umbraco/Umbraco-CMS/issues/4419 (the original issue was created here https://issues.umbraco.org/issue/U4-10005)
/Bjarne
Awesome - thanks for the explanation Bjarne!
(I did think we'd discussed this earlier at a meetup :)
Totally agree on the overkill part, too.
/Chriztian
is working on a reply...