2019-11-22 13:13:19 +11:00
|
|
|
|
using Umbraco.Core.Dictionary;
|
|
|
|
|
|
using Umbraco.Core.Logging;
|
2019-03-26 10:39:50 +01:00
|
|
|
|
using Umbraco.Core.Mapping;
|
2017-07-19 13:42:47 +02:00
|
|
|
|
using Umbraco.Core.Models;
|
2018-04-04 01:59:51 +10:00
|
|
|
|
using Umbraco.Core.PropertyEditors;
|
2017-07-19 13:42:47 +02:00
|
|
|
|
using Umbraco.Core.Services;
|
|
|
|
|
|
using Umbraco.Web.Models.ContentEditing;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Web.Models.Mapping
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
2017-07-20 11:21:28 +02:00
|
|
|
|
/// A mapper which declares how to map content properties. These mappings are shared among media (and probably members) which is
|
2017-07-19 13:42:47 +02:00
|
|
|
|
/// why they are in their own mapper
|
|
|
|
|
|
/// </summary>
|
2019-04-03 10:39:49 +02:00
|
|
|
|
internal class ContentPropertyMapDefinition : IMapDefinition
|
2017-07-19 13:42:47 +02:00
|
|
|
|
{
|
2019-03-26 10:39:50 +01:00
|
|
|
|
private readonly ContentPropertyBasicMapper<ContentPropertyBasic> _contentPropertyBasicConverter;
|
|
|
|
|
|
private readonly ContentPropertyDtoMapper _contentPropertyDtoConverter;
|
|
|
|
|
|
private readonly ContentPropertyDisplayMapper _contentPropertyDisplayMapper;
|
|
|
|
|
|
|
2019-11-22 13:13:19 +11:00
|
|
|
|
public ContentPropertyMapDefinition(ICultureDictionary cultureDictionary, IDataTypeService dataTypeService, IEntityService entityService, ILocalizedTextService textService, ILogger logger, PropertyEditorCollection propertyEditors)
|
2017-07-19 13:42:47 +02:00
|
|
|
|
{
|
2019-07-01 16:22:54 +10:00
|
|
|
|
_contentPropertyBasicConverter = new ContentPropertyBasicMapper<ContentPropertyBasic>(dataTypeService, entityService, logger, propertyEditors);
|
|
|
|
|
|
_contentPropertyDtoConverter = new ContentPropertyDtoMapper(dataTypeService, entityService, logger, propertyEditors);
|
2019-11-22 13:13:19 +11:00
|
|
|
|
_contentPropertyDisplayMapper = new ContentPropertyDisplayMapper(cultureDictionary, dataTypeService, entityService, textService, logger, propertyEditors);
|
2019-03-26 10:39:50 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-04-03 10:39:49 +02:00
|
|
|
|
public void DefineMaps(UmbracoMapper mapper)
|
2019-03-26 10:39:50 +01:00
|
|
|
|
{
|
|
|
|
|
|
mapper.Define<PropertyGroup, Tab<ContentPropertyDisplay>>((source, context) => new Tab<ContentPropertyDisplay>(), Map);
|
2019-11-08 15:10:05 +01:00
|
|
|
|
mapper.Define<IProperty, ContentPropertyBasic>((source, context) => new ContentPropertyBasic(), Map);
|
|
|
|
|
|
mapper.Define<IProperty, ContentPropertyDto>((source, context) => new ContentPropertyDto(), Map);
|
|
|
|
|
|
mapper.Define<IProperty, ContentPropertyDisplay>((source, context) => new ContentPropertyDisplay(), Map);
|
2019-03-26 10:39:50 +01:00
|
|
|
|
}
|
2017-07-19 13:42:47 +02:00
|
|
|
|
|
2019-03-26 10:39:50 +01:00
|
|
|
|
// Umbraco.Code.MapAll -Properties -Alias -Expanded
|
|
|
|
|
|
private void Map(PropertyGroup source, Tab<ContentPropertyDisplay> target, MapperContext mapper)
|
|
|
|
|
|
{
|
|
|
|
|
|
target.Id = source.Id;
|
|
|
|
|
|
target.IsActive = true;
|
|
|
|
|
|
target.Label = source.Name;
|
|
|
|
|
|
}
|
2017-07-19 13:42:47 +02:00
|
|
|
|
|
2019-11-08 15:10:05 +01:00
|
|
|
|
private void Map(IProperty source, ContentPropertyBasic target, MapperContext context)
|
2019-03-26 10:39:50 +01:00
|
|
|
|
{
|
|
|
|
|
|
// assume this is mapping everything and no MapAll is required
|
|
|
|
|
|
_contentPropertyBasicConverter.Map(source, target, context);
|
|
|
|
|
|
}
|
2017-07-19 13:42:47 +02:00
|
|
|
|
|
2019-11-08 15:10:05 +01:00
|
|
|
|
private void Map(IProperty source, ContentPropertyDto target, MapperContext context)
|
2019-03-26 10:39:50 +01:00
|
|
|
|
{
|
|
|
|
|
|
// assume this is mapping everything and no MapAll is required
|
|
|
|
|
|
_contentPropertyDtoConverter.Map(source, target, context);
|
|
|
|
|
|
}
|
2017-07-19 13:42:47 +02:00
|
|
|
|
|
2019-11-08 15:10:05 +01:00
|
|
|
|
private void Map(IProperty source, ContentPropertyDisplay target, MapperContext context)
|
2019-03-26 10:39:50 +01:00
|
|
|
|
{
|
|
|
|
|
|
// assume this is mapping everything and no MapAll is required
|
|
|
|
|
|
_contentPropertyDisplayMapper.Map(source, target, context);
|
2017-07-19 13:42:47 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-07-20 11:21:28 +02:00
|
|
|
|
}
|