Ejemplo n.º 1
0
        /// <summary>
        /// Renders both XPM Markup and Field Value for a multi-value field
        /// </summary>
        /// <typeparam name="TModel">Model type</typeparam>
        /// <typeparam name="TProp">Property type</typeparam>
        /// <typeparam name="TItem">Item type - this must match the generic type of the property type</typeparam>
        /// <param name="model">Model</param>
        /// <param name="propertyLambda">Lambda expression representing the property to render. This must be a direct property of the model.</param>
        /// <param name="item">The particular value of the multi-value field</param>
        /// <example>
        /// foreach (var content in model.Content)
        /// {
        ///     @model.XpmEditableField(m => m.Content, content);
        /// }
        /// </example>
        /// <returns>XPM Markup and field value</returns>
        public static HtmlString XpmEditableField <TModel, TProp, TItem>(this TModel model, Expression <Func <TModel, TProp> > propertyLambda, TItem item)
            where TModel : IViewModel
        {
            var renderer = new XpmRenderer <TModel>(model, XpmMarkupService, resolver);

            return(renderer.XpmEditableField(propertyLambda, item));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Renders the XPM Markup for a Component Presentation
        /// </summary>
        /// <param name="model">Model</param>
        /// <param name="region">Region</param>
        /// <returns>XPM Markup</returns>
        public static HtmlString StartXpmEditingZone(this IViewModel model, string region = null)
        {
            HtmlString result = null;

            if (model.ModelData is IComponentPresentation)
            {
                var renderer = new XpmRenderer <IViewModel>(model, XpmMarkupService, resolver);
                result = renderer.StartXpmEditingZone(region);
            }
            return(result);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Renders the XPM markup for a field
        /// </summary>
        /// <typeparam name="TModel">Model type</typeparam>
        /// <typeparam name="TProp">Property type</typeparam>
        /// <param name="model">Model</param>
        /// <param name="propertyLambda">Lambda expression representing the property to render. This must be a direct property of the model.</param>
        /// <param name="index">Optional index for a multi-value field</param>
        /// <returns>XPM Markup</returns>
        public static HtmlString XpmMarkupFor <TModel, TProp>(this TModel model, Expression <Func <TModel, TProp> > propertyLambda, int index = -1) where TModel : IViewModel
        {
            var renderer = new XpmRenderer <TModel>(model, XpmMarkupService, resolver);

            return(renderer.XpmMarkupFor(propertyLambda, index));
        }