2013-08-20 11:33:41 +10:00
|
|
|
|
using System;
|
|
|
|
|
|
using AutoMapper;
|
2013-08-12 15:06:12 +02:00
|
|
|
|
using Umbraco.Core;
|
|
|
|
|
|
using Umbraco.Core.Models;
|
|
|
|
|
|
using Umbraco.Core.Models.Mapping;
|
2013-08-20 11:33:41 +10:00
|
|
|
|
using Umbraco.Core.Services;
|
2013-08-12 15:06:12 +02:00
|
|
|
|
using Umbraco.Web.Models.ContentEditing;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Web.Models.Mapping
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 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
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
internal class ContentPropertyModelMapper : MapperConfiguration
|
|
|
|
|
|
{
|
|
|
|
|
|
public override void ConfigureMappings(IConfiguration config, ApplicationContext applicationContext)
|
|
|
|
|
|
{
|
2013-08-20 11:33:41 +10:00
|
|
|
|
var lazyDataTypeService = new Lazy<IDataTypeService>(() => applicationContext.Services.DataTypeService);
|
|
|
|
|
|
|
2013-08-12 15:06:12 +02:00
|
|
|
|
//FROM Property TO ContentPropertyBasic
|
|
|
|
|
|
config.CreateMap<PropertyGroup, Tab<ContentPropertyDisplay>>()
|
2014-04-14 15:20:02 +10:00
|
|
|
|
.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());
|
2013-08-12 15:06:12 +02:00
|
|
|
|
|
|
|
|
|
|
//FROM Property TO ContentPropertyBasic
|
|
|
|
|
|
config.CreateMap<Property, ContentPropertyBasic>()
|
2013-11-19 11:51:01 +11:00
|
|
|
|
.ConvertUsing(new ContentPropertyBasicConverter<ContentPropertyBasic>(lazyDataTypeService));
|
2013-08-12 15:06:12 +02:00
|
|
|
|
|
|
|
|
|
|
//FROM Property TO ContentPropertyDto
|
|
|
|
|
|
config.CreateMap<Property, ContentPropertyDto>()
|
2013-08-20 11:33:41 +10:00
|
|
|
|
.ConvertUsing(new ContentPropertyDtoConverter(lazyDataTypeService));
|
2013-08-12 15:06:12 +02:00
|
|
|
|
|
|
|
|
|
|
//FROM Property TO ContentPropertyDisplay
|
|
|
|
|
|
config.CreateMap<Property, ContentPropertyDisplay>()
|
2013-08-20 11:33:41 +10:00
|
|
|
|
.ConvertUsing(new ContentPropertyDisplayConverter(lazyDataTypeService));
|
2013-08-12 15:06:12 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2013-07-25 16:08:18 +10:00
|
|
|
|
}
|