public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { if (reader.TokenType == JsonToken.Null) { return(null); } var tempDictionary = new Dictionary <string, object>(); serializer.Populate(reader, tempDictionary); // Make sure keys are in camelCase tempDictionary = tempDictionary .ToDictionary(x => Char.ToLowerInvariant(x.Key[0]) + x.Key.Substring(1), x => x.Value); var item = new MortarItem { Type = tempDictionary["type"].ToString(), RawValue = tempDictionary["value"], AdditionalInfo = tempDictionary .Where(x => x.Key != "type" && x.Key != "value") .ToDictionary(k => k.Key, v => v.Value.ToString()) }; return(item); }
public static HtmlString RenderMortarItem( this HtmlHelper helper, MortarRow row, MortarItem item, string viewPath = "", string actionName = "", object model = null) { if (item == null) { return(new HtmlString(string.Empty)); } if (!string.IsNullOrWhiteSpace(viewPath)) { viewPath = viewPath.TrimEnd('/') + "/"; } if (string.IsNullOrWhiteSpace(actionName)) { actionName = item.Value.DocumentTypeAlias; } var controllerName = string.Concat(item.Value.DocumentTypeAlias, "Surface"); var umbracoHelper = new UmbracoHelper(UmbracoContext.Current); if (umbracoHelper.SurfaceControllerExists(controllerName, actionName, true)) { return(helper.Action(actionName, controllerName, new { mortarModel = model ?? item.Value, mortarRow = row, mortarViewPath = viewPath })); } return(helper.Partial(viewPath + item.Value.DocumentTypeAlias, model ?? item.Value)); }
public RenderMortarItemViewModel(MortarRow row, MortarItem item, int index) { Index = index; Item = item; Row = row; }