2019-03-20 19:09:23 +01:00
|
|
|
|
using Umbraco.Core.Manifest;
|
|
|
|
|
|
using Umbraco.Core.Mapping;
|
2019-02-18 11:22:25 +01:00
|
|
|
|
using Umbraco.Core.Models.Sections;
|
2017-07-19 13:42:47 +02:00
|
|
|
|
using Umbraco.Core.Services;
|
|
|
|
|
|
using Umbraco.Web.Models.ContentEditing;
|
2019-03-20 19:09:23 +01:00
|
|
|
|
using Umbraco.Web.Sections;
|
2017-07-19 13:42:47 +02:00
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Web.Models.Mapping
|
|
|
|
|
|
{
|
2019-03-20 19:09:23 +01:00
|
|
|
|
internal class SectionMapperProfile : IMapperProfile
|
2017-07-19 13:42:47 +02:00
|
|
|
|
{
|
2019-03-20 19:09:23 +01:00
|
|
|
|
private readonly ILocalizedTextService _textService;
|
2017-09-20 20:06:46 +02:00
|
|
|
|
public SectionMapperProfile(ILocalizedTextService textService)
|
2017-07-19 13:42:47 +02:00
|
|
|
|
{
|
2019-03-20 19:09:23 +01:00
|
|
|
|
_textService = textService;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-03-28 12:38:04 +01:00
|
|
|
|
public void DefineMaps(Mapper mapper)
|
2019-03-20 19:09:23 +01:00
|
|
|
|
{
|
2019-03-26 10:39:50 +01:00
|
|
|
|
mapper.Define<ISection, Section>((source, context) => new Section(), Map);
|
2019-03-20 19:09:23 +01:00
|
|
|
|
|
|
|
|
|
|
// this is for AutoMapper ReverseMap - but really?
|
2019-03-25 09:03:46 +01:00
|
|
|
|
mapper.Define<Section, ContentSection>();
|
|
|
|
|
|
mapper.Define<Section, ContentSection>();
|
|
|
|
|
|
mapper.Define<Section, ManifestSection>(Map);
|
|
|
|
|
|
mapper.Define<Section, MediaSection>();
|
|
|
|
|
|
mapper.Define<Section, MembersSection>();
|
|
|
|
|
|
mapper.Define<Section, PackagesSection>();
|
|
|
|
|
|
mapper.Define<Section, SettingsSection>();
|
|
|
|
|
|
mapper.Define<Section, TranslationSection>();
|
|
|
|
|
|
mapper.Define<Section, UsersSection>();
|
2019-03-20 19:09:23 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Umbraco.Code.MapAll -RoutePath
|
2019-03-26 10:39:50 +01:00
|
|
|
|
private void Map(ISection source, Section target, MapperContext context)
|
2019-03-20 19:09:23 +01:00
|
|
|
|
{
|
|
|
|
|
|
target.Alias = source.Alias;
|
|
|
|
|
|
target.Name = _textService.Localize("sections/" + source.Alias);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Umbraco.Code.MapAll
|
2019-03-26 10:39:50 +01:00
|
|
|
|
private static void Map(Section source, ManifestSection target, MapperContext context)
|
2019-03-20 19:09:23 +01:00
|
|
|
|
{
|
|
|
|
|
|
target.Alias = source.Alias;
|
|
|
|
|
|
target.Name = source.Name;
|
2017-07-19 13:42:47 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-07-20 11:21:28 +02:00
|
|
|
|
}
|