Fixes: U4-4610 Unmapped members in Automapper

This commit is contained in:
Shannon
2014-04-14 15:20:02 +10:00
parent e3c4ed5bf7
commit 5990a95d13
11 changed files with 219 additions and 126 deletions

View File

@@ -22,29 +22,33 @@ namespace Umbraco.Web.Models.Mapping
config.CreateMap<IMacro, EntityBasic>()
.ForMember(entityBasic => entityBasic.Icon, expression => expression.UseValue("icon-settings-alt"))
.ForMember(dto => dto.ParentId, expression => expression.UseValue(-1))
.ForMember(dto => dto.Path, expression => expression.ResolveUsing(macro => "-1," + macro.Id));
.ForMember(dto => dto.Path, expression => expression.ResolveUsing(macro => "-1," + macro.Id))
.ForMember(dto => dto.AdditionalData, expression => expression.Ignore());
config.CreateMap<IMacro, IEnumerable<MacroParameter>>()
.ConvertUsing(macro => macro.Properties.Select(Mapper.Map<MacroParameter>).ToList());
config.CreateMap<IMacroProperty, MacroParameter>()
.AfterMap((property, parameter) =>
{
//map the view and the config
.ForMember(x => x.View, expression => expression.Ignore())
.ForMember(x => x.Configuration, expression => expression.Ignore())
.ForMember(x => x.Value, expression => expression.Ignore())
.AfterMap((property, parameter) =>
{
//map the view and the config
var paramEditor = ParameterEditorResolver.Current.GetByAlias(property.EditorAlias);
if (paramEditor == null)
{
//we'll just map this to a text box
paramEditor = ParameterEditorResolver.Current.GetByAlias(Constants.PropertyEditors.TextboxAlias);
LogHelper.Warn<MacroModelMapper>("Could not resolve a parameter editor with alias " + property.EditorAlias + ", a textbox will be rendered in it's place");
}
var paramEditor = ParameterEditorResolver.Current.GetByAlias(property.EditorAlias);
if (paramEditor == null)
{
//we'll just map this to a text box
paramEditor = ParameterEditorResolver.Current.GetByAlias(Constants.PropertyEditors.TextboxAlias);
LogHelper.Warn<MacroModelMapper>("Could not resolve a parameter editor with alias " + property.EditorAlias + ", a textbox will be rendered in it's place");
}
parameter.View = paramEditor.ValueEditor.View;
//set the config
parameter.Configuration = paramEditor.Configuration;
});
parameter.View = paramEditor.ValueEditor.View;
//set the config
parameter.Configuration = paramEditor.Configuration;
});
}