Ejemplo n.º 1
0
        public virtual object Apply(IPublishedElement element, UmbracoMappingContext context)
        {
            var item = element.ToElement <M>();

            var output = mapper.Map <V>(item, context.Items);

            return(output);
        }
        public object Apply(IPublishedElement content, IPublishedElement settings, string modifierClass = null)
        {
            var contentModel = content.ToElement <M>();

            if (contentModel != null)
            {
                var output = mapper.Map <V>(contentModel);
                return(output);
            }
            else
            {
                return(null);
            }
        }
        public object Apply(PositionalContentModel model, IPublishedElement content, IPublishedElement settings)
        {
            var contentModel = content.ToElement <M>();

            if (contentModel != null)
            {
                var output = mapper.Map <V>(contentModel);
                return(output);
            }
            else
            {
                return(null);
            }
        }
        public virtual object CreateVm(IPublishedElement model, IDictionary <string, object> contextItems, dynamic config = null)
        {
            var item = model.ToElement <M>();

            var output = typeFactoryRunner.Run <V>(contextItems);

            if (output == null)
            {
                output = mapper.Map <V>(model, contextItems);
            }

            if (config != null && typeof(V).GetProperty("Config") != null)
            {
                typeof(V).GetProperty("Config").SetValue(output, config);
            }
            return(output);
        }
 protected BaseElementViewModel(IPublishedElement content)
 {
     Element = content.ToElement <TElement>();
 }