Changed how model mappers work for persistence objects so we don't have to statically associate the mapper.

This commit is contained in:
Shannon Deminick
2013-03-07 22:27:47 +06:00
parent 0230bedeb6
commit da331b7408
57 changed files with 218 additions and 142 deletions

View File

@@ -3,6 +3,7 @@ using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
using Umbraco.Core.Persistence.Mappers;
namespace Umbraco.Core.Models
{
@@ -11,6 +12,7 @@ namespace Umbraco.Core.Models
/// </summary>
[Serializable]
[DataContract(IsReference = true)]
[Mapper(typeof(ContentMapper))]
public class Content : ContentBase, IContent
{
private IContentType _contentType;

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
using Umbraco.Core.Persistence.Mappers;
namespace Umbraco.Core.Models
{
@@ -11,6 +12,7 @@ namespace Umbraco.Core.Models
/// </summary>
[Serializable]
[DataContract(IsReference = true)]
[Mapper(typeof(ContentTypeMapper))]
public class ContentType : ContentTypeCompositionBase, IContentType
{
private int _defaultTemplate;

View File

@@ -2,6 +2,7 @@
using System.Reflection;
using System.Runtime.Serialization;
using Umbraco.Core.Models.EntityBase;
using Umbraco.Core.Persistence.Mappers;
namespace Umbraco.Core.Models
{
@@ -14,6 +15,7 @@ namespace Umbraco.Core.Models
/// </remarks>
[Serializable]
[DataContract(IsReference = true)]
[Mapper(typeof(DataTypeDefinitionMapper))]
public class DataTypeDefinition : Entity, IDataTypeDefinition
{
private int _parentId;

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Reflection;
using System.Runtime.Serialization;
using Umbraco.Core.Models.EntityBase;
using Umbraco.Core.Persistence.Mappers;
namespace Umbraco.Core.Models
{
@@ -11,6 +12,7 @@ namespace Umbraco.Core.Models
/// </summary>
[Serializable]
[DataContract(IsReference = true)]
[Mapper(typeof(DictionaryMapper))]
public class DictionaryItem : Entity, IDictionaryItem
{
private Guid _parentId;

View File

@@ -2,6 +2,7 @@
using System.Reflection;
using System.Runtime.Serialization;
using Umbraco.Core.Models.EntityBase;
using Umbraco.Core.Persistence.Mappers;
namespace Umbraco.Core.Models
{
@@ -10,6 +11,7 @@ namespace Umbraco.Core.Models
/// </summary>
[Serializable]
[DataContract(IsReference = true)]
[Mapper(typeof(DictionaryTranslationMapper))]
public class DictionaryTranslation : Entity, IDictionaryTranslation
{
private ILanguage _language;

View File

@@ -1,11 +1,13 @@
using System;
using System.Diagnostics;
using Umbraco.Core.Persistence.Mappers;
namespace Umbraco.Core.Models
{
/// <summary>
/// Defines a Content object
/// </summary>
[Mapper(typeof(ContentMapper))]
public interface IContent : IContentBase
{
/// <summary>

View File

@@ -1,10 +1,12 @@
using System.Collections.Generic;
using Umbraco.Core.Persistence.Mappers;
namespace Umbraco.Core.Models
{
/// <summary>
/// Defines a ContentType, which Content is based on
/// </summary>
[Mapper(typeof(ContentTypeMapper))]
public interface IContentType : IContentTypeComposition
{
/// <summary>

View File

@@ -1,8 +1,10 @@
using System;
using Umbraco.Core.Models.EntityBase;
using Umbraco.Core.Persistence.Mappers;
namespace Umbraco.Core.Models
{
[Mapper(typeof(DataTypeDefinitionMapper))]
public interface IDataTypeDefinition : IUmbracoEntity
{
/// <summary>

View File

@@ -2,9 +2,11 @@ using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using Umbraco.Core.Models.EntityBase;
using Umbraco.Core.Persistence.Mappers;
namespace Umbraco.Core.Models
{
[Mapper(typeof(DictionaryMapper))]
public interface IDictionaryItem : IAggregateRoot
{
/// <summary>

View File

@@ -1,8 +1,10 @@
using System.Runtime.Serialization;
using Umbraco.Core.Models.EntityBase;
using Umbraco.Core.Persistence.Mappers;
namespace Umbraco.Core.Models
{
[Mapper(typeof(DictionaryTranslationMapper))]
public interface IDictionaryTranslation : IEntity
{
/// <summary>

View File

@@ -1,9 +1,11 @@
using System.Globalization;
using System.Runtime.Serialization;
using Umbraco.Core.Models.EntityBase;
using Umbraco.Core.Persistence.Mappers;
namespace Umbraco.Core.Models
{
[Mapper(typeof(LanguageMapper))]
public interface ILanguage : IAggregateRoot
{
/// <summary>

View File

@@ -1,5 +1,8 @@
namespace Umbraco.Core.Models
using Umbraco.Core.Persistence.Mappers;
namespace Umbraco.Core.Models
{
[Mapper(typeof(MediaMapper))]
public interface IMedia : IContentBase
{
/// <summary>

View File

@@ -1,8 +1,11 @@
namespace Umbraco.Core.Models
using Umbraco.Core.Persistence.Mappers;
namespace Umbraco.Core.Models
{
/// <summary>
/// Defines a ContentType, which Media is based on
/// </summary>
[Mapper(typeof(MediaTypeMapper))]
public interface IMediaType : IContentTypeComposition
{

View File

@@ -3,6 +3,7 @@ using System.Globalization;
using System.Reflection;
using System.Runtime.Serialization;
using Umbraco.Core.Models.EntityBase;
using Umbraco.Core.Persistence.Mappers;
namespace Umbraco.Core.Models
{
@@ -11,6 +12,7 @@ namespace Umbraco.Core.Models
/// </summary>
[Serializable]
[DataContract(IsReference = true)]
[Mapper(typeof(LanguageMapper))]
public class Language : Entity, ILanguage
{
private string _isoCode;

View File

@@ -1,5 +1,6 @@
using System;
using System.Runtime.Serialization;
using Umbraco.Core.Persistence.Mappers;
namespace Umbraco.Core.Models
{
@@ -8,6 +9,7 @@ namespace Umbraco.Core.Models
/// </summary>
[Serializable]
[DataContract(IsReference = true)]
[Mapper(typeof(MediaMapper))]
public class Media : ContentBase, IMedia
{
private IMediaType _contentType;

View File

@@ -1,5 +1,6 @@
using System;
using System.Runtime.Serialization;
using Umbraco.Core.Persistence.Mappers;
namespace Umbraco.Core.Models
{
@@ -8,6 +9,7 @@ namespace Umbraco.Core.Models
/// </summary>
[Serializable]
[DataContract(IsReference = true)]
[Mapper(typeof(MediaTypeMapper))]
public class MediaType : ContentTypeCompositionBase, IMediaType
{
public MediaType(int parentId) : base(parentId)

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using Umbraco.Core.Persistence.Mappers;
namespace Umbraco.Core.Models.Membership
{
@@ -6,6 +7,7 @@ namespace Umbraco.Core.Models.Membership
/// Defines the interface for a <see cref="User"/>
/// </summary>
/// <remarks>Will be left internal until a proper Membership implementation is part of the roadmap</remarks>
[Mapper(typeof(UserMapper))]
internal interface IUser : IMembershipUser
{
string Name { get; set; }

View File

@@ -1,7 +1,9 @@
using Umbraco.Core.Models.EntityBase;
using Umbraco.Core.Persistence.Mappers;
namespace Umbraco.Core.Models.Membership
{
[Mapper(typeof(UserTypeMapper))]
internal interface IUserType : IAggregateRoot
{
string Alias { get; set; }

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using Umbraco.Core.Models.EntityBase;
using Umbraco.Core.Persistence.Mappers;
namespace Umbraco.Core.Models.Membership
{
@@ -15,6 +16,7 @@ namespace Umbraco.Core.Models.Membership
/// </remarks>
[Serializable]
[DataContract(IsReference = true)]
[Mapper(typeof(UserMapper))]
internal class User : UserProfile, IUser
{
private bool _hasIdentity;

View File

@@ -1,6 +1,7 @@
using System;
using System.Runtime.Serialization;
using Umbraco.Core.Models.EntityBase;
using Umbraco.Core.Persistence.Mappers;
namespace Umbraco.Core.Models.Membership
{
@@ -13,6 +14,7 @@ namespace Umbraco.Core.Models.Membership
/// </remarks>
[Serializable]
[DataContract(IsReference = true)]
[Mapper(typeof(UserTypeMapper))]
internal class UserType : Entity, IUserType
{
[DataMember]

View File

@@ -2,6 +2,7 @@
using System.Reflection;
using System.Runtime.Serialization;
using Umbraco.Core.Models.EntityBase;
using Umbraco.Core.Persistence.Mappers;
namespace Umbraco.Core.Models
{
@@ -10,6 +11,7 @@ namespace Umbraco.Core.Models
/// </summary>
[Serializable]
[DataContract(IsReference = true)]
[Mapper(typeof(PropertyMapper))]
public class Property : Entity
{
private readonly PropertyType _propertyType;

View File

@@ -3,6 +3,7 @@ using System.Collections.Specialized;
using System.Reflection;
using System.Runtime.Serialization;
using Umbraco.Core.Models.EntityBase;
using Umbraco.Core.Persistence.Mappers;
namespace Umbraco.Core.Models
{
@@ -11,6 +12,7 @@ namespace Umbraco.Core.Models
/// </summary>
[Serializable]
[DataContract(IsReference = true)]
[Mapper(typeof(PropertyGroupMapper))]
public class PropertyGroup : Entity, IEquatable<PropertyGroup>
{
private string _name;

View File

@@ -3,6 +3,7 @@ using System.Reflection;
using System.Runtime.Serialization;
using System.Text.RegularExpressions;
using Umbraco.Core.Models.EntityBase;
using Umbraco.Core.Persistence.Mappers;
namespace Umbraco.Core.Models
{
@@ -11,6 +12,7 @@ namespace Umbraco.Core.Models
/// </summary>
[Serializable]
[DataContract(IsReference = true)]
[Mapper(typeof(PropertyTypeMapper))]
public class PropertyType : Entity, IEquatable<PropertyType>
{
//private SerializationService _service;

View File

@@ -2,6 +2,7 @@
using System.Reflection;
using System.Runtime.Serialization;
using Umbraco.Core.Models.EntityBase;
using Umbraco.Core.Persistence.Mappers;
namespace Umbraco.Core.Models
{
@@ -10,6 +11,7 @@ namespace Umbraco.Core.Models
/// </summary>
[Serializable]
[DataContract(IsReference = true)]
[Mapper(typeof(RelationMapper))]
public class Relation : Entity, IAggregateRoot
{
//NOTE: The datetime column from umbracoRelation is set on CreateDate on the Entity

View File

@@ -2,6 +2,7 @@ using System;
using System.Reflection;
using System.Runtime.Serialization;
using Umbraco.Core.Models.EntityBase;
using Umbraco.Core.Persistence.Mappers;
namespace Umbraco.Core.Models
{
@@ -10,6 +11,7 @@ namespace Umbraco.Core.Models
/// </summary>
[Serializable]
[DataContract(IsReference = true)]
[Mapper(typeof(RelationTypeMapper))]
public class RelationType : Entity, IAggregateRoot
{
private string _name;

View File

@@ -5,7 +5,7 @@ using Umbraco.Core.Sync;
namespace Umbraco.Core.Models
{
[Mapper(typeof(ServerRegistrationMapper))]
internal class ServerRegistration : Entity, IServerAddress, IAggregateRoot
{
public ServerRegistration()