using System; using AutoMapper; using Umbraco.Core; using Umbraco.Core.Models; using Umbraco.Core.Models.Mapping; using Umbraco.Core.Services; using Umbraco.Web.Models.ContentEditing; namespace Umbraco.Web.Models.Mapping { /// /// A mapper which declares how to map content properties. These mappings are shared among media (and probably members) which is /// why they are in their own mapper /// internal class ContentPropertyModelMapper : MapperConfiguration { public override void ConfigureMappings(IConfiguration config, ApplicationContext applicationContext) { var lazyDataTypeService = new Lazy(() => applicationContext.Services.DataTypeService); //FROM Property TO ContentPropertyBasic config.CreateMap>() .ForMember(tab => tab.Label, expression => expression.MapFrom(@group => @group.Name)) .ForMember(tab => tab.IsActive, expression => expression.UseValue(true)) .ForMember(tab => tab.Properties, expression => expression.Ignore()) .ForMember(tab => tab.Alias, expression => expression.Ignore()); //FROM Property TO ContentPropertyBasic config.CreateMap() .ConvertUsing(new ContentPropertyBasicConverter(lazyDataTypeService)); //FROM Property TO ContentPropertyDto config.CreateMap() .ConvertUsing(new ContentPropertyDtoConverter(lazyDataTypeService)); //FROM Property TO ContentPropertyDisplay config.CreateMap() .ConvertUsing(new ContentPropertyDisplayConverter(lazyDataTypeService)); } } }