Request datatype by guid (#6847)

This commit is contained in:
Bjarne Fyrstenborg
2020-01-08 19:02:16 +01:00
committed by Kenn Jacobsen
parent 2908ecac64
commit 0dfd7679e0
4 changed files with 144 additions and 33 deletions

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
using Umbraco.Core;
using Umbraco.Core.Logging;
@@ -23,6 +24,7 @@ namespace Umbraco.Web.Models.Mapping
public void DefineMaps(UmbracoMapper mapper)
{
mapper.Define<IMacro, EntityBasic>((source, context) => new EntityBasic(), Map);
mapper.Define<IMacro, MacroDisplay>((source, context) => new MacroDisplay(), Map);
mapper.Define<IMacro, IEnumerable<MacroParameter>>((source, context) => context.MapEnumerable<IMacroProperty, MacroParameter>(source.Properties.Values));
mapper.Define<IMacroProperty, MacroParameter>((source, context) => new MacroParameter(), Map);
}
@@ -40,6 +42,23 @@ namespace Umbraco.Web.Models.Mapping
target.Udi = Udi.Create(Constants.UdiEntityType.Macro, source.Key);
}
private void Map(IMacro source, MacroDisplay target, MapperContext context)
{
target.Alias = source.Alias;
target.Icon = Constants.Icons.Macro;
target.Id = source.Id;
target.Key = source.Key;
target.Name = source.Name;
target.ParentId = -1;
target.Path = "-1," + source.Id;
target.Udi = Udi.Create(Constants.UdiEntityType.Macro, source.Key);
target.CacheByPage = source.CacheByPage;
target.CacheByUser = source.CacheByMember;
target.CachePeriod = source.CacheDuration;
target.UseInEditor = source.UseInEditor;
target.RenderInEditor = !source.DontRender;
target.View = source.MacroSource;
}
// Umbraco.Code.MapAll -Value
private void Map(IMacroProperty source, MacroParameter target, MapperContext context)
{