using System.Collections.Concurrent; using Umbraco.Core.Models.EntityBase; using Umbraco.Core.Models; using Umbraco.Core.Models.Rdbms; namespace Umbraco.Core.Persistence.Mappers { /// /// Represents a to DTO mapper used to translate the properties of the public api /// implementation to that of the database's DTO as sql: [tableName].[columnName]. /// [MapperFor(typeof(IMember))] [MapperFor(typeof(Member))] public sealed class MemberMapper : BaseMapper { private static readonly ConcurrentDictionary PropertyInfoCacheInstance = new ConcurrentDictionary(); //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 MemberMapper() { BuildMap(); } #region Overrides of BaseMapper internal override ConcurrentDictionary PropertyInfoCache { get { return PropertyInfoCacheInstance; } } internal override void BuildMap() { CacheMap(src => src.Id, dto => dto.NodeId); CacheMap(src => src.CreateDate, dto => dto.CreateDate); CacheMap(src => ((IUmbracoEntity)src).Level, dto => dto.Level); CacheMap(src => ((IUmbracoEntity)src).ParentId, dto => dto.ParentId); CacheMap(src => ((IUmbracoEntity)src).Path, dto => dto.Path); CacheMap(src => ((IUmbracoEntity)src).SortOrder, dto => dto.SortOrder); CacheMap(src => ((IUmbracoEntity)src).CreatorId, dto => dto.UserId); CacheMap(src => src.Name, dto => dto.Text); CacheMap(src => src.Trashed, dto => dto.Trashed); CacheMap(src => src.Key, dto => dto.UniqueId); CacheMap(src => src.ContentTypeId, dto => dto.ContentTypeId); CacheMap(src => src.ContentTypeAlias, dto => dto.Alias); CacheMap(src => src.UpdateDate, dto => dto.VersionDate); CacheMap(src => src.Version, dto => dto.VersionId); CacheMap(src => src.Email, dto => dto.Email); CacheMap(src => src.Username, dto => dto.LoginName); CacheMap(src => src.RawPasswordValue, dto => dto.Password); CacheMap(src => src.IsApproved, dto => dto.Integer); CacheMap(src => src.IsLockedOut, dto => dto.Integer); CacheMap(src => src.Comments, dto => dto.Text); CacheMap(src => src.RawPasswordAnswerValue, dto => dto.VarChar); CacheMap(src => src.PasswordQuestion, dto => dto.VarChar); CacheMap(src => src.FailedPasswordAttempts, dto => dto.Integer); CacheMap(src => src.LastLockoutDate, dto => dto.Date); CacheMap(src => src.LastLoginDate, dto => dto.Date); CacheMap(src => src.LastPasswordChangeDate, dto => dto.Date); /* Internal experiment */ CacheMap(src => src.DateTimePropertyValue, dto => dto.Date); CacheMap(src => src.IntegerPropertyValue, dto => dto.Integer); CacheMap(src => src.BoolPropertyValue, dto => dto.Integer); CacheMap(src => src.LongStringPropertyValue, dto => dto.Text); CacheMap(src => src.ShortStringPropertyValue, dto => dto.VarChar); CacheMap(src => src.PropertyTypeAlias, dto => dto.Alias); } #endregion } }