Merge branch '7.2.0' of https://github.com/umbraco/Umbraco-CMS into 7.2.0
This commit is contained in:
50
src/Umbraco.Core/Persistence/Mappers/TemplateMapper.cs
Normal file
50
src/Umbraco.Core/Persistence/Mappers/TemplateMapper.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Rdbms;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Mappers
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a <see cref="Template"/> to DTO mapper used to translate the properties of the public api
|
||||
/// implementation to that of the database's DTO as sql: [tableName].[columnName].
|
||||
/// </summary>
|
||||
[MapperFor(typeof(Template))]
|
||||
[MapperFor(typeof(ITemplate))]
|
||||
public sealed class TemplateMapper : BaseMapper
|
||||
{
|
||||
private static readonly ConcurrentDictionary<string, DtoMapModel> PropertyInfoCacheInstance = new ConcurrentDictionary<string, DtoMapModel>();
|
||||
|
||||
//NOTE: its an internal class but the ctor must be public since we're using Activator.CreateInstance to create it
|
||||
// otherwise that would fail because there is no public constructor.
|
||||
public TemplateMapper()
|
||||
{
|
||||
BuildMap();
|
||||
}
|
||||
|
||||
#region Overrides of BaseMapper
|
||||
|
||||
internal override ConcurrentDictionary<string, DtoMapModel> PropertyInfoCache
|
||||
{
|
||||
get { return PropertyInfoCacheInstance; }
|
||||
}
|
||||
|
||||
internal override void BuildMap()
|
||||
{
|
||||
if(PropertyInfoCache.IsEmpty)
|
||||
{
|
||||
CacheMap<Template, TemplateDto>(src => src.Id, dto => dto.NodeId);
|
||||
|
||||
CacheMap<Template, TemplateDto>(src => src.MasterTemplateId, dto => dto.Master);
|
||||
CacheMap<Template, TemplateDto>(src => src.Alias, dto => dto.Alias);
|
||||
CacheMap<Template, TemplateDto>(src => src.Content, dto => dto.Design);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -387,6 +387,7 @@
|
||||
<Compile Include="Persistence\Factories\MemberGroupFactory.cs" />
|
||||
<Compile Include="Persistence\Mappers\MemberGroupMapper.cs" />
|
||||
<Compile Include="Persistence\Mappers\TagMapper.cs" />
|
||||
<Compile Include="Persistence\Mappers\TemplateMapper.cs" />
|
||||
<Compile Include="Persistence\Migrations\DataLossException.cs" />
|
||||
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSevenOneZero\AssignMissingPrimaryForMySqlKeys.cs" />
|
||||
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSixTwoZero\AssignMissingPrimaryForMySqlKeys.cs" />
|
||||
|
||||
Reference in New Issue
Block a user