using Umbraco.Core.Manifest; using Umbraco.Core.Mapping; using Umbraco.Core.Models.Sections; using Umbraco.Core.Services; using Umbraco.Web.Models.ContentEditing; using Umbraco.Web.Sections; namespace Umbraco.Web.Models.Mapping { internal class SectionMapDefinition : IMapDefinition { private readonly ILocalizedTextService _textService; public SectionMapDefinition(ILocalizedTextService textService) { _textService = textService; } public void DefineMaps(UmbracoMapper mapper) { mapper.Define((source, context) => new Section(), Map); // this is for AutoMapper ReverseMap - but really? mapper.Define(); mapper.Define(); mapper.Define(Map); mapper.Define(); mapper.Define(); mapper.Define(); mapper.Define(); mapper.Define(); mapper.Define(); } // Umbraco.Code.MapAll -RoutePath private void Map(ISection source, Section target, MapperContext context) { target.Alias = source.Alias; target.Name = _textService.Localize("sections/" + source.Alias); } // Umbraco.Code.MapAll private static void Map(Section source, ManifestSection target, MapperContext context) { target.Alias = source.Alias; target.Name = source.Name; } } }