public static IHtmlString AmpHtml(this HtmlHelper htmlHelper, IDataItem dataItem, string fieldName, AmpComponentDto ampComponent) { //object fieldValue = ((IDynamicFieldsContainer)dataItem).GetValue(fieldName); object fieldValue = DataBinder.Eval(dataItem, fieldName); if (fieldValue is string || fieldValue is Lstring) { DynamicLinksParser dynamicLinksParser = new DynamicLinksParser(false); fieldValue = dynamicLinksParser.Apply(fieldValue.ToString()); } if (fieldValue == null || (fieldValue is IEnumerable<object> && !((IEnumerable<object>)fieldValue).Any())) { fieldValue = dataItem.GetRelatedItems(fieldName); } string ampHtml = string.Empty; if (ampComponent == null) { ampHtml = ampConverter.Value.ConvertFromHtml(fieldValue.ToString()); } else { var componentType = TypeResolutionService.ResolveType(ampComponent.ComponentType); var ampComponentGenerator = (IAmpComponent)Activator.CreateInstance(componentType); ampHtml = ampComponentGenerator.Generate(fieldValue); } return htmlHelper.Raw(ampHtml); }