Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I need to get the type of a macro parameter. To do so I neeed to get / create a MacroModel. Below the code I'am using for this:
var macro = umbraco.cms.businesslogic.macro.Macro.GetById(Model.MacroId);
var model = new umbraco.cms.businesslogic.macro.MacroModel(macro);
//for example: model.Properties.First().Type
//and map the values to the collection aswell
var source = Model.MacroParameters.Join(model.Properties,
mod => mod.Key, mm => mm.Key,
(mod, mm) => new umbraco.cms.businesslogic.macro.MacroPropertyModel(mod.Key, mod.Value.ToString(), mm.Type, mm.CLRType));
This doesn't feel right, especially because the "PartialViewMacroController" returns a "PartialViewMacroModel" instead of the "MacroModel".
See the source of the PartialViewMacroController
So, why do I need the Type? I need this because I like to create value converters for the parameters for which the implementation can be used in all macropartials. For example when the type is "contentPicker" I like to return a IPublishedContent..
//something like, or something similar
public string Convert(MacroPropertyModel value)
Is there another way to get the type? Or maybe there is a way to create value converters for MacroParameters?
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted