AB4227 - Moved persistence mappers
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Mappers
|
||||
{
|
||||
[MapperFor(typeof(PublicAccessEntry))]
|
||||
public sealed class AccessMapper : BaseMapper
|
||||
{
|
||||
public AccessMapper(Lazy<ISqlContext> sqlContext, ConcurrentDictionary<Type, ConcurrentDictionary<string, string>> maps)
|
||||
: base(sqlContext, maps)
|
||||
{ }
|
||||
|
||||
protected override void DefineMaps()
|
||||
{
|
||||
DefineMap<PublicAccessEntry, AccessDto>(nameof(PublicAccessEntry.Key), nameof(AccessDto.Id));
|
||||
DefineMap<PublicAccessEntry, AccessDto>(nameof(PublicAccessEntry.LoginNodeId), nameof(AccessDto.LoginNodeId));
|
||||
DefineMap<PublicAccessEntry, AccessDto>(nameof(PublicAccessEntry.NoAccessNodeId), nameof(AccessDto.NoAccessNodeId));
|
||||
DefineMap<PublicAccessEntry, AccessDto>(nameof(PublicAccessEntry.ProtectedNodeId), nameof(AccessDto.NodeId));
|
||||
DefineMap<PublicAccessEntry, AccessDto>(nameof(PublicAccessEntry.CreateDate), nameof(AccessDto.CreateDate));
|
||||
DefineMap<PublicAccessEntry, AccessDto>(nameof(PublicAccessEntry.UpdateDate), nameof(AccessDto.UpdateDate));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Mappers
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a mapper for audit entry entities.
|
||||
/// </summary>
|
||||
[MapperFor(typeof(IAuditEntry))]
|
||||
[MapperFor(typeof(AuditEntry))]
|
||||
public sealed class AuditEntryMapper : BaseMapper
|
||||
{
|
||||
public AuditEntryMapper(Lazy<ISqlContext> sqlContext, ConcurrentDictionary<Type, ConcurrentDictionary<string, string>> maps)
|
||||
: base(sqlContext, maps)
|
||||
{ }
|
||||
|
||||
protected override void DefineMaps()
|
||||
{
|
||||
DefineMap<AuditEntry, AuditEntryDto>(nameof(AuditEntry.Id), nameof(AuditEntryDto.Id));
|
||||
DefineMap<AuditEntry, AuditEntryDto>(nameof(AuditEntry.PerformingUserId), nameof(AuditEntryDto.PerformingUserId));
|
||||
DefineMap<AuditEntry, AuditEntryDto>(nameof(AuditEntry.PerformingDetails), nameof(AuditEntryDto.PerformingDetails));
|
||||
DefineMap<AuditEntry, AuditEntryDto>(nameof(AuditEntry.PerformingIp), nameof(AuditEntryDto.PerformingIp));
|
||||
DefineMap<AuditEntry, AuditEntryDto>(nameof(AuditEntry.EventDateUtc), nameof(AuditEntryDto.EventDateUtc));
|
||||
DefineMap<AuditEntry, AuditEntryDto>(nameof(AuditEntry.AffectedUserId), nameof(AuditEntryDto.AffectedUserId));
|
||||
DefineMap<AuditEntry, AuditEntryDto>(nameof(AuditEntry.AffectedDetails), nameof(AuditEntryDto.AffectedDetails));
|
||||
DefineMap<AuditEntry, AuditEntryDto>(nameof(AuditEntry.EventType), nameof(AuditEntryDto.EventType));
|
||||
DefineMap<AuditEntry, AuditEntryDto>(nameof(AuditEntry.EventDetails), nameof(AuditEntryDto.EventDetails));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Mappers
|
||||
{
|
||||
[MapperFor(typeof(AuditItem))]
|
||||
[MapperFor(typeof(IAuditItem))]
|
||||
public sealed class AuditItemMapper : BaseMapper
|
||||
{
|
||||
public AuditItemMapper(Lazy<ISqlContext> sqlContext, ConcurrentDictionary<Type, ConcurrentDictionary<string, string>> maps)
|
||||
: base(sqlContext, maps)
|
||||
{ }
|
||||
|
||||
protected override void DefineMaps()
|
||||
{
|
||||
DefineMap<AuditItem, LogDto>(nameof(AuditItem.Id), nameof(LogDto.NodeId));
|
||||
DefineMap<AuditItem, LogDto>(nameof(AuditItem.CreateDate), nameof(LogDto.Datestamp));
|
||||
DefineMap<AuditItem, LogDto>(nameof(AuditItem.UserId), nameof(LogDto.UserId));
|
||||
// we cannot map that one - because AuditType is an enum but Header is a string
|
||||
//DefineMap<AuditItem, LogDto>(nameof(AuditItem.AuditType), nameof(LogDto.Header));
|
||||
DefineMap<AuditItem, LogDto>(nameof(AuditItem.Comment), nameof(LogDto.Comment));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Mappers
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a mapper for consent entities.
|
||||
/// </summary>
|
||||
[MapperFor(typeof(IConsent))]
|
||||
[MapperFor(typeof(Consent))]
|
||||
public sealed class ConsentMapper : BaseMapper
|
||||
{
|
||||
public ConsentMapper(Lazy<ISqlContext> sqlContext, ConcurrentDictionary<Type, ConcurrentDictionary<string, string>> maps)
|
||||
: base(sqlContext, maps)
|
||||
{ }
|
||||
|
||||
protected override void DefineMaps()
|
||||
{
|
||||
DefineMap<Consent, ConsentDto>(nameof(Consent.Id), nameof(ConsentDto.Id));
|
||||
DefineMap<Consent, ConsentDto>(nameof(Consent.Current), nameof(ConsentDto.Current));
|
||||
DefineMap<Consent, ConsentDto>(nameof(Consent.CreateDate), nameof(ConsentDto.CreateDate));
|
||||
DefineMap<Consent, ConsentDto>(nameof(Consent.Source), nameof(ConsentDto.Source));
|
||||
DefineMap<Consent, ConsentDto>(nameof(Consent.Context), nameof(ConsentDto.Context));
|
||||
DefineMap<Consent, ConsentDto>(nameof(Consent.Action), nameof(ConsentDto.Action));
|
||||
DefineMap<Consent, ConsentDto>(nameof(Consent.State), nameof(ConsentDto.State));
|
||||
DefineMap<Consent, ConsentDto>(nameof(Consent.Comment), nameof(ConsentDto.Comment));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Mappers
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a <see cref="Content"/> 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(Content))]
|
||||
[MapperFor(typeof(IContent))]
|
||||
public sealed class ContentMapper : BaseMapper
|
||||
{
|
||||
public ContentMapper(Lazy<ISqlContext> sqlContext, ConcurrentDictionary<Type, ConcurrentDictionary<string, string>> maps)
|
||||
: base(sqlContext, maps)
|
||||
{ }
|
||||
|
||||
protected override void DefineMaps()
|
||||
{
|
||||
DefineMap<Content, NodeDto>(nameof(Content.Id), nameof(NodeDto.NodeId));
|
||||
DefineMap<Content, NodeDto>(nameof(Content.Key), nameof(NodeDto.UniqueId));
|
||||
|
||||
DefineMap<Content, ContentVersionDto>(nameof(Content.VersionId), nameof(ContentVersionDto.Id));
|
||||
DefineMap<Content, ContentVersionDto>(nameof(Content.Name), nameof(ContentVersionDto.Text));
|
||||
|
||||
DefineMap<Content, NodeDto>(nameof(Content.ParentId), nameof(NodeDto.ParentId));
|
||||
DefineMap<Content, NodeDto>(nameof(Content.Level), nameof(NodeDto.Level));
|
||||
DefineMap<Content, NodeDto>(nameof(Content.Path), nameof(NodeDto.Path));
|
||||
DefineMap<Content, NodeDto>(nameof(Content.SortOrder), nameof(NodeDto.SortOrder));
|
||||
DefineMap<Content, NodeDto>(nameof(Content.Trashed), nameof(NodeDto.Trashed));
|
||||
|
||||
DefineMap<Content, NodeDto>(nameof(Content.CreateDate), nameof(NodeDto.CreateDate));
|
||||
DefineMap<Content, NodeDto>(nameof(Content.CreatorId), nameof(NodeDto.UserId));
|
||||
DefineMap<Content, ContentDto>(nameof(Content.ContentTypeId), nameof(ContentDto.ContentTypeId));
|
||||
|
||||
DefineMap<Content, ContentVersionDto>(nameof(Content.UpdateDate), nameof(ContentVersionDto.VersionDate));
|
||||
DefineMap<Content, DocumentDto>(nameof(Content.Published), nameof(DocumentDto.Published));
|
||||
|
||||
//DefineMap<Content, DocumentDto>(nameof(Content.Name), nameof(DocumentDto.Alias));
|
||||
//CacheMap<Content, DocumentDto>(src => src, dto => dto.Newest);
|
||||
//DefineMap<Content, DocumentDto>(nameof(Content.Template), nameof(DocumentDto.TemplateId));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Mappers
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a <see cref="ContentType"/> 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(ContentType))]
|
||||
[MapperFor(typeof(IContentType))]
|
||||
public sealed class ContentTypeMapper : BaseMapper
|
||||
{
|
||||
public ContentTypeMapper(Lazy<ISqlContext> sqlContext, ConcurrentDictionary<Type, ConcurrentDictionary<string, string>> maps)
|
||||
: base(sqlContext, maps)
|
||||
{ }
|
||||
|
||||
protected override void DefineMaps()
|
||||
{
|
||||
DefineMap<ContentType, NodeDto>(nameof(ContentType.Id), nameof(NodeDto.NodeId));
|
||||
DefineMap<ContentType, NodeDto>(nameof(ContentType.CreateDate), nameof(NodeDto.CreateDate));
|
||||
DefineMap<ContentType, NodeDto>(nameof(ContentType.Level), nameof(NodeDto.Level));
|
||||
DefineMap<ContentType, NodeDto>(nameof(ContentType.ParentId), nameof(NodeDto.ParentId));
|
||||
DefineMap<ContentType, NodeDto>(nameof(ContentType.Path), nameof(NodeDto.Path));
|
||||
DefineMap<ContentType, NodeDto>(nameof(ContentType.SortOrder), nameof(NodeDto.SortOrder));
|
||||
DefineMap<ContentType, NodeDto>(nameof(ContentType.Name), nameof(NodeDto.Text));
|
||||
DefineMap<ContentType, NodeDto>(nameof(ContentType.Trashed), nameof(NodeDto.Trashed));
|
||||
DefineMap<ContentType, NodeDto>(nameof(ContentType.Key), nameof(NodeDto.UniqueId));
|
||||
DefineMap<ContentType, NodeDto>(nameof(ContentType.CreatorId), nameof(NodeDto.UserId));
|
||||
DefineMap<ContentType, ContentTypeDto>(nameof(ContentType.Alias), nameof(ContentTypeDto.Alias));
|
||||
DefineMap<ContentType, ContentTypeDto>(nameof(ContentType.AllowedAsRoot), nameof(ContentTypeDto.AllowAtRoot));
|
||||
DefineMap<ContentType, ContentTypeDto>(nameof(ContentType.Description), nameof(ContentTypeDto.Description));
|
||||
DefineMap<ContentType, ContentTypeDto>(nameof(ContentType.Icon), nameof(ContentTypeDto.Icon));
|
||||
DefineMap<ContentType, ContentTypeDto>(nameof(ContentType.IsContainer), nameof(ContentTypeDto.IsContainer));
|
||||
DefineMap<ContentType, ContentTypeDto>(nameof(ContentType.IsElement), nameof(ContentTypeDto.IsElement));
|
||||
DefineMap<ContentType, ContentTypeDto>(nameof(ContentType.Thumbnail), nameof(ContentTypeDto.Thumbnail));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Mappers
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a <see cref="DataType"/> 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(DataType))]
|
||||
[MapperFor(typeof(IDataType))]
|
||||
public sealed class DataTypeMapper : BaseMapper
|
||||
{
|
||||
public DataTypeMapper(Lazy<ISqlContext> sqlContext, ConcurrentDictionary<Type, ConcurrentDictionary<string, string>> maps)
|
||||
: base(sqlContext, maps)
|
||||
{ }
|
||||
|
||||
protected override void DefineMaps()
|
||||
{
|
||||
DefineMap<DataType, NodeDto>(nameof(DataType.Id), nameof(NodeDto.NodeId));
|
||||
DefineMap<DataType, NodeDto>(nameof(DataType.CreateDate), nameof(NodeDto.CreateDate));
|
||||
DefineMap<DataType, NodeDto>(nameof(DataType.Level), nameof(NodeDto.Level));
|
||||
DefineMap<DataType, NodeDto>(nameof(DataType.ParentId), nameof(NodeDto.ParentId));
|
||||
DefineMap<DataType, NodeDto>(nameof(DataType.Path), nameof(NodeDto.Path));
|
||||
DefineMap<DataType, NodeDto>(nameof(DataType.SortOrder), nameof(NodeDto.SortOrder));
|
||||
DefineMap<DataType, NodeDto>(nameof(DataType.Name), nameof(NodeDto.Text));
|
||||
DefineMap<DataType, NodeDto>(nameof(DataType.Trashed), nameof(NodeDto.Trashed));
|
||||
DefineMap<DataType, NodeDto>(nameof(DataType.Key), nameof(NodeDto.UniqueId));
|
||||
DefineMap<DataType, NodeDto>(nameof(DataType.CreatorId), nameof(NodeDto.UserId));
|
||||
DefineMap<DataType, DataTypeDto>(nameof(DataType.EditorAlias), nameof(DataTypeDto.EditorAlias));
|
||||
DefineMap<DataType, DataTypeDto>(nameof(DataType.DatabaseType), nameof(DataTypeDto.DbType));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Mappers
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a <see cref="DictionaryItem"/> 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(DictionaryItem))]
|
||||
[MapperFor(typeof(IDictionaryItem))]
|
||||
public sealed class DictionaryMapper : BaseMapper
|
||||
{
|
||||
public DictionaryMapper(Lazy<ISqlContext> sqlContext, ConcurrentDictionary<Type, ConcurrentDictionary<string, string>> maps)
|
||||
: base(sqlContext, maps)
|
||||
{ }
|
||||
|
||||
protected override void DefineMaps()
|
||||
{
|
||||
DefineMap<DictionaryItem, DictionaryDto>(nameof(DictionaryItem.Id), nameof(DictionaryDto.PrimaryKey));
|
||||
DefineMap<DictionaryItem, DictionaryDto>(nameof(DictionaryItem.Key), nameof(DictionaryDto.UniqueId));
|
||||
DefineMap<DictionaryItem, DictionaryDto>(nameof(DictionaryItem.ItemKey), nameof(DictionaryDto.Key));
|
||||
DefineMap<DictionaryItem, DictionaryDto>(nameof(DictionaryItem.ParentId), nameof(DictionaryDto.Parent));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Mappers
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a <see cref="DictionaryTranslation"/> 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(DictionaryTranslation))]
|
||||
[MapperFor(typeof(IDictionaryTranslation))]
|
||||
public sealed class DictionaryTranslationMapper : BaseMapper
|
||||
{
|
||||
public DictionaryTranslationMapper(Lazy<ISqlContext> sqlContext, ConcurrentDictionary<Type, ConcurrentDictionary<string, string>> maps)
|
||||
: base(sqlContext, maps)
|
||||
{ }
|
||||
|
||||
protected override void DefineMaps()
|
||||
{
|
||||
DefineMap<DictionaryTranslation, LanguageTextDto>(nameof(DictionaryTranslation.Id), nameof(LanguageTextDto.PrimaryKey));
|
||||
DefineMap<DictionaryTranslation, LanguageTextDto>(nameof(DictionaryTranslation.Key), nameof(LanguageTextDto.UniqueId));
|
||||
DefineMap<DictionaryTranslation, LanguageTextDto>(nameof(DictionaryTranslation.Language), nameof(LanguageTextDto.LanguageId));
|
||||
DefineMap<DictionaryTranslation, LanguageTextDto>(nameof(DictionaryTranslation.Value), nameof(LanguageTextDto.Value));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Mappers
|
||||
{
|
||||
[MapperFor(typeof(IDomain))]
|
||||
[MapperFor(typeof(UmbracoDomain))]
|
||||
public sealed class DomainMapper : BaseMapper
|
||||
{
|
||||
public DomainMapper(Lazy<ISqlContext> sqlContext, ConcurrentDictionary<Type, ConcurrentDictionary<string, string>> maps)
|
||||
: base(sqlContext, maps)
|
||||
{ }
|
||||
|
||||
protected override void DefineMaps()
|
||||
{
|
||||
DefineMap<UmbracoDomain, DomainDto>(nameof(UmbracoDomain.Id), nameof(DomainDto.Id));
|
||||
DefineMap<UmbracoDomain, DomainDto>(nameof(UmbracoDomain.RootContentId), nameof(DomainDto.RootStructureId));
|
||||
DefineMap<UmbracoDomain, DomainDto>(nameof(UmbracoDomain.LanguageId), nameof(DomainDto.DefaultLanguage));
|
||||
DefineMap<UmbracoDomain, DomainDto>(nameof(UmbracoDomain.DomainName), nameof(DomainDto.DomainName));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using Umbraco.Core.Models.Identity;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Mappers
|
||||
{
|
||||
[MapperFor(typeof(IIdentityUserLogin))]
|
||||
[MapperFor(typeof(IdentityUserLogin))]
|
||||
public sealed class ExternalLoginMapper : BaseMapper
|
||||
{
|
||||
public ExternalLoginMapper(Lazy<ISqlContext> sqlContext, ConcurrentDictionary<Type, ConcurrentDictionary<string, string>> maps)
|
||||
: base(sqlContext, maps)
|
||||
{ }
|
||||
|
||||
protected override void DefineMaps()
|
||||
{
|
||||
DefineMap<IdentityUserLogin, ExternalLoginDto>(nameof(IdentityUserLogin.Id), nameof(ExternalLoginDto.Id));
|
||||
DefineMap<IdentityUserLogin, ExternalLoginDto>(nameof(IdentityUserLogin.CreateDate), nameof(ExternalLoginDto.CreateDate));
|
||||
DefineMap<IdentityUserLogin, ExternalLoginDto>(nameof(IdentityUserLogin.LoginProvider), nameof(ExternalLoginDto.LoginProvider));
|
||||
DefineMap<IdentityUserLogin, ExternalLoginDto>(nameof(IdentityUserLogin.ProviderKey), nameof(ExternalLoginDto.ProviderKey));
|
||||
DefineMap<IdentityUserLogin, ExternalLoginDto>(nameof(IdentityUserLogin.UserId), nameof(ExternalLoginDto.UserId));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Mappers
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a <see cref="Language"/> 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(ILanguage))]
|
||||
[MapperFor(typeof(Language))]
|
||||
public sealed class LanguageMapper : BaseMapper
|
||||
{
|
||||
public LanguageMapper(Lazy<ISqlContext> sqlContext, ConcurrentDictionary<Type, ConcurrentDictionary<string, string>> maps)
|
||||
: base(sqlContext, maps)
|
||||
{ }
|
||||
|
||||
protected override void DefineMaps()
|
||||
{
|
||||
DefineMap<Language, LanguageDto>(nameof(Language.Id), nameof(LanguageDto.Id));
|
||||
DefineMap<Language, LanguageDto>(nameof(Language.IsoCode), nameof(LanguageDto.IsoCode));
|
||||
DefineMap<Language, LanguageDto>(nameof(Language.CultureName), nameof(LanguageDto.CultureName));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Mappers
|
||||
{
|
||||
[MapperFor(typeof(Macro))]
|
||||
[MapperFor(typeof(IMacro))]
|
||||
internal sealed class MacroMapper : BaseMapper
|
||||
{
|
||||
public MacroMapper(Lazy<ISqlContext> sqlContext, ConcurrentDictionary<Type, ConcurrentDictionary<string, string>> maps)
|
||||
: base(sqlContext, maps)
|
||||
{ }
|
||||
|
||||
protected override void DefineMaps()
|
||||
{
|
||||
DefineMap<Macro, MacroDto>(nameof(Macro.Id), nameof(MacroDto.Id));
|
||||
DefineMap<Macro, MacroDto>(nameof(Macro.Alias), nameof(MacroDto.Alias));
|
||||
DefineMap<Macro, MacroDto>(nameof(Macro.CacheByPage), nameof(MacroDto.CacheByPage));
|
||||
DefineMap<Macro, MacroDto>(nameof(Macro.CacheByMember), nameof(MacroDto.CachePersonalized));
|
||||
DefineMap<Macro, MacroDto>(nameof(Macro.MacroType), nameof(MacroDto.MacroType));
|
||||
DefineMap<Macro, MacroDto>(nameof(Macro.DontRender), nameof(MacroDto.DontRender));
|
||||
DefineMap<Macro, MacroDto>(nameof(Macro.Name), nameof(MacroDto.Name));
|
||||
DefineMap<Macro, MacroDto>(nameof(Macro.CacheDuration), nameof(MacroDto.RefreshRate));
|
||||
DefineMap<Macro, MacroDto>(nameof(Macro.MacroSource), nameof(MacroDto.MacroSource));
|
||||
DefineMap<Macro, MacroDto>(nameof(Macro.UseInEditor), nameof(MacroDto.UseInEditor));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using Umbraco.Core.Composing;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Mappers
|
||||
{
|
||||
public class MapperCollectionBuilder : SetCollectionBuilderBase<MapperCollectionBuilder, MapperCollection, BaseMapper>
|
||||
{
|
||||
private readonly ConcurrentDictionary<Type, ConcurrentDictionary<string, string>> _maps
|
||||
= new ConcurrentDictionary<Type, ConcurrentDictionary<string, string>>();
|
||||
|
||||
protected override MapperCollectionBuilder This => this;
|
||||
|
||||
public override void RegisterWith(IRegister register)
|
||||
{
|
||||
base.RegisterWith(register);
|
||||
|
||||
// default initializer registers
|
||||
// - service MapperCollectionBuilder, returns MapperCollectionBuilder
|
||||
// - service MapperCollection, returns MapperCollectionBuilder's collection
|
||||
// we want to register extra
|
||||
// - service IMapperCollection, returns MappersCollectionBuilder's collection
|
||||
|
||||
register.Register<IMapperCollection>(factory => factory.GetInstance<MapperCollection>());
|
||||
}
|
||||
|
||||
protected override BaseMapper CreateItem(IFactory factory, Type itemType)
|
||||
{
|
||||
return (BaseMapper) factory.CreateInstance(itemType, _maps);
|
||||
}
|
||||
|
||||
public MapperCollectionBuilder AddCoreMappers()
|
||||
{
|
||||
Add<AccessMapper>();
|
||||
Add<AuditItemMapper>();
|
||||
Add<ContentMapper>();
|
||||
Add<ContentTypeMapper>();
|
||||
Add<SimpleContentTypeMapper>();
|
||||
Add<DataTypeMapper>();
|
||||
Add<DictionaryMapper>();
|
||||
Add<DictionaryTranslationMapper>();
|
||||
Add<DomainMapper>();
|
||||
Add<LanguageMapper>();
|
||||
Add<MacroMapper>();
|
||||
Add<MediaMapper>();
|
||||
Add<MediaTypeMapper>();
|
||||
Add<MemberGroupMapper>();
|
||||
Add<MemberMapper>();
|
||||
Add<MemberTypeMapper>();
|
||||
Add<PropertyGroupMapper>();
|
||||
Add<PropertyMapper>();
|
||||
Add<PropertyTypeMapper>();
|
||||
Add<RelationMapper>();
|
||||
Add<RelationTypeMapper>();
|
||||
Add<ServerRegistrationMapper>();
|
||||
Add<TagMapper>();
|
||||
Add<TemplateMapper>();
|
||||
Add<UmbracoEntityMapper>();
|
||||
Add<UserMapper>();
|
||||
Add<ExternalLoginMapper>();
|
||||
Add<UserGroupMapper>();
|
||||
Add<AuditEntryMapper>();
|
||||
Add<ConsentMapper>();
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Mappers
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a <see cref="Models.Media"/> 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(IMedia))]
|
||||
[MapperFor(typeof(Umbraco.Core.Models.Media))]
|
||||
public sealed class MediaMapper : BaseMapper
|
||||
{
|
||||
public MediaMapper(Lazy<ISqlContext> sqlContext, ConcurrentDictionary<Type, ConcurrentDictionary<string, string>> maps)
|
||||
: base(sqlContext, maps)
|
||||
{ }
|
||||
|
||||
protected override void DefineMaps()
|
||||
{
|
||||
DefineMap<Models.Media, NodeDto>(nameof(Models.Media.Id), nameof(NodeDto.NodeId));
|
||||
DefineMap<Models.Media, NodeDto>(nameof(Models.Media.Key), nameof(NodeDto.UniqueId));
|
||||
|
||||
DefineMap<Content, ContentVersionDto>(nameof(Content.VersionId), nameof(ContentVersionDto.Id));
|
||||
|
||||
DefineMap<Models.Media, NodeDto>(nameof(Models.Media.CreateDate), nameof(NodeDto.CreateDate));
|
||||
DefineMap<Models.Media, NodeDto>(nameof(Models.Media.Level), nameof(NodeDto.Level));
|
||||
DefineMap<Models.Media, NodeDto>(nameof(Models.Media.ParentId), nameof(NodeDto.ParentId));
|
||||
DefineMap<Models.Media, NodeDto>(nameof(Models.Media.Path), nameof(NodeDto.Path));
|
||||
DefineMap<Models.Media, NodeDto>(nameof(Models.Media.SortOrder), nameof(NodeDto.SortOrder));
|
||||
DefineMap<Models.Media, NodeDto>(nameof(Models.Media.Name), nameof(NodeDto.Text));
|
||||
DefineMap<Models.Media, NodeDto>(nameof(Models.Media.Trashed), nameof(NodeDto.Trashed));
|
||||
DefineMap<Models.Media, NodeDto>(nameof(Models.Media.CreatorId), nameof(NodeDto.UserId));
|
||||
DefineMap<Models.Media, ContentDto>(nameof(Models.Media.ContentTypeId), nameof(ContentDto.ContentTypeId));
|
||||
DefineMap<Models.Media, ContentVersionDto>(nameof(Models.Media.UpdateDate), nameof(ContentVersionDto.VersionDate));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Mappers
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a <see cref="MediaType"/> 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(IMediaType))]
|
||||
[MapperFor(typeof(MediaType))]
|
||||
public sealed class MediaTypeMapper : BaseMapper
|
||||
{
|
||||
public MediaTypeMapper(Lazy<ISqlContext> sqlContext, ConcurrentDictionary<Type, ConcurrentDictionary<string, string>> maps)
|
||||
: base(sqlContext, maps)
|
||||
{ }
|
||||
|
||||
protected override void DefineMaps()
|
||||
{
|
||||
DefineMap<MediaType, NodeDto>(nameof(MediaType.Id), nameof(NodeDto.NodeId));
|
||||
DefineMap<MediaType, NodeDto>(nameof(MediaType.CreateDate), nameof(NodeDto.CreateDate));
|
||||
DefineMap<MediaType, NodeDto>(nameof(MediaType.Level), nameof(NodeDto.Level));
|
||||
DefineMap<MediaType, NodeDto>(nameof(MediaType.ParentId), nameof(NodeDto.ParentId));
|
||||
DefineMap<MediaType, NodeDto>(nameof(MediaType.Path), nameof(NodeDto.Path));
|
||||
DefineMap<MediaType, NodeDto>(nameof(MediaType.SortOrder), nameof(NodeDto.SortOrder));
|
||||
DefineMap<MediaType, NodeDto>(nameof(MediaType.Name), nameof(NodeDto.Text));
|
||||
DefineMap<MediaType, NodeDto>(nameof(MediaType.Trashed), nameof(NodeDto.Trashed));
|
||||
DefineMap<MediaType, NodeDto>(nameof(MediaType.Key), nameof(NodeDto.UniqueId));
|
||||
DefineMap<MediaType, NodeDto>(nameof(MediaType.CreatorId), nameof(NodeDto.UserId));
|
||||
DefineMap<MediaType, ContentTypeDto>(nameof(MediaType.Alias), nameof(ContentTypeDto.Alias));
|
||||
DefineMap<MediaType, ContentTypeDto>(nameof(MediaType.AllowedAsRoot), nameof(ContentTypeDto.AllowAtRoot));
|
||||
DefineMap<MediaType, ContentTypeDto>(nameof(MediaType.Description), nameof(ContentTypeDto.Description));
|
||||
DefineMap<MediaType, ContentTypeDto>(nameof(MediaType.Icon), nameof(ContentTypeDto.Icon));
|
||||
DefineMap<MediaType, ContentTypeDto>(nameof(MediaType.IsContainer), nameof(ContentTypeDto.IsContainer));
|
||||
DefineMap<MediaType, ContentTypeDto>(nameof(MediaType.IsElement), nameof(ContentTypeDto.IsElement));
|
||||
DefineMap<MediaType, ContentTypeDto>(nameof(MediaType.Thumbnail), nameof(ContentTypeDto.Thumbnail));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Mappers
|
||||
{
|
||||
[MapperFor(typeof (IMemberGroup))]
|
||||
[MapperFor(typeof (MemberGroup))]
|
||||
public sealed class MemberGroupMapper : BaseMapper
|
||||
{
|
||||
public MemberGroupMapper(Lazy<ISqlContext> sqlContext, ConcurrentDictionary<Type, ConcurrentDictionary<string, string>> maps)
|
||||
: base(sqlContext, maps)
|
||||
{ }
|
||||
|
||||
protected override void DefineMaps()
|
||||
{
|
||||
DefineMap<MemberGroup, NodeDto>(nameof(MemberGroup.Id), nameof(NodeDto.NodeId));
|
||||
DefineMap<MemberGroup, NodeDto>(nameof(MemberGroup.CreateDate), nameof(NodeDto.CreateDate));
|
||||
DefineMap<MemberGroup, NodeDto>(nameof(MemberGroup.CreatorId), nameof(NodeDto.UserId));
|
||||
DefineMap<MemberGroup, NodeDto>(nameof(MemberGroup.Name), nameof(NodeDto.Text));
|
||||
DefineMap<MemberGroup, NodeDto>(nameof(MemberGroup.Key), nameof(NodeDto.UniqueId));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Entities;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Mappers
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a <see cref="Member"/> 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(IMember))]
|
||||
[MapperFor(typeof(Member))]
|
||||
public sealed class MemberMapper : BaseMapper
|
||||
{
|
||||
public MemberMapper(Lazy<ISqlContext> sqlContext, ConcurrentDictionary<Type, ConcurrentDictionary<string, string>> maps)
|
||||
: base(sqlContext, maps)
|
||||
{ }
|
||||
|
||||
protected override void DefineMaps()
|
||||
{
|
||||
DefineMap<Member, NodeDto>(nameof(Member.Id), nameof(NodeDto.NodeId));
|
||||
DefineMap<Member, NodeDto>(nameof(Member.CreateDate), nameof(NodeDto.CreateDate));
|
||||
DefineMap<Member, NodeDto>(nameof(Member.Level), nameof(NodeDto.Level));
|
||||
DefineMap<Member, NodeDto>(nameof(Member.ParentId), nameof(NodeDto.ParentId));
|
||||
DefineMap<Member, NodeDto>(nameof(Member.Path), nameof(NodeDto.Path));
|
||||
DefineMap<Member, NodeDto>(nameof(Member.SortOrder), nameof(NodeDto.SortOrder));
|
||||
DefineMap<Member, NodeDto>(nameof(Member.CreatorId), nameof(NodeDto.UserId));
|
||||
DefineMap<Member, NodeDto>(nameof(Member.Name), nameof(NodeDto.Text));
|
||||
DefineMap<Member, NodeDto>(nameof(Member.Trashed), nameof(NodeDto.Trashed));
|
||||
DefineMap<Member, NodeDto>(nameof(Member.Key), nameof(NodeDto.UniqueId));
|
||||
DefineMap<Member, ContentDto>(nameof(Member.ContentTypeId), nameof(ContentDto.ContentTypeId));
|
||||
DefineMap<Member, ContentTypeDto>(nameof(Member.ContentTypeAlias), nameof(ContentTypeDto.Alias));
|
||||
DefineMap<Member, ContentVersionDto>(nameof(Member.UpdateDate), nameof(ContentVersionDto.VersionDate));
|
||||
|
||||
DefineMap<Member, MemberDto>(nameof(Member.Email), nameof(MemberDto.Email));
|
||||
DefineMap<Member, MemberDto>(nameof(Member.Username), nameof(MemberDto.LoginName));
|
||||
DefineMap<Member, MemberDto>(nameof(Member.RawPasswordValue), nameof(MemberDto.Password));
|
||||
|
||||
DefineMap<Member, PropertyDataDto>(nameof(Member.IsApproved), nameof(PropertyDataDto.IntegerValue));
|
||||
DefineMap<Member, PropertyDataDto>(nameof(Member.IsLockedOut), nameof(PropertyDataDto.IntegerValue));
|
||||
DefineMap<Member, PropertyDataDto>(nameof(Member.Comments), nameof(PropertyDataDto.TextValue));
|
||||
DefineMap<Member, PropertyDataDto>(nameof(Member.FailedPasswordAttempts), nameof(PropertyDataDto.IntegerValue));
|
||||
DefineMap<Member, PropertyDataDto>(nameof(Member.LastLockoutDate), nameof(PropertyDataDto.DateValue));
|
||||
DefineMap<Member, PropertyDataDto>(nameof(Member.LastLoginDate), nameof(PropertyDataDto.DateValue));
|
||||
DefineMap<Member, PropertyDataDto>(nameof(Member.LastPasswordChangeDate), nameof(PropertyDataDto.DateValue));
|
||||
|
||||
/* Internal experiment */
|
||||
DefineMap<Member, PropertyDataDto>(nameof(Member.DateTimePropertyValue), nameof(PropertyDataDto.DateValue));
|
||||
DefineMap<Member, PropertyDataDto>(nameof(Member.IntegerPropertyValue), nameof(PropertyDataDto.IntegerValue));
|
||||
DefineMap<Member, PropertyDataDto>(nameof(Member.BoolPropertyValue), nameof(PropertyDataDto.IntegerValue));
|
||||
DefineMap<Member, PropertyDataDto>(nameof(Member.LongStringPropertyValue), nameof(PropertyDataDto.TextValue));
|
||||
DefineMap<Member, PropertyDataDto>(nameof(Member.ShortStringPropertyValue), nameof(PropertyDataDto.VarcharValue));
|
||||
DefineMap<Member, PropertyTypeDto>(nameof(Member.PropertyTypeAlias), nameof(PropertyTypeDto.Alias));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Mappers
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a <see cref="MemberType"/> 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 (MemberType))]
|
||||
[MapperFor(typeof (IMemberType))]
|
||||
public sealed class MemberTypeMapper : BaseMapper
|
||||
{
|
||||
public MemberTypeMapper(Lazy<ISqlContext> sqlContext, ConcurrentDictionary<Type, ConcurrentDictionary<string, string>> maps)
|
||||
: base(sqlContext, maps)
|
||||
{ }
|
||||
|
||||
protected override void DefineMaps()
|
||||
{
|
||||
DefineMap<MemberType, NodeDto>(nameof(MemberType.Id), nameof(NodeDto.NodeId));
|
||||
DefineMap<MemberType, NodeDto>(nameof(MemberType.CreateDate), nameof(NodeDto.CreateDate));
|
||||
DefineMap<MemberType, NodeDto>(nameof(MemberType.Level), nameof(NodeDto.Level));
|
||||
DefineMap<MemberType, NodeDto>(nameof(MemberType.ParentId), nameof(NodeDto.ParentId));
|
||||
DefineMap<MemberType, NodeDto>(nameof(MemberType.Path), nameof(NodeDto.Path));
|
||||
DefineMap<MemberType, NodeDto>(nameof(MemberType.SortOrder), nameof(NodeDto.SortOrder));
|
||||
DefineMap<MemberType, NodeDto>(nameof(MemberType.Name), nameof(NodeDto.Text));
|
||||
DefineMap<MemberType, NodeDto>(nameof(MemberType.Trashed), nameof(NodeDto.Trashed));
|
||||
DefineMap<MemberType, NodeDto>(nameof(MemberType.Key), nameof(NodeDto.UniqueId));
|
||||
DefineMap<MemberType, NodeDto>(nameof(MemberType.CreatorId), nameof(NodeDto.UserId));
|
||||
DefineMap<MemberType, ContentTypeDto>(nameof(MemberType.Alias), nameof(ContentTypeDto.Alias));
|
||||
DefineMap<MemberType, ContentTypeDto>(nameof(MemberType.AllowedAsRoot), nameof(ContentTypeDto.AllowAtRoot));
|
||||
DefineMap<MemberType, ContentTypeDto>(nameof(MemberType.Description), nameof(ContentTypeDto.Description));
|
||||
DefineMap<MemberType, ContentTypeDto>(nameof(MemberType.Icon), nameof(ContentTypeDto.Icon));
|
||||
DefineMap<MemberType, ContentTypeDto>(nameof(MemberType.IsContainer), nameof(ContentTypeDto.IsContainer));
|
||||
DefineMap<MemberType, ContentTypeDto>(nameof(MemberType.IsElement), nameof(ContentTypeDto.IsElement));
|
||||
DefineMap<MemberType, ContentTypeDto>(nameof(MemberType.Thumbnail), nameof(ContentTypeDto.Thumbnail));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Mappers
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a <see cref="PropertyGroup"/> 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(PropertyGroup))]
|
||||
public sealed class PropertyGroupMapper : BaseMapper
|
||||
{
|
||||
public PropertyGroupMapper(Lazy<ISqlContext> sqlContext, ConcurrentDictionary<Type, ConcurrentDictionary<string, string>> maps)
|
||||
: base(sqlContext, maps)
|
||||
{ }
|
||||
|
||||
protected override void DefineMaps()
|
||||
{
|
||||
DefineMap<PropertyGroup, PropertyTypeGroupDto>(nameof(PropertyGroup.Id), nameof(PropertyTypeGroupDto.Id));
|
||||
DefineMap<PropertyGroup, PropertyTypeGroupDto>(nameof(PropertyGroup.Key), nameof(PropertyTypeGroupDto.UniqueId));
|
||||
DefineMap<PropertyGroup, PropertyTypeGroupDto>(nameof(PropertyGroup.SortOrder), nameof(PropertyTypeGroupDto.SortOrder));
|
||||
DefineMap<PropertyGroup, PropertyTypeGroupDto>(nameof(PropertyGroup.Name), nameof(PropertyTypeGroupDto.Text));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Mappers
|
||||
{
|
||||
[MapperFor(typeof(Property))]
|
||||
public sealed class PropertyMapper : BaseMapper
|
||||
{
|
||||
public PropertyMapper(Lazy<ISqlContext> sqlContext, ConcurrentDictionary<Type, ConcurrentDictionary<string, string>> maps)
|
||||
: base(sqlContext, maps)
|
||||
{ }
|
||||
|
||||
protected override void DefineMaps()
|
||||
{
|
||||
DefineMap<Property, PropertyDataDto>(nameof(Property.Id), nameof(PropertyDataDto.Id));
|
||||
DefineMap<Property, PropertyDataDto>(nameof(Property.PropertyTypeId), nameof(PropertyDataDto.PropertyTypeId));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Mappers
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a <see cref="IPropertyType"/> 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(PropertyType))]
|
||||
public sealed class PropertyTypeMapper : BaseMapper
|
||||
{
|
||||
public PropertyTypeMapper(Lazy<ISqlContext> sqlContext, ConcurrentDictionary<Type, ConcurrentDictionary<string, string>> maps)
|
||||
: base(sqlContext, maps)
|
||||
{ }
|
||||
|
||||
protected override void DefineMaps()
|
||||
{
|
||||
DefineMap<PropertyType, PropertyTypeDto>(nameof(PropertyType.Key), nameof(PropertyTypeDto.UniqueId));
|
||||
DefineMap<PropertyType, PropertyTypeDto>(nameof(PropertyType.Id), nameof(PropertyTypeDto.Id));
|
||||
DefineMap<PropertyType, PropertyTypeDto>(nameof(PropertyType.Alias), nameof(PropertyTypeDto.Alias));
|
||||
DefineMap<PropertyType, PropertyTypeDto>(nameof(PropertyType.DataTypeId), nameof(PropertyTypeDto.DataTypeId));
|
||||
DefineMap<PropertyType, PropertyTypeDto>(nameof(PropertyType.Description), nameof(PropertyTypeDto.Description));
|
||||
DefineMap<PropertyType, PropertyTypeDto>(nameof(PropertyType.Mandatory), nameof(PropertyTypeDto.Mandatory));
|
||||
DefineMap<PropertyType, PropertyTypeDto>(nameof(PropertyType.MandatoryMessage), nameof(PropertyTypeDto.MandatoryMessage));
|
||||
DefineMap<PropertyType, PropertyTypeDto>(nameof(PropertyType.Name), nameof(PropertyTypeDto.Name));
|
||||
DefineMap<PropertyType, PropertyTypeDto>(nameof(PropertyType.SortOrder), nameof(PropertyTypeDto.SortOrder));
|
||||
DefineMap<PropertyType, PropertyTypeDto>(nameof(PropertyType.ValidationRegExp), nameof(PropertyTypeDto.ValidationRegExp));
|
||||
DefineMap<PropertyType, PropertyTypeDto>(nameof(PropertyType.ValidationRegExpMessage), nameof(PropertyTypeDto.ValidationRegExpMessage));
|
||||
DefineMap<PropertyType, DataTypeDto>(nameof(PropertyType.PropertyEditorAlias), nameof(DataTypeDto.EditorAlias));
|
||||
DefineMap<PropertyType, DataTypeDto>(nameof(PropertyType.ValueStorageType), nameof(DataTypeDto.DbType));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Mappers
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a <see cref="Relation"/> 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(IRelation))]
|
||||
[MapperFor(typeof(Relation))]
|
||||
public sealed class RelationMapper : BaseMapper
|
||||
{
|
||||
public RelationMapper(Lazy<ISqlContext> sqlContext, ConcurrentDictionary<Type, ConcurrentDictionary<string, string>> maps)
|
||||
: base(sqlContext, maps)
|
||||
{ }
|
||||
|
||||
protected override void DefineMaps()
|
||||
{
|
||||
DefineMap<Relation, RelationDto>(nameof(Relation.Id), nameof(RelationDto.Id));
|
||||
DefineMap<Relation, RelationDto>(nameof(Relation.ChildId), nameof(RelationDto.ChildId));
|
||||
DefineMap<Relation, RelationDto>(nameof(Relation.Comment), nameof(RelationDto.Comment));
|
||||
DefineMap<Relation, RelationDto>(nameof(Relation.CreateDate), nameof(RelationDto.Datetime));
|
||||
DefineMap<Relation, RelationDto>(nameof(Relation.ParentId), nameof(RelationDto.ParentId));
|
||||
DefineMap<Relation, RelationDto>(nameof(Relation.RelationTypeId), nameof(RelationDto.RelationType));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Mappers
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a <see cref="RelationType"/> 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(RelationType))]
|
||||
[MapperFor(typeof(IRelationType))]
|
||||
public sealed class RelationTypeMapper : BaseMapper
|
||||
{
|
||||
public RelationTypeMapper(Lazy<ISqlContext> sqlContext, ConcurrentDictionary<Type, ConcurrentDictionary<string, string>> maps)
|
||||
: base(sqlContext, maps)
|
||||
{ }
|
||||
|
||||
protected override void DefineMaps()
|
||||
{
|
||||
DefineMap<RelationType, RelationTypeDto>(nameof(RelationType.Id), nameof(RelationTypeDto.Id));
|
||||
DefineMap<RelationType, RelationTypeDto>(nameof(RelationType.Alias), nameof(RelationTypeDto.Alias));
|
||||
DefineMap<RelationType, RelationTypeDto>(nameof(RelationType.ChildObjectType), nameof(RelationTypeDto.ChildObjectType));
|
||||
DefineMap<RelationType, RelationTypeDto>(nameof(RelationType.IsBidirectional), nameof(RelationTypeDto.Dual));
|
||||
DefineMap<RelationType, RelationTypeDto>(nameof(RelationType.Name), nameof(RelationTypeDto.Name));
|
||||
DefineMap<RelationType, RelationTypeDto>(nameof(RelationType.ParentObjectType), nameof(RelationTypeDto.ParentObjectType));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Mappers
|
||||
{
|
||||
[MapperFor(typeof(ServerRegistration))]
|
||||
[MapperFor(typeof(IServerRegistration))]
|
||||
internal sealed class ServerRegistrationMapper : BaseMapper
|
||||
{
|
||||
public ServerRegistrationMapper(Lazy<ISqlContext> sqlContext, ConcurrentDictionary<Type, ConcurrentDictionary<string, string>> maps)
|
||||
: base(sqlContext, maps)
|
||||
{ }
|
||||
|
||||
protected override void DefineMaps()
|
||||
{
|
||||
DefineMap<ServerRegistration, ServerRegistrationDto>(nameof(ServerRegistration.Id), nameof(ServerRegistrationDto.Id));
|
||||
DefineMap<ServerRegistration, ServerRegistrationDto>(nameof(ServerRegistration.IsActive), nameof(ServerRegistrationDto.IsActive));
|
||||
DefineMap<ServerRegistration, ServerRegistrationDto>(nameof(ServerRegistration.IsMaster), nameof(ServerRegistrationDto.IsMaster));
|
||||
DefineMap<ServerRegistration, ServerRegistrationDto>(nameof(ServerRegistration.ServerAddress), nameof(ServerRegistrationDto.ServerAddress));
|
||||
DefineMap<ServerRegistration, ServerRegistrationDto>(nameof(ServerRegistration.CreateDate), nameof(ServerRegistrationDto.DateRegistered));
|
||||
DefineMap<ServerRegistration, ServerRegistrationDto>(nameof(ServerRegistration.UpdateDate), nameof(ServerRegistrationDto.DateAccessed));
|
||||
DefineMap<ServerRegistration, ServerRegistrationDto>(nameof(ServerRegistration.ServerIdentity), nameof(ServerRegistrationDto.ServerIdentity));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Mappers
|
||||
{
|
||||
// TODO: This mapper is actually very useless because the only time it would ever be used is when trying to generate a strongly typed query
|
||||
// on an IContentBase object which is what exposes ISimpleContentType, however the queries that we execute in the content repositories don't actually
|
||||
// join on the content type table. The content type data is resolved outside of the query so the end result of the query that is generated by using
|
||||
// this mapper will either fail or the syntax will target umbracoNode which will be filtering on the actual content NOT the content type.
|
||||
// I'm leaving this here purely because the ExpressionTests rely on this which is fine for testing that the expressions work, but note that this
|
||||
// resulting query will not.
|
||||
|
||||
[MapperFor(typeof(ISimpleContentType))]
|
||||
[MapperFor(typeof(SimpleContentType))]
|
||||
public sealed class SimpleContentTypeMapper : BaseMapper
|
||||
{
|
||||
public SimpleContentTypeMapper(Lazy<ISqlContext> sqlContext, ConcurrentDictionary<Type, ConcurrentDictionary<string, string>> maps)
|
||||
: base(sqlContext, maps)
|
||||
{ }
|
||||
|
||||
protected override void DefineMaps()
|
||||
{
|
||||
// There is no reason for using ContentType here instead of SimpleContentType, in fact the underlying DefineMap call does nothing with the first type parameter
|
||||
|
||||
DefineMap<ContentType, NodeDto>(nameof(ContentType.Id), nameof(NodeDto.NodeId));
|
||||
DefineMap<ContentType, NodeDto>(nameof(ContentType.Key), nameof(NodeDto.UniqueId));
|
||||
DefineMap<ContentType, NodeDto>(nameof(ContentType.Name), nameof(NodeDto.Text));
|
||||
DefineMap<ContentType, ContentTypeDto>(nameof(ContentType.Alias), nameof(ContentTypeDto.Alias));
|
||||
DefineMap<ContentType, ContentTypeDto>(nameof(ContentType.Icon), nameof(ContentTypeDto.Icon));
|
||||
DefineMap<ContentType, ContentTypeDto>(nameof(ContentType.IsContainer), nameof(ContentTypeDto.IsContainer));
|
||||
DefineMap<ContentType, ContentTypeDto>(nameof(ContentType.AllowedAsRoot), nameof(ContentTypeDto.AllowAtRoot));
|
||||
DefineMap<ContentType, ContentTypeDto>(nameof(ContentType.IsElement), nameof(ContentTypeDto.IsElement));
|
||||
}
|
||||
}
|
||||
}
|
||||
28
src/Umbraco.Infrastructure/Persistence/Mappers/TagMapper.cs
Normal file
28
src/Umbraco.Infrastructure/Persistence/Mappers/TagMapper.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Mappers
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a <see cref="Tag"/> 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(Tag))]
|
||||
[MapperFor(typeof(ITag))]
|
||||
public sealed class TagMapper : BaseMapper
|
||||
{
|
||||
public TagMapper(Lazy<ISqlContext> sqlContext, ConcurrentDictionary<Type, ConcurrentDictionary<string, string>> maps)
|
||||
: base(sqlContext, maps)
|
||||
{ }
|
||||
|
||||
protected override void DefineMaps()
|
||||
{
|
||||
DefineMap<Tag, TagDto>(nameof(Tag.Id), nameof(TagDto.Id));
|
||||
DefineMap<Tag, TagDto>(nameof(Tag.Text), nameof(TagDto.Text));
|
||||
DefineMap<Tag, TagDto>(nameof(Tag.Group), nameof(TagDto.Group));
|
||||
DefineMap<Tag, TagDto>(nameof(Tag.LanguageId), nameof(TagDto.LanguageId));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
|
||||
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
|
||||
{
|
||||
public TemplateMapper(Lazy<ISqlContext> sqlContext, ConcurrentDictionary<Type, ConcurrentDictionary<string, string>> maps)
|
||||
: base(sqlContext, maps)
|
||||
{ }
|
||||
|
||||
protected override void DefineMaps()
|
||||
{
|
||||
DefineMap<Template, TemplateDto>(nameof(Template.Id), nameof(TemplateDto.NodeId));
|
||||
DefineMap<Template, NodeDto>(nameof(Template.MasterTemplateId), nameof(NodeDto.ParentId));
|
||||
DefineMap<Template, NodeDto>(nameof(Template.Key), nameof(NodeDto.UniqueId));
|
||||
DefineMap<Template, TemplateDto>(nameof(Template.Alias), nameof(TemplateDto.Alias));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using Umbraco.Core.Models.Entities;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Mappers
|
||||
{
|
||||
[MapperFor(typeof (IUmbracoEntity))]
|
||||
public sealed class UmbracoEntityMapper : BaseMapper
|
||||
{
|
||||
public UmbracoEntityMapper(Lazy<ISqlContext> sqlContext, ConcurrentDictionary<Type, ConcurrentDictionary<string, string>> maps)
|
||||
: base(sqlContext, maps)
|
||||
{ }
|
||||
|
||||
protected override void DefineMaps()
|
||||
{
|
||||
DefineMap<IUmbracoEntity, NodeDto>(nameof(IUmbracoEntity.Id), nameof(NodeDto.NodeId));
|
||||
DefineMap<IUmbracoEntity, NodeDto>(nameof(IUmbracoEntity.CreateDate), nameof(NodeDto.CreateDate));
|
||||
DefineMap<IUmbracoEntity, NodeDto>(nameof(IUmbracoEntity.Level), nameof(NodeDto.Level));
|
||||
DefineMap<IUmbracoEntity, NodeDto>(nameof(IUmbracoEntity.ParentId), nameof(NodeDto.ParentId));
|
||||
DefineMap<IUmbracoEntity, NodeDto>(nameof(IUmbracoEntity.Path), nameof(NodeDto.Path));
|
||||
DefineMap<IUmbracoEntity, NodeDto>(nameof(IUmbracoEntity.SortOrder), nameof(NodeDto.SortOrder));
|
||||
DefineMap<IUmbracoEntity, NodeDto>(nameof(IUmbracoEntity.Name), nameof(NodeDto.Text));
|
||||
DefineMap<IUmbracoEntity, NodeDto>(nameof(IUmbracoEntity.Trashed), nameof(NodeDto.Trashed));
|
||||
DefineMap<IUmbracoEntity, NodeDto>(nameof(IUmbracoEntity.Key), nameof(NodeDto.UniqueId));
|
||||
DefineMap<IUmbracoEntity, NodeDto>(nameof(IUmbracoEntity.CreatorId), nameof(NodeDto.UserId));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Mappers
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a <see cref="UserGroup"/> 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(IUserGroup))]
|
||||
[MapperFor(typeof(UserGroup))]
|
||||
public sealed class UserGroupMapper : BaseMapper
|
||||
{
|
||||
public UserGroupMapper(Lazy<ISqlContext> sqlContext, ConcurrentDictionary<Type, ConcurrentDictionary<string, string>> maps)
|
||||
: base(sqlContext, maps)
|
||||
{ }
|
||||
|
||||
protected override void DefineMaps()
|
||||
{
|
||||
DefineMap<UserGroup, UserGroupDto>(nameof(UserGroup.Id), nameof(UserGroupDto.Id));
|
||||
DefineMap<UserGroup, UserGroupDto>(nameof(UserGroup.Alias), nameof(UserGroupDto.Alias));
|
||||
DefineMap<UserGroup, UserGroupDto>(nameof(UserGroup.Name), nameof(UserGroupDto.Name));
|
||||
DefineMap<UserGroup, UserGroupDto>(nameof(UserGroup.Icon), nameof(UserGroupDto.Icon));
|
||||
DefineMap<UserGroup, UserGroupDto>(nameof(UserGroup.StartContentId), nameof(UserGroupDto.StartContentId));
|
||||
DefineMap<UserGroup, UserGroupDto>(nameof(UserGroup.StartMediaId), nameof(UserGroupDto.StartMediaId));
|
||||
}
|
||||
}
|
||||
}
|
||||
36
src/Umbraco.Infrastructure/Persistence/Mappers/UserMapper.cs
Normal file
36
src/Umbraco.Infrastructure/Persistence/Mappers/UserMapper.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Mappers
|
||||
{
|
||||
[MapperFor(typeof(IUser))]
|
||||
[MapperFor(typeof(User))]
|
||||
public sealed class UserMapper : BaseMapper
|
||||
{
|
||||
public UserMapper(Lazy<ISqlContext> sqlContext, ConcurrentDictionary<Type, ConcurrentDictionary<string, string>> maps)
|
||||
: base(sqlContext, maps)
|
||||
{ }
|
||||
|
||||
protected override void DefineMaps()
|
||||
{
|
||||
DefineMap<User, UserDto>(nameof(User.Id), nameof(UserDto.Id));
|
||||
DefineMap<User, UserDto>(nameof(User.Email), nameof(UserDto.Email));
|
||||
DefineMap<User, UserDto>(nameof(User.Username), nameof(UserDto.Login));
|
||||
DefineMap<User, UserDto>(nameof(User.RawPasswordValue), nameof(UserDto.Password));
|
||||
DefineMap<User, UserDto>(nameof(User.Name), nameof(UserDto.UserName));
|
||||
//NOTE: This column in the db is *not* used!
|
||||
//DefineMap<User, UserDto>(nameof(User.DefaultPermissions), nameof(UserDto.DefaultPermissions));
|
||||
DefineMap<User, UserDto>(nameof(User.IsApproved), nameof(UserDto.Disabled));
|
||||
DefineMap<User, UserDto>(nameof(User.IsLockedOut), nameof(UserDto.NoConsole));
|
||||
DefineMap<User, UserDto>(nameof(User.Language), nameof(UserDto.UserLanguage));
|
||||
DefineMap<User, UserDto>(nameof(User.CreateDate), nameof(UserDto.CreateDate));
|
||||
DefineMap<User, UserDto>(nameof(User.UpdateDate), nameof(UserDto.UpdateDate));
|
||||
DefineMap<User, UserDto>(nameof(User.LastLockoutDate), nameof(UserDto.LastLockoutDate));
|
||||
DefineMap<User, UserDto>(nameof(User.LastLoginDate), nameof(UserDto.LastLoginDate));
|
||||
DefineMap<User, UserDto>(nameof(User.LastPasswordChangeDate), nameof(UserDto.LastPasswordChangeDate));
|
||||
DefineMap<User, UserDto>(nameof(User.SecurityStamp), nameof(UserDto.SecurityStampToken));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using System.Collections.Concurrent;
|
||||
using Umbraco.Core.Models;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Mappers
|
||||
{
|
||||
//[MapperFor(typeof(UserSection))]
|
||||
//public sealed class UserSectionMapper : 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 UserSectionMapper()
|
||||
// {
|
||||
// BuildMap();
|
||||
// }
|
||||
|
||||
// #region Overrides of BaseMapper
|
||||
|
||||
// internal override ConcurrentDictionary<string, DtoMapModel> PropertyInfoCache
|
||||
// {
|
||||
// get { return PropertyInfoCacheInstance; }
|
||||
// }
|
||||
|
||||
// internal override void BuildMap()
|
||||
// {
|
||||
// CacheMap<UserSection, User2AppDto>(src => src.UserId, dto => dto.UserId);
|
||||
// CacheMap<UserSection, User2AppDto>(src => src.SectionAlias, dto => dto.AppAlias);
|
||||
// }
|
||||
|
||||
// #endregion
|
||||
//}
|
||||
}
|
||||
Reference in New Issue
Block a user