/// <summary> /// Render a property viewer. /// </summary> /// <param name="helper">A html helper.</param> /// <param name="entity">Entity object.</param> /// <param name="property">Property metadata.</param> /// <param name="value">Property value.</param> public static MvcHtmlString Viewer(this HtmlHelper helper, IEntity entity, IPropertyMetadata property, object value) { if (helper == null) { throw new ArgumentNullException("helper"); } if (entity == null) { throw new ArgumentNullException("entity"); } if (property == null) { throw new ArgumentNullException("property"); } MvcEditorModel model = new MvcEditorModel(); model.Metadata = property; model.Value = value; model.Entity = entity; if (property.Type == CustomDataType.Other) { return(helper.Partial(property.CustomType + "Viewer", model)); } else { return(helper.Partial(property.Type.ToString() + "Viewer", model)); } }
/// <summary> /// Render a property editor. /// </summary> /// <param name="helper">A htmlhelper.</param> /// <param name="property">Property metadata.</param> /// <param name="value">Property value.</param> public static void Editor(this HtmlHelper helper, PropertyMetadata property, object value) { if (helper == null) { throw new ArgumentNullException("helper"); } if (property == null) { throw new ArgumentNullException("property"); } MvcEditorModel model = new MvcEditorModel(); model.Metadata = property; model.Value = value; if (property.Type == CustomDataType.Other) { System.Web.Mvc.Html.RenderPartialExtensions.RenderPartial(helper, property.CustomType + "Editor", model); } else { System.Web.Mvc.Html.RenderPartialExtensions.RenderPartial(helper, property.Type.ToString() + "Editor", model); } }