diff --git a/src/Umbraco.Core/Cache/CacheRefresherBase.cs b/src/Umbraco.Core/Cache/CacheRefresherBase.cs
index 568c955eda..bb0aa9f589 100644
--- a/src/Umbraco.Core/Cache/CacheRefresherBase.cs
+++ b/src/Umbraco.Core/Cache/CacheRefresherBase.cs
@@ -100,7 +100,7 @@ namespace Umbraco.Core.Cache
///
/// The type of the entities.
protected void ClearAllIsolatedCacheByEntityType()
- where TEntity : class, IAggregateRoot
+ where TEntity : class, IEntity
{
CacheHelper.IsolatedRuntimeCache.ClearCache();
}
diff --git a/src/Umbraco.Core/Cache/DefaultRepositoryCachePolicy.cs b/src/Umbraco.Core/Cache/DefaultRepositoryCachePolicy.cs
index 4e668f064d..dde212988f 100644
--- a/src/Umbraco.Core/Cache/DefaultRepositoryCachePolicy.cs
+++ b/src/Umbraco.Core/Cache/DefaultRepositoryCachePolicy.cs
@@ -18,7 +18,7 @@ namespace Umbraco.Core.Cache
/// If options.GetAllCacheValidateCount then we check against the db when getting many entities.
///
internal class DefaultRepositoryCachePolicy : RepositoryCachePolicyBase
- where TEntity : class, IAggregateRoot
+ where TEntity : class, IEntity
{
private static readonly TEntity[] EmptyEntities = new TEntity[0]; // const
private readonly RepositoryCachePolicyOptions _options;
diff --git a/src/Umbraco.Core/Cache/FullDataSetRepositoryCachePolicy.cs b/src/Umbraco.Core/Cache/FullDataSetRepositoryCachePolicy.cs
index d28896e201..44eb00d5b9 100644
--- a/src/Umbraco.Core/Cache/FullDataSetRepositoryCachePolicy.cs
+++ b/src/Umbraco.Core/Cache/FullDataSetRepositoryCachePolicy.cs
@@ -19,7 +19,7 @@ namespace Umbraco.Core.Cache
/// keep as a whole in memory.
///
internal class FullDataSetRepositoryCachePolicy : RepositoryCachePolicyBase
- where TEntity : class, IAggregateRoot
+ where TEntity : class, IEntity
{
private readonly Func _entityGetId;
private readonly bool _expires;
diff --git a/src/Umbraco.Core/Cache/IRepositoryCachePolicy.cs b/src/Umbraco.Core/Cache/IRepositoryCachePolicy.cs
index 09d13cefec..e0a95290c6 100644
--- a/src/Umbraco.Core/Cache/IRepositoryCachePolicy.cs
+++ b/src/Umbraco.Core/Cache/IRepositoryCachePolicy.cs
@@ -6,7 +6,7 @@ using Umbraco.Core.Scoping;
namespace Umbraco.Core.Cache
{
internal interface IRepositoryCachePolicy
- where TEntity : class, IAggregateRoot
+ where TEntity : class, IEntity
{
///
/// Gets an entity from the cache, else from the repository.
diff --git a/src/Umbraco.Core/Cache/NoCacheRepositoryCachePolicy.cs b/src/Umbraco.Core/Cache/NoCacheRepositoryCachePolicy.cs
index a638a41ce3..035a9967e4 100644
--- a/src/Umbraco.Core/Cache/NoCacheRepositoryCachePolicy.cs
+++ b/src/Umbraco.Core/Cache/NoCacheRepositoryCachePolicy.cs
@@ -7,7 +7,7 @@ using Umbraco.Core.Scoping;
namespace Umbraco.Core.Cache
{
internal class NoCacheRepositoryCachePolicy : IRepositoryCachePolicy
- where TEntity : class, IAggregateRoot
+ where TEntity : class, IEntity
{
private NoCacheRepositoryCachePolicy() { }
diff --git a/src/Umbraco.Core/Cache/RepositoryCachePolicyBase.cs b/src/Umbraco.Core/Cache/RepositoryCachePolicyBase.cs
index e38dc0ac6b..6c656257a2 100644
--- a/src/Umbraco.Core/Cache/RepositoryCachePolicyBase.cs
+++ b/src/Umbraco.Core/Cache/RepositoryCachePolicyBase.cs
@@ -11,7 +11,7 @@ namespace Umbraco.Core.Cache
/// The type of the entity.
/// The type of the identifier.
internal abstract class RepositoryCachePolicyBase : IRepositoryCachePolicy
- where TEntity : class, IAggregateRoot
+ where TEntity : class, IEntity
{
private readonly IRuntimeCacheProvider _globalCache;
private readonly IScopeAccessor _scopeAccessor;
diff --git a/src/Umbraco.Core/Cache/SingleItemsOnlyRepositoryCachePolicy.cs b/src/Umbraco.Core/Cache/SingleItemsOnlyRepositoryCachePolicy.cs
index 9ffcbd2b71..a4bb63706a 100644
--- a/src/Umbraco.Core/Cache/SingleItemsOnlyRepositoryCachePolicy.cs
+++ b/src/Umbraco.Core/Cache/SingleItemsOnlyRepositoryCachePolicy.cs
@@ -14,7 +14,7 @@ namespace Umbraco.Core.Cache
/// Used by DictionaryRepository.
///
internal class SingleItemsOnlyRepositoryCachePolicy : DefaultRepositoryCachePolicy
- where TEntity : class, IAggregateRoot
+ where TEntity : class, IEntity
{
public SingleItemsOnlyRepositoryCachePolicy(IRuntimeCacheProvider cache, IScopeAccessor scopeAccessor, RepositoryCachePolicyOptions options)
: base(cache, scopeAccessor, options)
diff --git a/src/Umbraco.Core/Composing/CompositionRoots/RepositoryCompositionRoot.cs b/src/Umbraco.Core/Composing/CompositionRoots/RepositoryCompositionRoot.cs
index 1bac01adc6..c72ecb528f 100644
--- a/src/Umbraco.Core/Composing/CompositionRoots/RepositoryCompositionRoot.cs
+++ b/src/Umbraco.Core/Composing/CompositionRoots/RepositoryCompositionRoot.cs
@@ -39,7 +39,7 @@ namespace Umbraco.Core.Composing.CompositionRoots
container.RegisterSingleton();
container.RegisterSingleton();
container.RegisterSingleton();
- container.RegisterSingleton();
+ container.RegisterSingleton();
container.RegisterSingleton();
container.RegisterSingleton();
container.RegisterSingleton();
diff --git a/src/Umbraco.Core/Composing/Current.cs b/src/Umbraco.Core/Composing/Current.cs
index 8326be987f..98c0725819 100644
--- a/src/Umbraco.Core/Composing/Current.cs
+++ b/src/Umbraco.Core/Composing/Current.cs
@@ -147,6 +147,9 @@ namespace Umbraco.Core.Composing
public static ISqlContext SqlContext
=> Container.GetInstance();
+ public static IPublishedContentTypeFactory PublishedContentTypeFactory
+ => Container.GetInstance();
+
#endregion
}
}
diff --git a/src/Umbraco.Core/KeyValuePairExtensions.cs b/src/Umbraco.Core/KeyValuePairExtensions.cs
new file mode 100644
index 0000000000..30fd3fee50
--- /dev/null
+++ b/src/Umbraco.Core/KeyValuePairExtensions.cs
@@ -0,0 +1,20 @@
+using System.Collections.Generic;
+
+namespace Umbraco.Core
+{
+ ///
+ /// Provides extension methods for the struct.
+ ///
+ public static class KeyValuePairExtensions
+ {
+ ///
+ /// Implements key/value pair deconstruction.
+ ///
+ /// Allows for foreach ((var k, var v) in ...).
+ public static void Deconstruct(this KeyValuePair kvp, out TKey key, out TValue value)
+ {
+ key = kvp.Key;
+ value = kvp.Value;
+ }
+ }
+}
diff --git a/src/Umbraco.Core/Models/AuditItem.cs b/src/Umbraco.Core/Models/AuditItem.cs
index cd885724d0..993eb784d6 100644
--- a/src/Umbraco.Core/Models/AuditItem.cs
+++ b/src/Umbraco.Core/Models/AuditItem.cs
@@ -2,7 +2,7 @@
namespace Umbraco.Core.Models
{
- public sealed class AuditItem : Entity, IAggregateRoot
+ public sealed class AuditItem : EntityBase.EntityBase
{
public AuditItem(int objectId, string comment, AuditType type, int userId)
{
diff --git a/src/Umbraco.Core/Models/ContentBase.cs b/src/Umbraco.Core/Models/ContentBase.cs
index 6adec3db5f..7863e5b6d8 100644
--- a/src/Umbraco.Core/Models/ContentBase.cs
+++ b/src/Umbraco.Core/Models/ContentBase.cs
@@ -18,7 +18,7 @@ namespace Umbraco.Core.Models
[Serializable]
[DataContract(IsReference = true)]
[DebuggerDisplay("Id: {Id}, Name: {Name}, ContentType: {ContentTypeBase.Alias}")]
- public abstract class ContentBase : Entity, IContentBase
+ public abstract class ContentBase : EntityBase.EntityBase, IContentBase
{
private static readonly Lazy Ps = new Lazy();
diff --git a/src/Umbraco.Core/Models/ContentTypeBase.cs b/src/Umbraco.Core/Models/ContentTypeBase.cs
index 3e5c85f098..d54ce27443 100644
--- a/src/Umbraco.Core/Models/ContentTypeBase.cs
+++ b/src/Umbraco.Core/Models/ContentTypeBase.cs
@@ -17,7 +17,7 @@ namespace Umbraco.Core.Models
[Serializable]
[DataContract(IsReference = true)]
[DebuggerDisplay("Id: {Id}, Name: {Name}, Alias: {Alias}")]
- public abstract class ContentTypeBase : Entity, IContentTypeBase
+ public abstract class ContentTypeBase : EntityBase.EntityBase, IContentTypeBase
{
private static readonly Lazy Ps = new Lazy();
diff --git a/src/Umbraco.Core/Models/ContentTypeBaseExtensions.cs b/src/Umbraco.Core/Models/ContentTypeBaseExtensions.cs
new file mode 100644
index 0000000000..6a71ff0979
--- /dev/null
+++ b/src/Umbraco.Core/Models/ContentTypeBaseExtensions.cs
@@ -0,0 +1,20 @@
+using Umbraco.Core.Models.PublishedContent;
+
+namespace Umbraco.Core.Models
+{
+ ///
+ /// Provides extensions methods for .
+ ///
+ public static class ContentTypeBaseExtensions
+ {
+ public static PublishedItemType GetItemType(this IContentTypeBase contentType)
+ {
+ var type = contentType.GetType();
+ var itemType = PublishedItemType.Unknown;
+ if (type == typeof(IContentType)) itemType = PublishedItemType.Content;
+ else if (type == typeof(IMediaType)) itemType = PublishedItemType.Media;
+ else if (type == typeof(IMemberType)) itemType = PublishedItemType.Member;
+ return itemType;
+ }
+ }
+}
diff --git a/src/Umbraco.Core/Models/DataType.cs b/src/Umbraco.Core/Models/DataType.cs
new file mode 100644
index 0000000000..2f35115ffd
--- /dev/null
+++ b/src/Umbraco.Core/Models/DataType.cs
@@ -0,0 +1,166 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Reflection;
+using System.Runtime.Serialization;
+using Umbraco.Core.Models.EntityBase;
+
+namespace Umbraco.Core.Models
+{
+ ///
+ /// Implements .
+ ///
+ [Serializable]
+ [DataContract(IsReference = true)]
+ public class DataType : EntityBase.EntityBase, IDataType
+ {
+ private static readonly Lazy Ps = new Lazy();
+ private readonly IDictionary _additionalData;
+
+ private int _parentId;
+ private string _name;
+ private int _sortOrder;
+ private int _level;
+ private string _path;
+ private int _creatorId;
+ private bool _trashed;
+ private string _propertyEditorAlias;
+ private DataTypeDatabaseType _databaseType;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public DataType(int parentId, string propertyEditorAlias)
+ {
+ _parentId = parentId;
+ _propertyEditorAlias = propertyEditorAlias;
+
+ _additionalData = new Dictionary();
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public DataType(string propertyEditorAlias)
+ {
+ _parentId = -1;
+ _propertyEditorAlias = propertyEditorAlias;
+
+ _additionalData = new Dictionary();
+ }
+
+ // ReSharper disable once ClassNeverInstantiated.Local
+ private class PropertySelectors
+ {
+ public readonly PropertyInfo NameSelector = ExpressionHelper.GetPropertyInfo(x => x.Name);
+ public readonly PropertyInfo ParentIdSelector = ExpressionHelper.GetPropertyInfo(x => x.ParentId);
+ public readonly PropertyInfo SortOrderSelector = ExpressionHelper.GetPropertyInfo(x => x.SortOrder);
+ public readonly PropertyInfo LevelSelector = ExpressionHelper.GetPropertyInfo(x => x.Level);
+ public readonly PropertyInfo PathSelector = ExpressionHelper.GetPropertyInfo(x => x.Path);
+ public readonly PropertyInfo UserIdSelector = ExpressionHelper.GetPropertyInfo(x => x.CreatorId);
+ public readonly PropertyInfo TrashedSelector = ExpressionHelper.GetPropertyInfo(x => x.Trashed);
+ public readonly PropertyInfo PropertyEditorAliasSelector = ExpressionHelper.GetPropertyInfo(x => x.EditorAlias);
+ public readonly PropertyInfo DatabaseTypeSelector = ExpressionHelper.GetPropertyInfo(x => x.DatabaseType);
+ }
+
+ ///
+ [DataMember]
+ public int ParentId
+ {
+ get => _parentId;
+ set => SetPropertyValueAndDetectChanges(value, ref _parentId, Ps.Value.ParentIdSelector);
+ }
+
+ ///
+ [DataMember]
+ public string Name
+ {
+ get => _name;
+ set => SetPropertyValueAndDetectChanges(value, ref _name, Ps.Value.NameSelector);
+ }
+
+ ///
+ [DataMember]
+ public int SortOrder
+ {
+ get => _sortOrder;
+ set => SetPropertyValueAndDetectChanges(value, ref _sortOrder, Ps.Value.SortOrderSelector);
+ }
+
+ ///
+ [DataMember]
+ public int Level
+ {
+ get => _level;
+ set => SetPropertyValueAndDetectChanges(value, ref _level, Ps.Value.LevelSelector);
+ }
+
+ ///
+ // fixme - setting this value should be handled by the class not the user
+ [DataMember]
+ public string Path
+ {
+ get => _path;
+ set => SetPropertyValueAndDetectChanges(value, ref _path, Ps.Value.PathSelector);
+ }
+
+ ///
+ [DataMember]
+ public int CreatorId
+ {
+ get => _creatorId;
+ set => SetPropertyValueAndDetectChanges(value, ref _creatorId, Ps.Value.UserIdSelector);
+ }
+
+ ///
+ // fixme - data types cannot be trashed?
+ [DataMember]
+ public bool Trashed
+ {
+ get => _trashed;
+ internal set
+ {
+ SetPropertyValueAndDetectChanges(value, ref _trashed, Ps.Value.TrashedSelector);
+
+ // this is a custom property that is not exposed in IUmbracoEntity so add it to the additional data
+ _additionalData["Trashed"] = value;
+ }
+ }
+
+ // fixme - what exactly are we doing with _additionalData?
+ // are we allocating 1 dictionary for *every* entity?
+ // not doing it for other entities?
+
+ ///
+ [DataMember]
+ public string EditorAlias
+ {
+ get => _propertyEditorAlias;
+ set
+ {
+ SetPropertyValueAndDetectChanges(value, ref _propertyEditorAlias, Ps.Value.PropertyEditorAliasSelector);
+
+ // this is a custom property that is not exposed in IUmbracoEntity so add it to the additional data
+ _additionalData["DatabaseType"] = value;
+ }
+ }
+
+ ///
+ [DataMember]
+ public DataTypeDatabaseType DatabaseType
+ {
+ get => _databaseType;
+ set
+ {
+ SetPropertyValueAndDetectChanges(value, ref _databaseType, Ps.Value.DatabaseTypeSelector);
+
+ // this is a custom property that is not exposed in IUmbracoEntity so add it to the additional data
+ _additionalData["DatabaseType"] = value;
+ }
+ }
+
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ IDictionary IUmbracoEntity.AdditionalData => _additionalData;
+ }
+}
diff --git a/src/Umbraco.Core/Models/DataTypeDefinition.cs b/src/Umbraco.Core/Models/DataTypeDefinition.cs
deleted file mode 100644
index eac6a7d5fd..0000000000
--- a/src/Umbraco.Core/Models/DataTypeDefinition.cs
+++ /dev/null
@@ -1,182 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Reflection;
-using System.Runtime.Serialization;
-using Umbraco.Core.Logging;
-using Umbraco.Core.Models.EntityBase;
-using Umbraco.Core.Persistence;
-using Umbraco.Core.PropertyEditors;
-using Umbraco.Core.Services;
-
-namespace Umbraco.Core.Models
-{
- ///
- /// Definition of a DataType/PropertyEditor
- ///
- ///
- /// The definition exists as a database reference between an actual DataType/PropertyEditor
- /// (identified by its control id), its prevalues (configuration) and the named DataType in the backoffice UI.
- ///
- [Serializable]
- [DataContract(IsReference = true)]
- public class DataTypeDefinition : Entity, IDataTypeDefinition
- {
- private int _parentId;
- private string _name;
- private int _sortOrder;
- private int _level;
- private string _path;
- private int _creatorId;
- private bool _trashed;
- private string _propertyEditorAlias;
- private DataTypeDatabaseType _databaseType;
-
-
- public DataTypeDefinition(int parentId, string propertyEditorAlias)
- {
- _parentId = parentId;
- _propertyEditorAlias = propertyEditorAlias;
-
- _additionalData = new Dictionary();
- }
-
- public DataTypeDefinition(string propertyEditorAlias)
- {
- _parentId = -1;
- _propertyEditorAlias = propertyEditorAlias;
-
- _additionalData = new Dictionary();
- }
-
- private static readonly Lazy Ps = new Lazy();
-
- private class PropertySelectors
- {
- public readonly PropertyInfo NameSelector = ExpressionHelper.GetPropertyInfo(x => x.Name);
- public readonly PropertyInfo ParentIdSelector = ExpressionHelper.GetPropertyInfo(x => x.ParentId);
- public readonly PropertyInfo SortOrderSelector = ExpressionHelper.GetPropertyInfo(x => x.SortOrder);
- public readonly PropertyInfo LevelSelector = ExpressionHelper.GetPropertyInfo(x => x.Level);
- public readonly PropertyInfo PathSelector = ExpressionHelper.GetPropertyInfo(x => x.Path);
- public readonly PropertyInfo UserIdSelector = ExpressionHelper.GetPropertyInfo(x => x.CreatorId);
- public readonly PropertyInfo TrashedSelector = ExpressionHelper.GetPropertyInfo(x => x.Trashed);
- public readonly PropertyInfo PropertyEditorAliasSelector = ExpressionHelper.GetPropertyInfo(x => x.PropertyEditorAlias);
- public readonly PropertyInfo DatabaseTypeSelector = ExpressionHelper.GetPropertyInfo(x => x.DatabaseType);
- }
-
- ///
- /// Gets or sets the Id of the Parent entity
- ///
- /// Might not be necessary if handled as a relation?
- [DataMember]
- public int ParentId
- {
- get { return _parentId; }
- set { SetPropertyValueAndDetectChanges(value, ref _parentId, Ps.Value.ParentIdSelector); }
- }
-
- ///
- /// Gets or sets the name of the current entity
- ///
- [DataMember]
- public string Name
- {
- get { return _name; }
- set { SetPropertyValueAndDetectChanges(value, ref _name, Ps.Value.NameSelector); }
- }
-
- ///
- /// Gets or sets the sort order of the content entity
- ///
- [DataMember]
- public int SortOrder
- {
- get { return _sortOrder; }
- set { SetPropertyValueAndDetectChanges(value, ref _sortOrder, Ps.Value.SortOrderSelector); }
- }
-
- ///
- /// Gets or sets the level of the content entity
- ///
- [DataMember]
- public int Level
- {
- get { return _level; }
- set { SetPropertyValueAndDetectChanges(value, ref _level, Ps.Value.LevelSelector); }
- }
-
- ///
- /// Gets or sets the path
- ///
- [DataMember]
- public string Path //Setting this value should be handled by the class not the user
- {
- get { return _path; }
- set { SetPropertyValueAndDetectChanges(value, ref _path, Ps.Value.PathSelector); }
- }
-
- ///
- /// Id of the user who created this entity
- ///
- [DataMember]
- public int CreatorId
- {
- get { return _creatorId; }
- set { SetPropertyValueAndDetectChanges(value, ref _creatorId, Ps.Value.UserIdSelector); }
- }
-
- //NOTE: SD: Why do we have this ??
-
- ///
- /// Boolean indicating whether this entity is Trashed or not.
- ///
- [DataMember]
- public bool Trashed
- {
- get { return _trashed; }
- internal set
- {
- SetPropertyValueAndDetectChanges(value, ref _trashed, Ps.Value.TrashedSelector);
- //This is a custom property that is not exposed in IUmbracoEntity so add it to the additional data
- _additionalData["Trashed"] = value;
- }
- }
-
- [DataMember]
- public string PropertyEditorAlias
- {
- get { return _propertyEditorAlias; }
- set
- {
- SetPropertyValueAndDetectChanges(value, ref _propertyEditorAlias, Ps.Value.PropertyEditorAliasSelector);
- //This is a custom property that is not exposed in IUmbracoEntity so add it to the additional data
- _additionalData["DatabaseType"] = value;
- }
- }
-
- ///
- /// Gets or Sets the DatabaseType for which the DataType's value is saved as
- ///
- [DataMember]
- public DataTypeDatabaseType DatabaseType
- {
- get { return _databaseType; }
- set
- {
- SetPropertyValueAndDetectChanges(value, ref _databaseType, Ps.Value.DatabaseTypeSelector);
- //This is a custom property that is not exposed in IUmbracoEntity so add it to the additional data
- _additionalData["DatabaseType"] = value;
- }
- }
-
- private readonly IDictionary _additionalData;
- ///
- /// Some entities may expose additional data that other's might not, this custom data will be available in this collection
- ///
- [EditorBrowsable(EditorBrowsableState.Never)]
- IDictionary IUmbracoEntity.AdditionalData
- {
- get { return _additionalData; }
- }
- }
-}
diff --git a/src/Umbraco.Core/Models/DictionaryItem.cs b/src/Umbraco.Core/Models/DictionaryItem.cs
index e32bfd7f76..f97742076b 100644
--- a/src/Umbraco.Core/Models/DictionaryItem.cs
+++ b/src/Umbraco.Core/Models/DictionaryItem.cs
@@ -12,7 +12,7 @@ namespace Umbraco.Core.Models
///
[Serializable]
[DataContract(IsReference = true)]
- public class DictionaryItem : Entity, IDictionaryItem
+ public class DictionaryItem : EntityBase.EntityBase, IDictionaryItem
{
public Func GetLanguage { get; set; }
private Guid? _parentId;
diff --git a/src/Umbraco.Core/Models/DictionaryTranslation.cs b/src/Umbraco.Core/Models/DictionaryTranslation.cs
index ebb24e3992..1df0c4b618 100644
--- a/src/Umbraco.Core/Models/DictionaryTranslation.cs
+++ b/src/Umbraco.Core/Models/DictionaryTranslation.cs
@@ -11,7 +11,7 @@ namespace Umbraco.Core.Models
///
[Serializable]
[DataContract(IsReference = true)]
- public class DictionaryTranslation : Entity, IDictionaryTranslation
+ public class DictionaryTranslation : EntityBase.EntityBase, IDictionaryTranslation
{
internal Func GetLanguage { get; set; }
diff --git a/src/Umbraco.Core/Models/EntityBase/BeingDirtyBase.cs b/src/Umbraco.Core/Models/EntityBase/BeingDirtyBase.cs
new file mode 100644
index 0000000000..c673088984
--- /dev/null
+++ b/src/Umbraco.Core/Models/EntityBase/BeingDirtyBase.cs
@@ -0,0 +1,184 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Reflection;
+using System.Runtime.Serialization;
+using Umbraco.Core.Composing;
+
+namespace Umbraco.Core.Models.EntityBase
+{
+ ///
+ /// Provides a base implementation of and .
+ ///
+ [Serializable]
+ [DataContract(IsReference = true)]
+ public abstract class BeingDirtyBase : IRememberBeingDirty
+ {
+ private bool _withChanges = true; // should we track changes?
+ private Dictionary _currentChanges; // which properties have changed?
+ private Dictionary _savedChanges; // which properties had changed at last commit?
+
+ #region ICanBeDirty
+
+ ///
+ public virtual bool IsDirty()
+ {
+ return _currentChanges != null && _currentChanges.Any();
+ }
+
+ ///
+ public virtual bool IsPropertyDirty(string propertyName)
+ {
+ return _currentChanges != null && _currentChanges.Any(x => x.Key == propertyName);
+ }
+
+ ///
+ public virtual IEnumerable GetDirtyProperties()
+ {
+ // ReSharper disable once MergeConditionalExpression
+ return _currentChanges == null
+ ? Enumerable.Empty()
+ : _currentChanges.Where(x => x.Value).Select(x => x.Key);
+ }
+
+ ///
+ /// Saves dirty properties so they can be checked with WasDirty.
+ public virtual void ResetDirtyProperties()
+ {
+ ResetDirtyProperties(true);
+ }
+
+ #endregion
+
+ #region IRememberBeingDirty
+
+ ///
+ public virtual bool WasDirty()
+ {
+ return _savedChanges != null && _savedChanges.Any();
+ }
+
+ ///
+ public virtual bool WasPropertyDirty(string propertyName)
+ {
+ return _savedChanges != null && _savedChanges.Any(x => x.Key == propertyName);
+ }
+
+ ///
+ public void ResetWereDirtyProperties()
+ {
+ // note: cannot .Clear() because when memberwise-cloning this will be the SAME
+ // instance as the one on the clone, so we need to create a new instance.
+ _savedChanges = null;
+ }
+
+ ///
+ public virtual void ResetDirtyProperties(bool rememberDirty)
+ {
+ // capture changes if remembering
+ // clone the dictionary in case it's shared by an entity clone
+ _savedChanges = rememberDirty && _currentChanges != null
+ ? _currentChanges.ToDictionary(v => v.Key, v => v.Value)
+ : null;
+
+ // note: cannot .Clear() because when memberwise-clone this will be the SAME
+ // instance as the one on the clone, so we need to create a new instance.
+ _currentChanges = null;
+ }
+
+ #endregion
+
+ #region Change Tracking
+
+ ///
+ /// Occurs when a property changes.
+ ///
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ ///
+ /// Registers that a property has changed.
+ ///
+ protected virtual void OnPropertyChanged(PropertyInfo propertyInfo)
+ {
+ if (_withChanges == false)
+ return;
+
+ if (_currentChanges == null)
+ _currentChanges = new Dictionary();
+
+ _currentChanges[propertyInfo.Name] = true;
+
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyInfo.Name));
+ }
+
+ ///
+ /// Disables change tracking.
+ ///
+ public void DisableChangeTracking()
+ {
+ _withChanges = false;
+ }
+
+ ///
+ /// Enables change tracking.
+ ///
+ public void EnableChangeTracking()
+ {
+ _withChanges = true;
+ }
+
+ ///
+ /// Sets a property value, detects changes and manages the dirty flag.
+ ///
+ /// The type of the value.
+ /// The new value.
+ /// A reference to the value to set.
+ /// The property selector.
+ /// A comparer to compare property values.
+ protected void SetPropertyValueAndDetectChanges(T value, ref T valueRef, PropertyInfo propertySelector, IEqualityComparer comparer = null)
+ {
+ if (comparer == null)
+ {
+ // if no comparer is provided, use the default provider, as long as the value is not
+ // an IEnumerable - exclude strings, which are IEnumerable but have a default comparer
+ var typeofT = typeof(T);
+ if (!(typeofT == typeof(string)) && typeof(IEnumerable).IsAssignableFrom(typeofT))
+ throw new ArgumentNullException(nameof(comparer), "A custom comparer must be supplied for IEnumerable values.");
+ comparer = EqualityComparer.Default;
+ }
+
+ // compare values
+ var changed = _withChanges && comparer.Equals(valueRef, value) == false;
+
+ // assign the new value
+ valueRef = value;
+
+ // handle change
+ if (changed)
+ OnPropertyChanged(propertySelector);
+ }
+
+ ///
+ /// Detects changes and manages the dirty flag.
+ ///
+ /// The type of the value.
+ /// The new value.
+ /// The original value.
+ /// The property selector.
+ /// A comparer to compare property values.
+ /// A value indicating whether we know values have changed and no comparison is required.
+ protected void DetectChanges(T value, T orig, PropertyInfo propertySelector, IEqualityComparer comparer, bool changed)
+ {
+ // compare values
+ changed = _withChanges && (changed || !comparer.Equals(orig, value));
+
+ // handle change
+ if (changed)
+ OnPropertyChanged(propertySelector);
+ }
+
+ #endregion
+ }
+}
diff --git a/src/Umbraco.Core/Models/EntityBase/Entity.cs b/src/Umbraco.Core/Models/EntityBase/Entity.cs
deleted file mode 100644
index f3970cec17..0000000000
--- a/src/Umbraco.Core/Models/EntityBase/Entity.cs
+++ /dev/null
@@ -1,214 +0,0 @@
-using System;
-using System.Diagnostics;
-using System.Reflection;
-using System.Runtime.Serialization;
-
-namespace Umbraco.Core.Models.EntityBase
-{
- ///
- /// Base Abstract Entity
- ///
- [Serializable]
- [DataContract(IsReference = true)]
- [DebuggerDisplay("Id: {" + nameof(Id) + "}")]
- public abstract class Entity : TracksChangesEntityBase, IEntity //, IRememberBeingDirty, ICanBeDirty
- {
- private bool _hasIdentity;
- private int _id;
- private Guid _key;
- private DateTime _createDate;
- private DateTime _updateDate;
- private bool _wasCancelled;
-
- private static readonly Lazy Ps = new Lazy();
-
- // ReSharper disable once ClassNeverInstantiated.Local
- private class PropertySelectors
- {
- public readonly PropertyInfo IdSelector = ExpressionHelper.GetPropertyInfo(x => x.Id);
- public readonly PropertyInfo KeySelector = ExpressionHelper.GetPropertyInfo(x => x.Key);
- public readonly PropertyInfo CreateDateSelector = ExpressionHelper.GetPropertyInfo(x => x.CreateDate);
- public readonly PropertyInfo UpdateDateSelector = ExpressionHelper.GetPropertyInfo(x => x.UpdateDate);
- public readonly PropertyInfo HasIdentitySelector = ExpressionHelper.GetPropertyInfo(x => x.HasIdentity);
- public readonly PropertyInfo WasCancelledSelector = ExpressionHelper.GetPropertyInfo(x => x.WasCancelled);
- }
-
- ///
- /// Integer Id
- ///
- [DataMember]
- public int Id
- {
- get => _id;
- set
- {
- SetPropertyValueAndDetectChanges(value, ref _id, Ps.Value.IdSelector);
- HasIdentity = value != 0; //set the has Identity
- }
- }
-
- ///
- /// Guid based Id
- ///
- /// The key is currectly used to store the Unique Id from the
- /// umbracoNode table, which many of the entities are based on.
- [DataMember]
- public Guid Key
- {
- get
- {
- // if an entity does NOT have a UniqueId yet, assign one now
- if (_key == Guid.Empty)
- _key = Guid.NewGuid();
- return _key;
- }
- set => SetPropertyValueAndDetectChanges(value, ref _key, Ps.Value.KeySelector);
- }
-
- ///
- /// Gets or sets the Created Date
- ///
- [DataMember]
- public DateTime CreateDate
- {
- get => _createDate;
- set => SetPropertyValueAndDetectChanges(value, ref _createDate, Ps.Value.CreateDateSelector);
- }
-
- ///
- /// Gets or sets the WasCancelled flag, which is used to track
- /// whether some action against an entity was cancelled through some event.
- /// This only exists so we have a way to check if an event was cancelled through
- /// the new api, which also needs to take effect in the legacy api.
- ///
- [IgnoreDataMember]
- [Obsolete("Anytime there's a cancellable method it needs to return an Attempt so we know the outcome instead of this hack, not all services have been updated to use this though yet.")]
- internal bool WasCancelled
- {
- get => _wasCancelled;
- set => SetPropertyValueAndDetectChanges(value, ref _wasCancelled, Ps.Value.WasCancelledSelector);
- }
-
- ///
- /// Gets or sets the Modified Date
- ///
- [DataMember]
- public DateTime UpdateDate
- {
- get => _updateDate;
- set => SetPropertyValueAndDetectChanges(value, ref _updateDate, Ps.Value.UpdateDateSelector);
- }
-
- [IgnoreDataMember]
- public DateTime? DeletedDate { get; set; }
-
- internal virtual void ResetIdentity()
- {
- _hasIdentity = false;
- _id = default(int);
- _key = Guid.Empty;
- }
-
- ///
- /// Method to call on entity saved when first added
- ///
- internal virtual void AddingEntity()
- {
- if (IsPropertyDirty("CreateDate") == false || _createDate == default(DateTime))
- CreateDate = DateTime.Now;
- if (IsPropertyDirty("UpdateDate") == false || _updateDate == default(DateTime))
- UpdateDate = DateTime.Now;
- }
-
- ///
- /// Method to call on entity saved/updated
- ///
- internal virtual void UpdatingEntity()
- {
- if (IsPropertyDirty("UpdateDate") == false || _updateDate == default(DateTime))
- UpdateDate = DateTime.Now;
-
- //this is just in case
- if (_createDate == default(DateTime))
- CreateDate = DateTime.Now;
- }
-
- ///
- /// Indicates whether the current entity has an identity, eg. Id.
- ///
- [DataMember]
- public virtual bool HasIdentity
- {
- get => _hasIdentity;
- protected set => SetPropertyValueAndDetectChanges(value, ref _hasIdentity, Ps.Value.HasIdentitySelector);
- }
-
- //TODO: Make this NOT virtual or even exist really!
- public virtual bool SameIdentityAs(IEntity other)
- {
- return other != null && (ReferenceEquals(this, other) || SameIdentityAs(other as Entity));
- }
-
- public virtual bool Equals(Entity other)
- {
- return other != null && (ReferenceEquals(this, other) || SameIdentityAs(other));
- }
-
- //TODO: Make this NOT virtual or even exist really!
- public virtual Type GetRealType()
- {
- return GetType();
- }
-
- //TODO: Make this NOT virtual or even exist really!
- public virtual bool SameIdentityAs(Entity other)
- {
- if (ReferenceEquals(null, other))
- return false;
-
- if (ReferenceEquals(this, other))
- return true;
-
- if (GetType() == other.GetRealType() && HasIdentity && other.HasIdentity)
- return other.Id.Equals(Id);
-
- return false;
- }
-
- public override bool Equals(object obj)
- {
- return obj != null && (ReferenceEquals(this, obj) || SameIdentityAs(obj as IEntity));
- }
-
- public override int GetHashCode()
- {
- unchecked
- {
- var hashCode = HasIdentity.GetHashCode();
- hashCode = (hashCode * 397) ^ Id;
- hashCode = (hashCode * 397) ^ GetType().GetHashCode();
- return hashCode;
- }
- }
-
- public virtual object DeepClone()
- {
- //Memberwise clone on Entity will work since it doesn't have any deep elements
- // for any sub class this will work for standard properties as well that aren't complex object's themselves.
- var unused = Key; // ensure that 'this' has a key, before cloning
- var clone = (Entity)MemberwiseClone();
- //ensure the clone has it's own dictionaries
- clone.ResetChangeTrackingCollections();
- //turn off change tracking
- clone.DisableChangeTracking();
- //Automatically deep clone ref properties that are IDeepCloneable
- DeepCloneHelper.DeepCloneRefProperties(this, clone);
- //this shouldn't really be needed since we're not tracking
- clone.ResetDirtyProperties(false);
- //re-enable tracking
- clone.EnableChangeTracking();
-
- return clone;
- }
- }
-}
diff --git a/src/Umbraco.Core/Models/EntityBase/EntityBase.cs b/src/Umbraco.Core/Models/EntityBase/EntityBase.cs
new file mode 100644
index 0000000000..2055ba584b
--- /dev/null
+++ b/src/Umbraco.Core/Models/EntityBase/EntityBase.cs
@@ -0,0 +1,180 @@
+using System;
+using System.Diagnostics;
+using System.Reflection;
+using System.Runtime.Serialization;
+
+namespace Umbraco.Core.Models.EntityBase
+{
+ ///
+ /// Provides a base class for entities.
+ ///
+ [Serializable]
+ [DataContract(IsReference = true)]
+ [DebuggerDisplay("Id: {" + nameof(Id) + "}")]
+ public abstract class EntityBase : BeingDirtyBase, IEntity
+ {
+ private static readonly Lazy Ps = new Lazy();
+
+ private bool _hasIdentity;
+ private int _id;
+ private Guid _key;
+ private DateTime _createDate;
+ private DateTime _updateDate;
+
+ // ReSharper disable once ClassNeverInstantiated.Local
+ private class PropertySelectors
+ {
+ public readonly PropertyInfo IdSelector = ExpressionHelper.GetPropertyInfo(x => x.Id);
+ public readonly PropertyInfo KeySelector = ExpressionHelper.GetPropertyInfo(x => x.Key);
+ public readonly PropertyInfo CreateDateSelector = ExpressionHelper.GetPropertyInfo(x => x.CreateDate);
+ public readonly PropertyInfo UpdateDateSelector = ExpressionHelper.GetPropertyInfo(x => x.UpdateDate);
+ }
+
+ ///
+ [DataMember]
+ public int Id
+ {
+ get => _id;
+ set
+ {
+ SetPropertyValueAndDetectChanges(value, ref _id, Ps.Value.IdSelector);
+ _hasIdentity = value != 0;
+ }
+ }
+
+ ///
+ [DataMember]
+ public Guid Key
+ {
+ get
+ {
+ // if an entity does NOT have a key yet, assign one now
+ if (_key == Guid.Empty)
+ _key = Guid.NewGuid();
+ return _key;
+ }
+ set => SetPropertyValueAndDetectChanges(value, ref _key, Ps.Value.KeySelector);
+ }
+
+ ///
+ [DataMember]
+ public DateTime CreateDate
+ {
+ get => _createDate;
+ set => SetPropertyValueAndDetectChanges(value, ref _createDate, Ps.Value.CreateDateSelector);
+ }
+
+ ///
+ [DataMember]
+ public DateTime UpdateDate
+ {
+ get => _updateDate;
+ set => SetPropertyValueAndDetectChanges(value, ref _updateDate, Ps.Value.UpdateDateSelector);
+ }
+
+ ///
+ [DataMember]
+ public DateTime? DeleteDate { get; set; } // no change tracking - not persisted
+
+ ///
+ [DataMember]
+ public virtual bool HasIdentity => _hasIdentity;
+
+ ///
+ /// Resets the entity identity.
+ ///
+ internal virtual void ResetIdentity()
+ {
+ _id = default;
+ _key = Guid.Empty;
+ _hasIdentity = false;
+ }
+
+ ///
+ /// Updates the entity when it is being saved for the first time.
+ ///
+ internal virtual void AddingEntity()
+ {
+ var now = DateTime.Now;
+
+ // set the create and update dates, if not already set
+ if (IsPropertyDirty("CreateDate") == false || _createDate == default)
+ CreateDate = now;
+ if (IsPropertyDirty("UpdateDate") == false || _updateDate == default)
+ UpdateDate = now;
+ }
+
+ ///
+ /// Updates the entity when it is being saved.
+ ///
+ internal virtual void UpdatingEntity()
+ {
+ var now = DateTime.Now;
+
+ // just in case
+ if (_createDate == default)
+ CreateDate = now;
+
+ // set the update date if not already set
+ if (IsPropertyDirty("UpdateDate") == false || _updateDate == default)
+ UpdateDate = now;
+ }
+
+ public virtual bool Equals(EntityBase other)
+ {
+ return other != null && (ReferenceEquals(this, other) || SameIdentityAs(other));
+ }
+
+ public override bool Equals(object obj)
+ {
+ return obj != null && (ReferenceEquals(this, obj) || SameIdentityAs(obj as EntityBase));
+ }
+
+ private bool SameIdentityAs(EntityBase other)
+ {
+ if (other == null) return false;
+
+ // same identity if
+ // - same object (reference equals)
+ // - or same Clr type, both have identities, and they are identical
+
+ if (ReferenceEquals(this, other))
+ return true;
+
+ return GetType() == other.GetType() && HasIdentity && other.HasIdentity && Id == other.Id;
+ }
+
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ var hashCode = HasIdentity.GetHashCode();
+ hashCode = (hashCode * 397) ^ Id;
+ hashCode = (hashCode * 397) ^ GetType().GetHashCode();
+ return hashCode;
+ }
+ }
+
+ public virtual object DeepClone()
+ {
+ // memberwise-clone (ie shallow clone) the entity
+ var unused = Key; // ensure that 'this' has a key, before cloning
+ var clone = (EntityBase) MemberwiseClone();
+
+ // clear changes (ensures the clone has its own dictionaries)
+ // then disable change tracking
+ clone.ResetDirtyProperties(false);
+ clone.DisableChangeTracking();
+
+ // deep clone ref properties that are IDeepCloneable
+ DeepCloneHelper.DeepCloneRefProperties(this, clone);
+
+ // clear changes again (just to be sure, because we were not tracking)
+ // then enable change tracking
+ clone.ResetDirtyProperties(false);
+ clone.EnableChangeTracking();
+
+ return clone;
+ }
+ }
+}
diff --git a/src/Umbraco.Core/Models/EntityBase/EntityPath.cs b/src/Umbraco.Core/Models/EntityBase/EntityPath.cs
deleted file mode 100644
index 368d6bd87b..0000000000
--- a/src/Umbraco.Core/Models/EntityBase/EntityPath.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace Umbraco.Core.Models.EntityBase
-{
- public class EntityPath
- {
- public int Id { get; set; }
- public string Path { get; set; }
- }
-}
diff --git a/src/Umbraco.Core/Models/EntityBase/IAggregateRoot.cs b/src/Umbraco.Core/Models/EntityBase/IAggregateRoot.cs
deleted file mode 100644
index 38f4cfbbd0..0000000000
--- a/src/Umbraco.Core/Models/EntityBase/IAggregateRoot.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace Umbraco.Core.Models.EntityBase
-{
- ///
- /// Marker interface for aggregate roots
- ///
- public interface IAggregateRoot : IDeletableEntity
- { }
-}
diff --git a/src/Umbraco.Core/Models/EntityBase/ICanBeDirty.cs b/src/Umbraco.Core/Models/EntityBase/ICanBeDirty.cs
index 536cf11bfc..30b79121f1 100644
--- a/src/Umbraco.Core/Models/EntityBase/ICanBeDirty.cs
+++ b/src/Umbraco.Core/Models/EntityBase/ICanBeDirty.cs
@@ -8,12 +8,12 @@ namespace Umbraco.Core.Models.EntityBase
public interface ICanBeDirty
{
///
- /// Gets a value indicating whether the current entity is dirty.
+ /// Determines whether the current entity is dirty.
///
bool IsDirty();
///
- /// Gets a value indicating whether a specific property is dirty.
+ /// Determines whether a specific property is dirty.
///
bool IsPropertyDirty(string propName);
diff --git a/src/Umbraco.Core/Models/EntityBase/IDeletableEntity.cs b/src/Umbraco.Core/Models/EntityBase/IDeletableEntity.cs
deleted file mode 100644
index 910722c184..0000000000
--- a/src/Umbraco.Core/Models/EntityBase/IDeletableEntity.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using System;
-using System.Runtime.Serialization;
-
-namespace Umbraco.Core.Models.EntityBase
-{
- public interface IDeletableEntity : IEntity
- {
- [DataMember]
- DateTime? DeletedDate { get; set; }
- }
-}
diff --git a/src/Umbraco.Core/Models/EntityBase/IEntity.cs b/src/Umbraco.Core/Models/EntityBase/IEntity.cs
index d871719826..c15eb3ca25 100644
--- a/src/Umbraco.Core/Models/EntityBase/IEntity.cs
+++ b/src/Umbraco.Core/Models/EntityBase/IEntity.cs
@@ -9,13 +9,13 @@ namespace Umbraco.Core.Models.EntityBase
public interface IEntity : IDeepCloneable
{
///
- /// The integer identifier of the entity.
+ /// Gets or sets the integer identifier of the entity.
///
[DataMember]
int Id { get; set; }
///
- /// The Guid unique identifier of the entity.
+ /// Gets or sets the Guid unique identifier of the entity.
///
[DataMember]
Guid Key { get; set; }
@@ -32,6 +32,17 @@ namespace Umbraco.Core.Models.EntityBase
[DataMember]
DateTime UpdateDate { get; set; }
+ ///
+ /// Gets or sets the delete date.
+ ///
+ ///
+ /// The delete date is null when the entity has not been deleted.
+ /// The delete date has a value when the entity instance has been deleted, but this value
+ /// is transient and not persisted in database (since the entity does not exist anymore).
+ ///
+ [DataMember]
+ DateTime? DeleteDate { get; set; }
+
///
/// Gets a value indicating whether the entity has an identity.
///
diff --git a/src/Umbraco.Core/Models/EntityBase/IRememberBeingDirty.cs b/src/Umbraco.Core/Models/EntityBase/IRememberBeingDirty.cs
index db7f27357b..2e4fb50fe8 100644
--- a/src/Umbraco.Core/Models/EntityBase/IRememberBeingDirty.cs
+++ b/src/Umbraco.Core/Models/EntityBase/IRememberBeingDirty.cs
@@ -7,13 +7,13 @@
public interface IRememberBeingDirty : ICanBeDirty
{
///
- /// Gets a value indicating whether the current entity is dirty.
+ /// Determines whether the current entity is dirty.
///
/// A property was dirty if it had been changed and the changes were committed.
bool WasDirty();
///
- /// Gets a value indicating whether a specific property was dirty.
+ /// Determines whether a specific property was dirty.
///
/// A property was dirty if it had been changed and the changes were committed.
bool WasPropertyDirty(string propertyName);
diff --git a/src/Umbraco.Core/Models/EntityBase/ITreeEntity.cs b/src/Umbraco.Core/Models/EntityBase/ITreeEntity.cs
new file mode 100644
index 0000000000..e5a53903d4
--- /dev/null
+++ b/src/Umbraco.Core/Models/EntityBase/ITreeEntity.cs
@@ -0,0 +1,42 @@
+namespace Umbraco.Core.Models.EntityBase
+{
+ ///
+ /// Defines an entity that belongs to a tree.
+ ///
+ public interface ITreeEntity : IEntity
+ {
+ ///
+ /// Gets or sets the name of the entity.
+ ///
+ string Name { get; set; }
+
+ ///
+ /// Gets or sets the identifier of the parent entity.
+ ///
+ int ParentId { get; set; }
+
+ ///
+ /// Gets or sets the level of the entity.
+ ///
+ int Level { get; set; }
+
+ ///
+ /// Gets or sets the path to the entity.
+ ///
+ string Path { get; set; }
+
+ ///
+ /// Gets or sets the sort order of the entity.
+ ///
+ int SortOrder { get; set; }
+
+ ///
+ /// Gets a value indicating whether this entity is trashed.
+ ///
+ ///
+ /// Trashed entities are located in the recycle bin.
+ /// Always false for entities that do not support being trashed.
+ ///
+ bool Trashed { get; }
+ }
+}
\ No newline at end of file
diff --git a/src/Umbraco.Core/Models/EntityBase/IUmbracoEntity.cs b/src/Umbraco.Core/Models/EntityBase/IUmbracoEntity.cs
index 4d69a78c16..d7ac509788 100644
--- a/src/Umbraco.Core/Models/EntityBase/IUmbracoEntity.cs
+++ b/src/Umbraco.Core/Models/EntityBase/IUmbracoEntity.cs
@@ -2,51 +2,26 @@
namespace Umbraco.Core.Models.EntityBase
{
- public interface IUmbracoEntity : IAggregateRoot, IRememberBeingDirty
+ ///
+ /// Represents fixme what exactly?
+ ///
+ ///
+ /// An IUmbracoEntity can be related to another via the IRelationService.
+ /// IUmbracoEntities can be retrieved with the IEntityService.
+ /// An IUmbracoEntity can participate in notifications.
+ ///
+ public interface IUmbracoEntity : ITreeEntity, IRememberBeingDirty
{
///
- /// Profile of the user who created this Entity
+ /// Gets or sets the identifier of the user who created this entity.
///
int CreatorId { get; set; }
///
- /// Gets or sets the level of the Entity
- ///
- int Level { get; set; }
-
- ///
- /// Gets or Sets the Name of the Entity
- ///
- string Name { get; set; }
-
- ///
- /// Gets or sets the Id of the Parent Entity
- ///
- int ParentId { get; set; }
-
- ///
- /// Gets or sets the path to the Entity
- ///
- string Path { get; set; }
-
- ///
- /// Gets or sets the sort order of the Entity
- ///
- int SortOrder { get; set; }
-
- ///
- /// Boolean indicating whether this Entity is Trashed or not.
- /// If an Entity is Trashed it will be located in the Recyclebin.
- ///
- ///
- /// When content is trashed it should be unpublished.
- /// Not all entities support being trashed, they'll always return false.
- ///
- bool Trashed { get; }
-
- ///
- /// Some entities may expose additional data that other's might not, this custom data will be available in this collection
+ /// Gets additional data for this entity.
///
IDictionary AdditionalData { get; }
+
+ // fixme AdditionalData is never null, then we need a HasAdditionalData for checking values?
}
}
diff --git a/src/Umbraco.Core/Models/EntityBase/TracksChangesEntityBase.cs b/src/Umbraco.Core/Models/EntityBase/TracksChangesEntityBase.cs
deleted file mode 100644
index 3b69c64d04..0000000000
--- a/src/Umbraco.Core/Models/EntityBase/TracksChangesEntityBase.cs
+++ /dev/null
@@ -1,206 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Linq;
-using System.Reflection;
-using System.Runtime.Serialization;
-using Umbraco.Core.Composing;
-
-namespace Umbraco.Core.Models.EntityBase
-{
- ///
- /// A base class for use to implement IRememberBeingDirty/ICanBeDirty
- ///
- [Serializable]
- [DataContract(IsReference = true)]
- public abstract class TracksChangesEntityBase : IRememberBeingDirty
- {
- private bool _changeTrackingEnabled = true; // should we track changes?
- private IDictionary _propertyChangedInfo; // which properties have changed?
- private IDictionary _lastPropertyChangedInfo; // which properties had changed at last commit?
-
- ///
- /// Gets properties that are dirty.
- ///
- public virtual IEnumerable GetDirtyProperties()
- {
- if (_propertyChangedInfo == null)
- return Enumerable.Empty();
-
- return _propertyChangedInfo.Where(x => x.Value).Select(x => x.Key);
- }
-
- ///
- /// Occurs when a property changes.
- ///
- public event PropertyChangedEventHandler PropertyChanged;
-
- ///
- /// Registers that a property has changed.
- ///
- protected virtual void OnPropertyChanged(PropertyInfo propertyInfo)
- {
- if (_changeTrackingEnabled == false)
- return;
-
- if (_propertyChangedInfo == null)
- _propertyChangedInfo = new Dictionary();
-
- _propertyChangedInfo[propertyInfo.Name] = true;
-
- PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyInfo.Name));
- }
-
- ///
- /// Gets a value indicating whether a specific property is dirty.
- ///
- public virtual bool IsPropertyDirty(string propertyName)
- {
- return _propertyChangedInfo != null && _propertyChangedInfo.Any(x => x.Key == propertyName);
- }
-
- ///
- /// Gets a value indicating whether a specific property was dirty.
- ///
- /// A property was dirty if it had been changed and the changes were committed.
- public virtual bool WasPropertyDirty(string propertyName)
- {
- return _lastPropertyChangedInfo != null && _lastPropertyChangedInfo.Any(x => x.Key == propertyName);
- }
-
- ///
- /// Gets a value indicating whether the current entity is dirty.
- ///
- public virtual bool IsDirty()
- {
- return _propertyChangedInfo != null && _propertyChangedInfo.Any();
- }
-
- ///
- /// Gets a value indicating whether the current entity is dirty.
- ///
- /// A property was dirty if it had been changed and the changes were committed.
- public virtual bool WasDirty()
- {
- return _lastPropertyChangedInfo != null && _lastPropertyChangedInfo.Any();
- }
-
- ///
- /// Resets dirty properties.
- ///
- /// Saves dirty properties so they can be checked with WasDirty.
- public virtual void ResetDirtyProperties()
- {
- ResetDirtyProperties(true);
- }
-
- ///
- /// Resets dirty properties.
- ///
- /// A value indicating whether to remember dirty properties.
- /// When is true, dirty properties are saved so they can be checked with WasDirty.
- public virtual void ResetDirtyProperties(bool rememberDirty)
- {
- if (rememberDirty && _propertyChangedInfo != null)
- {
- _lastPropertyChangedInfo = _propertyChangedInfo.ToDictionary(v => v.Key, v => v.Value);
- }
-
- // note: cannot .Clear() because when memberwise-clone this will be the SAME
- // instance as the one on the clone, so we need to create a new instance.
- _propertyChangedInfo = null;
- }
-
- ///
- /// Resets properties that were dirty.
- ///
- public void ResetWereDirtyProperties()
- {
- // note: cannot .Clear() because when memberwise-cloning this will be the SAME
- // instance as the one on the clone, so we need to create a new instance.
- _lastPropertyChangedInfo = null;
- }
-
- ///
- /// Resets all change tracking infos.
- ///
- public void ResetChangeTrackingCollections()
- {
- _propertyChangedInfo = null;
- _lastPropertyChangedInfo = null;
- }
-
- ///
- /// Disables change tracking.
- ///
- public void DisableChangeTracking()
- {
- _changeTrackingEnabled = false;
- }
-
- ///
- /// Enables change tracking.
- ///
- public void EnableChangeTracking()
- {
- _changeTrackingEnabled = true;
- }
-
- ///
- /// Sets a property value, detects changes and manages the dirty flag.
- ///
- /// The type of the value.
- /// The new value.
- /// A reference to the value to set.
- /// The property selector.
- internal void SetPropertyValueAndDetectChanges(T value, ref T valueRef, PropertyInfo propertySelector)
- {
- if ((typeof(T) == typeof(string) == false) && TypeHelper.IsTypeAssignableFrom(typeof(T)))
- {
- throw new InvalidOperationException("This method does not support IEnumerable instances. For IEnumerable instances a manual custom equality check will be required");
- }
-
- SetPropertyValueAndDetectChanges(value, ref valueRef, propertySelector, EqualityComparer.Default);
- }
-
- ///
- /// Sets a property value, detects changes and manages the dirty flag.
- ///
- /// The type of the value.
- /// The new value.
- /// A reference to the value to set.
- /// The property selector.
- /// A comparer to compare property values.
- internal void SetPropertyValueAndDetectChanges(T value, ref T valueRef, PropertyInfo propertySelector, IEqualityComparer comparer)
- {
- var changed = _changeTrackingEnabled && comparer.Equals(valueRef, value) == false;
-
- valueRef = value;
-
- if (changed)
- OnPropertyChanged(propertySelector);
- }
-
- ///
- /// Detects changes and manages the dirty flag.
- ///
- /// The type of the value.
- /// The new value.
- /// The original value.
- /// The property selector.
- /// A comparer to compare property values.
- /// A value indicating whether we know values have changed and no comparison is required.
- internal void DetectChanges(T value, T orig, PropertyInfo propertySelector, IEqualityComparer comparer, bool changed)
- {
- if (_changeTrackingEnabled == false)
- return;
-
- if (!changed)
- changed = comparer.Equals(orig, value) == false;
-
- if (changed)
- OnPropertyChanged(propertySelector);
- }
- }
-}
diff --git a/src/Umbraco.Core/Models/EntityBase/TreeEntityPath.cs b/src/Umbraco.Core/Models/EntityBase/TreeEntityPath.cs
new file mode 100644
index 0000000000..746011a85a
--- /dev/null
+++ b/src/Umbraco.Core/Models/EntityBase/TreeEntityPath.cs
@@ -0,0 +1,18 @@
+namespace Umbraco.Core.Models.EntityBase
+{
+ ///
+ /// Represents the path of a tree entity.
+ ///
+ public class TreeEntityPath
+ {
+ ///
+ /// Gets or sets the identifier of the entity.
+ ///
+ public int Id { get; set; }
+
+ ///
+ /// Gets or sets the path of the entity.
+ ///
+ public string Path { get; set; }
+ }
+}
diff --git a/src/Umbraco.Core/Models/File.cs b/src/Umbraco.Core/Models/File.cs
index 97469d8a49..46e6ec633e 100644
--- a/src/Umbraco.Core/Models/File.cs
+++ b/src/Umbraco.Core/Models/File.cs
@@ -13,7 +13,7 @@ namespace Umbraco.Core.Models
///
[Serializable]
[DataContract(IsReference = true)]
- public abstract class File : Entity, IFile
+ public abstract class File : EntityBase.EntityBase, IFile
{
private string _path;
private string _originalPath;
diff --git a/src/Umbraco.Core/Models/Folder.cs b/src/Umbraco.Core/Models/Folder.cs
index 945a47eeb4..321d6b69e6 100644
--- a/src/Umbraco.Core/Models/Folder.cs
+++ b/src/Umbraco.Core/Models/Folder.cs
@@ -2,7 +2,7 @@
namespace Umbraco.Core.Models
{
- internal sealed class Folder : Entity
+ internal sealed class Folder : EntityBase.EntityBase
{
public Folder(string folderPath)
{
diff --git a/src/Umbraco.Core/Models/IDataType.cs b/src/Umbraco.Core/Models/IDataType.cs
new file mode 100644
index 0000000000..b6d70b890f
--- /dev/null
+++ b/src/Umbraco.Core/Models/IDataType.cs
@@ -0,0 +1,32 @@
+using Umbraco.Core.Models.EntityBase;
+
+namespace Umbraco.Core.Models
+{
+ ///
+ /// Represents a data type.
+ ///
+ public interface IDataType : IUmbracoEntity
+ {
+ ///
+ /// Gets or sets the property editor alias.
+ ///
+ string EditorAlias { get; set; }
+
+ ///
+ /// Gets or sets the database type for the data type values.
+ ///
+ /// In most cases this is imposed by the property editor, but some editors
+ /// may support storing different types.
+ DataTypeDatabaseType DatabaseType { get; set; }
+
+ ///
+ /// Gets or sets the configuration object.
+ ///
+ ///
+ /// The configuration object is serialized to Json and stored into the database.
+ /// The serialized Json is deserialized by the property editor, which by default should
+ /// return a Dictionary{string, object} but could return a typed object e.g. MyEditor.Configuration.
+ ///
+ object Configuration { get; set; }
+ }
+}
diff --git a/src/Umbraco.Core/Models/IDataTypeDefinition.cs b/src/Umbraco.Core/Models/IDataTypeDefinition.cs
deleted file mode 100644
index 814512738a..0000000000
--- a/src/Umbraco.Core/Models/IDataTypeDefinition.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using System;
-using Umbraco.Core.Models.EntityBase;
-
-namespace Umbraco.Core.Models
-{
- public interface IDataTypeDefinition : IUmbracoEntity
- {
- ///
- /// The Property editor alias assigned to the data type
- ///
- string PropertyEditorAlias { get; set; }
-
- ///
- /// Gets or Sets the DatabaseType for which the DataType's value is saved as
- ///
- DataTypeDatabaseType DatabaseType { get; set; }
- }
-}
diff --git a/src/Umbraco.Core/Models/IDeepCloneable.cs b/src/Umbraco.Core/Models/IDeepCloneable.cs
index ea41d26dd1..057326b3c7 100644
--- a/src/Umbraco.Core/Models/IDeepCloneable.cs
+++ b/src/Umbraco.Core/Models/IDeepCloneable.cs
@@ -1,7 +1,8 @@
-using System.Reflection;
-
-namespace Umbraco.Core.Models
+namespace Umbraco.Core.Models
{
+ ///
+ /// Provides a mean to deep-clone an object.
+ ///
public interface IDeepCloneable
{
object DeepClone();
diff --git a/src/Umbraco.Core/Models/IDictionaryItem.cs b/src/Umbraco.Core/Models/IDictionaryItem.cs
index b4a1deea89..52b969dc4d 100644
--- a/src/Umbraco.Core/Models/IDictionaryItem.cs
+++ b/src/Umbraco.Core/Models/IDictionaryItem.cs
@@ -2,11 +2,10 @@
using System.Collections.Generic;
using System.Runtime.Serialization;
using Umbraco.Core.Models.EntityBase;
-using Umbraco.Core.Persistence.Mappers;
namespace Umbraco.Core.Models
{
- public interface IDictionaryItem : IAggregateRoot, IRememberBeingDirty, ICanBeDirty
+ public interface IDictionaryItem : IEntity, IRememberBeingDirty
{
///
/// Gets or Sets the Parent Id of the Dictionary Item
diff --git a/src/Umbraco.Core/Models/IDomain.cs b/src/Umbraco.Core/Models/IDomain.cs
index b33c987f9e..ef95f59ded 100644
--- a/src/Umbraco.Core/Models/IDomain.cs
+++ b/src/Umbraco.Core/Models/IDomain.cs
@@ -2,7 +2,7 @@
namespace Umbraco.Core.Models
{
- public interface IDomain : IAggregateRoot, IRememberBeingDirty, ICanBeDirty
+ public interface IDomain : IEntity, IRememberBeingDirty
{
int? LanguageId { get; set; }
string DomainName { get; set; }
diff --git a/src/Umbraco.Core/Models/IFile.cs b/src/Umbraco.Core/Models/IFile.cs
index 77cc21a49b..18dcdcdf80 100644
--- a/src/Umbraco.Core/Models/IFile.cs
+++ b/src/Umbraco.Core/Models/IFile.cs
@@ -7,7 +7,7 @@ namespace Umbraco.Core.Models
/// Defines a File
///
/// Used for Scripts, Stylesheets and Templates
- public interface IFile : IAggregateRoot
+ public interface IFile : IEntity
{
///
/// Gets the Name of the File including extension
diff --git a/src/Umbraco.Core/Models/ILanguage.cs b/src/Umbraco.Core/Models/ILanguage.cs
index 125bebf8e2..2fc82df3a8 100644
--- a/src/Umbraco.Core/Models/ILanguage.cs
+++ b/src/Umbraco.Core/Models/ILanguage.cs
@@ -1,11 +1,10 @@
using System.Globalization;
using System.Runtime.Serialization;
using Umbraco.Core.Models.EntityBase;
-using Umbraco.Core.Persistence.Mappers;
namespace Umbraco.Core.Models
{
- public interface ILanguage : IAggregateRoot, IRememberBeingDirty, ICanBeDirty
+ public interface ILanguage : IEntity, IRememberBeingDirty
{
///
/// Gets or sets the Iso Code for the Language
diff --git a/src/Umbraco.Core/Models/IMacro.cs b/src/Umbraco.Core/Models/IMacro.cs
index 6aafba0a43..7521b22a48 100644
--- a/src/Umbraco.Core/Models/IMacro.cs
+++ b/src/Umbraco.Core/Models/IMacro.cs
@@ -8,7 +8,7 @@ namespace Umbraco.Core.Models
///
/// Defines a Macro
///
- public interface IMacro : IAggregateRoot, IRememberBeingDirty, ICanBeDirty
+ public interface IMacro : IEntity, IRememberBeingDirty
{
///
/// Gets or sets the alias of the Macro
diff --git a/src/Umbraco.Core/Models/IMemberGroup.cs b/src/Umbraco.Core/Models/IMemberGroup.cs
index 0fcf20acb6..1a3d8a3909 100644
--- a/src/Umbraco.Core/Models/IMemberGroup.cs
+++ b/src/Umbraco.Core/Models/IMemberGroup.cs
@@ -6,7 +6,7 @@ namespace Umbraco.Core.Models
///
/// Represents a member type
///
- public interface IMemberGroup : IAggregateRoot, IRememberBeingDirty, ICanBeDirty
+ public interface IMemberGroup : IEntity, IRememberBeingDirty
{
///
/// The name of the member group
diff --git a/src/Umbraco.Core/Models/IMigrationEntry.cs b/src/Umbraco.Core/Models/IMigrationEntry.cs
index 0cc466f1cb..db820b565e 100644
--- a/src/Umbraco.Core/Models/IMigrationEntry.cs
+++ b/src/Umbraco.Core/Models/IMigrationEntry.cs
@@ -4,7 +4,7 @@ using Umbraco.Core.Models.EntityBase;
namespace Umbraco.Core.Models
{
- public interface IMigrationEntry : IAggregateRoot, IRememberBeingDirty
+ public interface IMigrationEntry : IEntity, IRememberBeingDirty
{
string MigrationName { get; set; }
SemVersion Version { get; set; }
diff --git a/src/Umbraco.Core/Models/IRedirectUrl.cs b/src/Umbraco.Core/Models/IRedirectUrl.cs
index 419389f60d..ed28f16855 100644
--- a/src/Umbraco.Core/Models/IRedirectUrl.cs
+++ b/src/Umbraco.Core/Models/IRedirectUrl.cs
@@ -7,7 +7,7 @@ namespace Umbraco.Core.Models
///
/// Represents a redirect url.
///
- public interface IRedirectUrl : IAggregateRoot, IRememberBeingDirty
+ public interface IRedirectUrl : IEntity, IRememberBeingDirty
{
///
/// Gets or sets the identifier of the content item.
diff --git a/src/Umbraco.Core/Models/IRelation.cs b/src/Umbraco.Core/Models/IRelation.cs
index a80d6543a2..33aafa4f4e 100644
--- a/src/Umbraco.Core/Models/IRelation.cs
+++ b/src/Umbraco.Core/Models/IRelation.cs
@@ -3,7 +3,7 @@ using Umbraco.Core.Models.EntityBase;
namespace Umbraco.Core.Models
{
- public interface IRelation : IAggregateRoot, IRememberBeingDirty, ICanBeDirty
+ public interface IRelation : IEntity, IRememberBeingDirty
{
///
/// Gets or sets the Parent Id of the Relation (Source)
diff --git a/src/Umbraco.Core/Models/IRelationType.cs b/src/Umbraco.Core/Models/IRelationType.cs
index 913cee9590..df71fdd541 100644
--- a/src/Umbraco.Core/Models/IRelationType.cs
+++ b/src/Umbraco.Core/Models/IRelationType.cs
@@ -4,7 +4,7 @@ using Umbraco.Core.Models.EntityBase;
namespace Umbraco.Core.Models
{
- public interface IRelationType : IAggregateRoot, IRememberBeingDirty, ICanBeDirty
+ public interface IRelationType : IEntity, IRememberBeingDirty
{
///
/// Gets or sets the Name of the RelationType
diff --git a/src/Umbraco.Core/Models/IServerRegistration.cs b/src/Umbraco.Core/Models/IServerRegistration.cs
index 20513339d8..df7ad57923 100644
--- a/src/Umbraco.Core/Models/IServerRegistration.cs
+++ b/src/Umbraco.Core/Models/IServerRegistration.cs
@@ -4,7 +4,7 @@ using Umbraco.Core.Sync;
namespace Umbraco.Core.Models
{
- public interface IServerRegistration : IServerAddress, IAggregateRoot, IRememberBeingDirty
+ public interface IServerRegistration : IServerAddress, IEntity, IRememberBeingDirty
{
///
/// Gets or sets the server unique identity.
diff --git a/src/Umbraco.Core/Models/ITag.cs b/src/Umbraco.Core/Models/ITag.cs
index 2f05527ed9..734a355efe 100644
--- a/src/Umbraco.Core/Models/ITag.cs
+++ b/src/Umbraco.Core/Models/ITag.cs
@@ -6,7 +6,7 @@ namespace Umbraco.Core.Models
///
/// Represents a Tag, which is composed of a Text, Group and NodeCount property.
///
- public interface ITag : IAggregateRoot, IRememberBeingDirty, ICanBeDirty
+ public interface ITag : IEntity, IRememberBeingDirty
{
[DataMember]
string Text { get; set; }
diff --git a/src/Umbraco.Core/Models/Identity/BackOfficeIdentityUser.cs b/src/Umbraco.Core/Models/Identity/BackOfficeIdentityUser.cs
index cfabcb2d64..fb6a4f6a86 100644
--- a/src/Umbraco.Core/Models/Identity/BackOfficeIdentityUser.cs
+++ b/src/Umbraco.Core/Models/Identity/BackOfficeIdentityUser.cs
@@ -424,7 +424,7 @@ namespace Umbraco.Core.Models.Identity
///
/// internal class used to track changes for properties that have it enabled
///
- private class ChangeTracker : TracksChangesEntityBase
+ private class ChangeTracker : BeingDirtyBase
{
///
/// Make this public so that it's usable
diff --git a/src/Umbraco.Core/Models/Identity/IIdentityUserLogin.cs b/src/Umbraco.Core/Models/Identity/IIdentityUserLogin.cs
index d4d8e5e08e..39a3b911a4 100644
--- a/src/Umbraco.Core/Models/Identity/IIdentityUserLogin.cs
+++ b/src/Umbraco.Core/Models/Identity/IIdentityUserLogin.cs
@@ -2,7 +2,7 @@
namespace Umbraco.Core.Models.Identity
{
- public interface IIdentityUserLogin : IAggregateRoot, IRememberBeingDirty, ICanBeDirty
+ public interface IIdentityUserLogin : IEntity, IRememberBeingDirty
{
///
/// The login provider for the login (i.e. facebook, google)
diff --git a/src/Umbraco.Core/Models/Identity/IdentityUserLogin.cs b/src/Umbraco.Core/Models/Identity/IdentityUserLogin.cs
index 89d20bc948..46a9f6186b 100644
--- a/src/Umbraco.Core/Models/Identity/IdentityUserLogin.cs
+++ b/src/Umbraco.Core/Models/Identity/IdentityUserLogin.cs
@@ -7,7 +7,7 @@ namespace Umbraco.Core.Models.Identity
/// Entity type for a user's login (i.e. facebook, google)
///
///
- public class IdentityUserLogin : Entity, IIdentityUserLogin
+ public class IdentityUserLogin : EntityBase.EntityBase, IIdentityUserLogin
{
public IdentityUserLogin(string loginProvider, string providerKey, int userId)
{
diff --git a/src/Umbraco.Core/Models/Language.cs b/src/Umbraco.Core/Models/Language.cs
index 98acd7430b..5cc9d4948e 100644
--- a/src/Umbraco.Core/Models/Language.cs
+++ b/src/Umbraco.Core/Models/Language.cs
@@ -11,7 +11,7 @@ namespace Umbraco.Core.Models
///
[Serializable]
[DataContract(IsReference = true)]
- public class Language : Entity, ILanguage
+ public class Language : EntityBase.EntityBase, ILanguage
{
private static readonly Lazy Ps = new Lazy();
diff --git a/src/Umbraco.Core/Models/Macro.cs b/src/Umbraco.Core/Models/Macro.cs
index c004e040cc..6ae76505f4 100644
--- a/src/Umbraco.Core/Models/Macro.cs
+++ b/src/Umbraco.Core/Models/Macro.cs
@@ -15,7 +15,7 @@ namespace Umbraco.Core.Models
///
[Serializable]
[DataContract(IsReference = true)]
- public class Macro : Entity, IMacro
+ public class Macro : EntityBase.EntityBase, IMacro
{
public Macro()
{
@@ -181,7 +181,7 @@ namespace Umbraco.Core.Models
base.ResetDirtyProperties(rememberDirty);
foreach (var prop in Properties)
{
- ((TracksChangesEntityBase)prop).ResetDirtyProperties(rememberDirty);
+ ((BeingDirtyBase)prop).ResetDirtyProperties(rememberDirty);
}
}
diff --git a/src/Umbraco.Core/Models/MacroProperty.cs b/src/Umbraco.Core/Models/MacroProperty.cs
index 2aba3c05a1..5936344a79 100644
--- a/src/Umbraco.Core/Models/MacroProperty.cs
+++ b/src/Umbraco.Core/Models/MacroProperty.cs
@@ -11,7 +11,7 @@ namespace Umbraco.Core.Models
///
[Serializable]
[DataContract(IsReference = true)]
- public class MacroProperty : TracksChangesEntityBase, IMacroProperty, IRememberBeingDirty, IDeepCloneable
+ public class MacroProperty : BeingDirtyBase, IMacroProperty, IRememberBeingDirty, IDeepCloneable
{
public MacroProperty()
{
@@ -84,7 +84,7 @@ namespace Umbraco.Core.Models
public readonly PropertyInfo AliasSelector = ExpressionHelper.GetPropertyInfo(x => x.Alias);
public readonly PropertyInfo NameSelector = ExpressionHelper.GetPropertyInfo(x => x.Name);
public readonly PropertyInfo SortOrderSelector = ExpressionHelper.GetPropertyInfo(x => x.SortOrder);
- public readonly PropertyInfo IdSelector = ExpressionHelper.GetPropertyInfo(x => x.Id);
+ public readonly PropertyInfo IdSelector = ExpressionHelper.GetPropertyInfo(x => x.Id);
public readonly PropertyInfo PropertyTypeSelector = ExpressionHelper.GetPropertyInfo(x => x.EditorAlias);
}
diff --git a/src/Umbraco.Core/Models/MemberGroup.cs b/src/Umbraco.Core/Models/MemberGroup.cs
index e7f6355ac2..d1dbedab20 100644
--- a/src/Umbraco.Core/Models/MemberGroup.cs
+++ b/src/Umbraco.Core/Models/MemberGroup.cs
@@ -11,7 +11,7 @@ namespace Umbraco.Core.Models
///
[Serializable]
[DataContract(IsReference = true)]
- public class MemberGroup : Entity, IMemberGroup
+ public class MemberGroup : EntityBase.EntityBase, IMemberGroup
{
public MemberGroup()
{
diff --git a/src/Umbraco.Core/Models/Membership/ContentPermissionSet.cs b/src/Umbraco.Core/Models/Membership/ContentPermissionSet.cs
index f55093402b..9eba76a09d 100644
--- a/src/Umbraco.Core/Models/Membership/ContentPermissionSet.cs
+++ b/src/Umbraco.Core/Models/Membership/ContentPermissionSet.cs
@@ -10,7 +10,7 @@ namespace Umbraco.Core.Models.Membership
///
/// This implements purely so it can be used with the repository layer which is why it's explicitly implemented.
///
- public class ContentPermissionSet : EntityPermissionSet, IAggregateRoot
+ public class ContentPermissionSet : EntityPermissionSet, IEntity
{
private readonly IContent _content;
@@ -43,7 +43,7 @@ namespace Umbraco.Core.Models.Membership
DateTime IEntity.UpdateDate { get; set; }
- DateTime? IDeletableEntity.DeletedDate { get; set; }
+ DateTime? IEntity.DeleteDate { get; set; }
object IDeepCloneable.DeepClone()
{
diff --git a/src/Umbraco.Core/Models/Membership/IMembershipUser.cs b/src/Umbraco.Core/Models/Membership/IMembershipUser.cs
index 5a63997795..15ce8bae46 100644
--- a/src/Umbraco.Core/Models/Membership/IMembershipUser.cs
+++ b/src/Umbraco.Core/Models/Membership/IMembershipUser.cs
@@ -6,7 +6,7 @@ namespace Umbraco.Core.Models.Membership
///
/// Defines the base contract for and
///
- public interface IMembershipUser : IAggregateRoot
+ public interface IMembershipUser : IEntity
{
object ProviderUserKey { get; set; }
string Username { get; set; }
diff --git a/src/Umbraco.Core/Models/Membership/IUserGroup.cs b/src/Umbraco.Core/Models/Membership/IUserGroup.cs
index 0551fcc8a8..7b27657d09 100644
--- a/src/Umbraco.Core/Models/Membership/IUserGroup.cs
+++ b/src/Umbraco.Core/Models/Membership/IUserGroup.cs
@@ -3,7 +3,7 @@ using Umbraco.Core.Models.EntityBase;
namespace Umbraco.Core.Models.Membership
{
- public interface IUserGroup : IAggregateRoot
+ public interface IUserGroup : IEntity
{
string Alias { get; set; }
diff --git a/src/Umbraco.Core/Models/Membership/IUserType.cs b/src/Umbraco.Core/Models/Membership/IUserType.cs
index 6d97a0b206..084e0b6c7f 100644
--- a/src/Umbraco.Core/Models/Membership/IUserType.cs
+++ b/src/Umbraco.Core/Models/Membership/IUserType.cs
@@ -7,7 +7,7 @@ namespace Umbraco.Core.Models.Membership
{
[Obsolete("This should not be used it exists for legacy reasons only, use user groups instead, it will be removed in future versions")]
[EditorBrowsable(EditorBrowsableState.Never)]
- public interface IUserType : IAggregateRoot
+ public interface IUserType : IEntity
{
string Alias { get; set; }
string Name { get; set; }
diff --git a/src/Umbraco.Core/Models/Membership/User.cs b/src/Umbraco.Core/Models/Membership/User.cs
index 9ad1c87108..2d2375cc85 100644
--- a/src/Umbraco.Core/Models/Membership/User.cs
+++ b/src/Umbraco.Core/Models/Membership/User.cs
@@ -18,7 +18,7 @@ namespace Umbraco.Core.Models.Membership
///
[Serializable]
[DataContract(IsReference = true)]
- public class User : Entity, IUser, IProfile
+ public class User : EntityBase.EntityBase, IUser, IProfile
{
///
/// Constructor for creating a new/empty user
@@ -321,7 +321,7 @@ namespace Umbraco.Core.Models.Membership
Id = realGroup.Id,
Key = realGroup.Key,
CreateDate = realGroup.CreateDate,
- DeletedDate = realGroup.DeletedDate,
+ DeletedDate = realGroup.DeleteDate,
Name = realGroup.Name,
Permissions = realGroup.Permissions,
UpdateDate = realGroup.UpdateDate
@@ -338,7 +338,7 @@ namespace Umbraco.Core.Models.Membership
Id = realGroup.Id,
Key = realGroup.Key,
CreateDate = realGroup.CreateDate,
- DeletedDate = realGroup.DeletedDate,
+ DeletedDate = realGroup.DeleteDate,
Name = realGroup.Name,
Permissions = realGroup.Permissions,
UpdateDate = realGroup.UpdateDate
diff --git a/src/Umbraco.Core/Models/Membership/UserGroup.cs b/src/Umbraco.Core/Models/Membership/UserGroup.cs
index dc91862e77..cd9e993bce 100644
--- a/src/Umbraco.Core/Models/Membership/UserGroup.cs
+++ b/src/Umbraco.Core/Models/Membership/UserGroup.cs
@@ -12,7 +12,7 @@ namespace Umbraco.Core.Models.Membership
///
[Serializable]
[DataContract(IsReference = true)]
- internal class UserGroup : Entity, IUserGroup, IReadOnlyUserGroup
+ internal class UserGroup : EntityBase.EntityBase, IUserGroup, IReadOnlyUserGroup
{
private int? _startContentId;
private int? _startMediaId;
diff --git a/src/Umbraco.Core/Models/Membership/UserType.cs b/src/Umbraco.Core/Models/Membership/UserType.cs
index 1b8d71f4c0..1f80d0f4b3 100644
--- a/src/Umbraco.Core/Models/Membership/UserType.cs
+++ b/src/Umbraco.Core/Models/Membership/UserType.cs
@@ -12,7 +12,7 @@ namespace Umbraco.Core.Models.Membership
[EditorBrowsable(EditorBrowsableState.Never)]
[Serializable]
[DataContract(IsReference = true)]
- internal class UserType : Entity, IUserType
+ internal class UserType : EntityBase.EntityBase, IUserType
{
private string _alias;
private string _name;
diff --git a/src/Umbraco.Core/Models/MigrationEntry.cs b/src/Umbraco.Core/Models/MigrationEntry.cs
index f3f696fd71..9407be8950 100644
--- a/src/Umbraco.Core/Models/MigrationEntry.cs
+++ b/src/Umbraco.Core/Models/MigrationEntry.cs
@@ -5,7 +5,7 @@ using Umbraco.Core.Models.EntityBase;
namespace Umbraco.Core.Models
{
- public class MigrationEntry : Entity, IMigrationEntry
+ public class MigrationEntry : EntityBase.EntityBase, IMigrationEntry
{
public MigrationEntry()
{
diff --git a/src/Umbraco.Core/Models/Packaging/InstallationSummary.cs b/src/Umbraco.Core/Models/Packaging/InstallationSummary.cs
index 4ba6a7a1c7..3eb397d728 100644
--- a/src/Umbraco.Core/Models/Packaging/InstallationSummary.cs
+++ b/src/Umbraco.Core/Models/Packaging/InstallationSummary.cs
@@ -9,7 +9,7 @@ namespace Umbraco.Core.Models.Packaging
public class InstallationSummary
{
public MetaData MetaData { get; set; }
- public IEnumerable DataTypesInstalled { get; set; }
+ public IEnumerable DataTypesInstalled { get; set; }
public IEnumerable LanguagesInstalled { get; set; }
public IEnumerable DictionaryItemsInstalled { get; set; }
public IEnumerable MacrosInstalled { get; set; }
@@ -29,7 +29,7 @@ namespace Umbraco.Core.Models.Packaging
summary.Actions = new List();
summary.ContentInstalled = new List();
summary.ContentTypesInstalled = new List();
- summary.DataTypesInstalled = new List();
+ summary.DataTypesInstalled = new List();
summary.DictionaryItemsInstalled = new List();
summary.FilesInstalled = new List();
summary.LanguagesInstalled = new List();
diff --git a/src/Umbraco.Core/Models/Property.cs b/src/Umbraco.Core/Models/Property.cs
index 0d8ab300c8..365247669c 100644
--- a/src/Umbraco.Core/Models/Property.cs
+++ b/src/Umbraco.Core/Models/Property.cs
@@ -14,7 +14,7 @@ namespace Umbraco.Core.Models
///
[Serializable]
[DataContract(IsReference = true)]
- public class Property : Entity
+ public class Property : EntityBase.EntityBase
{
private List _tagChanges;
diff --git a/src/Umbraco.Core/Models/PropertyGroup.cs b/src/Umbraco.Core/Models/PropertyGroup.cs
index fbec228201..a458edb387 100644
--- a/src/Umbraco.Core/Models/PropertyGroup.cs
+++ b/src/Umbraco.Core/Models/PropertyGroup.cs
@@ -13,7 +13,7 @@ namespace Umbraco.Core.Models
[Serializable]
[DataContract(IsReference = true)]
[DebuggerDisplay("Id: {Id}, Name: {Name}")]
- public class PropertyGroup : Entity, IEquatable
+ public class PropertyGroup : EntityBase.EntityBase, IEquatable
{
private static readonly Lazy Ps = new Lazy();
diff --git a/src/Umbraco.Core/Models/PropertyType.cs b/src/Umbraco.Core/Models/PropertyType.cs
index cd5ac63bd3..515a7086ea 100644
--- a/src/Umbraco.Core/Models/PropertyType.cs
+++ b/src/Umbraco.Core/Models/PropertyType.cs
@@ -15,7 +15,7 @@ namespace Umbraco.Core.Models
[Serializable]
[DataContract(IsReference = true)]
[DebuggerDisplay("Id: {Id}, Name: {Name}, Alias: {Alias}")]
- public class PropertyType : Entity, IEquatable
+ public class PropertyType : EntityBase.EntityBase, IEquatable
{
private static readonly Lazy Ps = new Lazy();
@@ -33,20 +33,20 @@ namespace Umbraco.Core.Models
private string _validationRegExp;
private ContentVariation _variations;
- public PropertyType(IDataTypeDefinition dataTypeDefinition)
+ public PropertyType(IDataType dataType)
{
- if (dataTypeDefinition == null) throw new ArgumentNullException("dataTypeDefinition");
+ if (dataType == null) throw new ArgumentNullException("dataType");
- if(dataTypeDefinition.HasIdentity)
- _dataTypeDefinitionId = dataTypeDefinition.Id;
+ if(dataType.HasIdentity)
+ _dataTypeDefinitionId = dataType.Id;
- _propertyEditorAlias = dataTypeDefinition.PropertyEditorAlias;
- _dataTypeDatabaseType = dataTypeDefinition.DatabaseType;
+ _propertyEditorAlias = dataType.EditorAlias;
+ _dataTypeDatabaseType = dataType.DatabaseType;
_variations = ContentVariation.InvariantNeutral;
}
- public PropertyType(IDataTypeDefinition dataTypeDefinition, string propertyTypeAlias)
- : this(dataTypeDefinition)
+ public PropertyType(IDataType dataType, string propertyTypeAlias)
+ : this(dataType)
{
_alias = GetAlias(propertyTypeAlias);
}
@@ -141,7 +141,7 @@ namespace Umbraco.Core.Models
///
/// Gets of Sets the Id of the DataType (Definition), which the PropertyType is "wrapping"
///
- /// This is actually the Id of the
+ /// This is actually the Id of the
[DataMember]
public int DataTypeDefinitionId
{
diff --git a/src/Umbraco.Core/Models/PublicAccessEntry.cs b/src/Umbraco.Core/Models/PublicAccessEntry.cs
index d4b0bc8a3b..0b04bc9782 100644
--- a/src/Umbraco.Core/Models/PublicAccessEntry.cs
+++ b/src/Umbraco.Core/Models/PublicAccessEntry.cs
@@ -11,7 +11,7 @@ namespace Umbraco.Core.Models
{
[Serializable]
[DataContract(IsReference = true)]
- public class PublicAccessEntry : Entity, IAggregateRoot
+ public class PublicAccessEntry : EntityBase.EntityBase
{
private readonly ObservableCollection _ruleCollection;
private int _protectedNodeId;
diff --git a/src/Umbraco.Core/Models/PublicAccessRule.cs b/src/Umbraco.Core/Models/PublicAccessRule.cs
index fe7c4c5e4f..cc21e7a27a 100644
--- a/src/Umbraco.Core/Models/PublicAccessRule.cs
+++ b/src/Umbraco.Core/Models/PublicAccessRule.cs
@@ -7,7 +7,7 @@ namespace Umbraco.Core.Models
{
[Serializable]
[DataContract(IsReference = true)]
- public class PublicAccessRule : Entity
+ public class PublicAccessRule : EntityBase.EntityBase
{
private string _ruleValue;
private string _ruleType;
diff --git a/src/Umbraco.Core/Models/PublishedContent/DataTypeConfigurationSource.cs b/src/Umbraco.Core/Models/PublishedContent/DataTypeConfigurationSource.cs
index 94a1499ff0..45936de1bf 100644
--- a/src/Umbraco.Core/Models/PublishedContent/DataTypeConfigurationSource.cs
+++ b/src/Umbraco.Core/Models/PublishedContent/DataTypeConfigurationSource.cs
@@ -27,6 +27,16 @@ namespace Umbraco.Core.Models.PublishedContent
///
public object GetDataTypeConfiguration(string editorAlias, int id)
{
+ // fixme - this should all be in IDataTypeService
+ //
+ // get data type by id / with -or without- configuration
+ // configuration should just be 1 json field
+ // could be in uNodeData?
+ // then, there is no 'get configuration' at all
+ //
+ // and then, could be
+ // if we consider that the published snapshot service in NuCache does a getall
+
// fixme - we need a more efficient dataTypeService way of getting these
// fixme - would be nice not to pass editorAlias but annoying for tests?
//var datatype = _dataTypeService.GetDataTypeDefinitionById(id);
diff --git a/src/Umbraco.Core/Models/PublishedContent/IPublishedContentTypeFactory.cs b/src/Umbraco.Core/Models/PublishedContent/IPublishedContentTypeFactory.cs
index a24923400c..83d4cca078 100644
--- a/src/Umbraco.Core/Models/PublishedContent/IPublishedContentTypeFactory.cs
+++ b/src/Umbraco.Core/Models/PublishedContent/IPublishedContentTypeFactory.cs
@@ -1,4 +1,4 @@
-namespace Umbraco.Core.Models.PublishedContent
+namespace Umbraco. Core.Models.PublishedContent
{
///
/// Creates published content types.
@@ -8,26 +8,28 @@
///
/// Creates a published content type.
///
- /// The item type.
/// An content type.
/// A published content type corresponding to the item type and content type.
- PublishedContentType CreateContentType(PublishedItemType itemType, IContentTypeComposition contentType);
- // fixme could we derive itemType from contentType?
+ PublishedContentType CreateContentType(IContentTypeComposition contentType);
///
/// Creates a published property type.
///
/// The published content type owning the property.
/// A property type.
- /// A published property type corresponding to the property type and owned by the published content type.
+ /// Is used by constructor to create property types.
PublishedPropertyType CreatePropertyType(PublishedContentType contentType, PropertyType propertyType);
///
/// Creates a published property type.
///
- /// A value indicating whether the property is created by Umbraco.
- /// fixme xplain.
- PublishedPropertyType CreatePropertyType(string propertyTypeAlias, int dataTypeId, string editorAlias, bool umbraco = false);
+ /// The published content type owning the property.
+ /// The property type alias.
+ /// The datatype identifier.
+ /// The property editor alias. FIXME derive from dataTypeId?
+ /// The variations.
+ /// Is used by constructor to create special property types.
+ PublishedPropertyType CreatePropertyType(PublishedContentType contentType, string propertyTypeAlias, int dataTypeId, string propertyEditorAlias, ContentVariation variations);
///
/// Creates a published data type.
diff --git a/src/Umbraco.Core/Models/PublishedContent/IPublishedProperty.cs b/src/Umbraco.Core/Models/PublishedContent/IPublishedProperty.cs
index 1fd9cda069..24c654604c 100644
--- a/src/Umbraco.Core/Models/PublishedContent/IPublishedProperty.cs
+++ b/src/Umbraco.Core/Models/PublishedContent/IPublishedProperty.cs
@@ -8,7 +8,7 @@
///
/// Gets the alias of the property.
///
- string PropertyTypeAlias { get; }
+ string Alias { get; }
///
/// Gets a value indicating whether the property has a value.
diff --git a/src/Umbraco.Core/Models/PublishedContent/PublishedContentType.cs b/src/Umbraco.Core/Models/PublishedContent/PublishedContentType.cs
index 8407c7f4dc..3645835170 100644
--- a/src/Umbraco.Core/Models/PublishedContent/PublishedContentType.cs
+++ b/src/Umbraco.Core/Models/PublishedContent/PublishedContentType.cs
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using Umbraco.Core.Composing;
namespace Umbraco.Core.Models.PublishedContent
{
@@ -15,82 +14,51 @@ namespace Umbraco.Core.Models.PublishedContent
private readonly PublishedPropertyType[] _propertyTypes;
// fast alias-to-index xref containing both the raw alias and its lowercase version
- // fixme - benchmark this!
private readonly Dictionary _indexes = new Dictionary();
- // fixme used in legacy page.cs that should die
- internal PublishedContentType(IContentType contentType)
- : this(PublishedItemType.Content, contentType, new CurrentPublishedContentTypeFactory())
- { }
-
- // fixme above and should die
- private class CurrentPublishedContentTypeFactory : IPublishedContentTypeFactory
- {
- public PublishedContentType CreateContentType(PublishedItemType itemType, IContentTypeComposition contentType)
- {
- return new PublishedContentType(itemType, contentType, this);
- }
-
- public PublishedPropertyType CreatePropertyType(PublishedContentType contentType, PropertyType propertyType)
- {
- return new PublishedPropertyType(contentType, propertyType, Current.PublishedModelFactory, Current.PropertyValueConverters, this);
- }
-
- public PublishedPropertyType CreatePropertyType(string propertyTypeAlias, int dataTypeId, string editorAlias, bool umbraco = false)
- {
- return new PublishedPropertyType(propertyTypeAlias, dataTypeId, editorAlias, umbraco, Current.PublishedModelFactory, Current.PropertyValueConverters, this);
- }
-
- public PublishedDataType CreateDataType(int id, string editorAlias)
- {
- return new PublishedDataType(id, editorAlias, new DataTypeConfigurationSource(Current.Services.DataTypeService, Current.PropertyEditors));
- }
- }
-
- // this is the main and only true ctor
- internal PublishedContentType(PublishedItemType itemType, IContentTypeComposition contentType, IPublishedContentTypeFactory factory)
- : this(contentType.Id, contentType.Alias, itemType, contentType.CompositionAliases())
+ ///
+ /// Initializes a new instance of the class with a content type.
+ ///
+ public PublishedContentType(IContentTypeComposition contentType, IPublishedContentTypeFactory factory)
+ : this(contentType.Id, contentType.Alias, contentType.GetItemType(), contentType.CompositionAliases(), contentType.Variations)
{
var propertyTypes = contentType.CompositionPropertyTypes
- .Select(x => factory.CreatePropertyType(this, x));
+ .Select(x => factory.CreatePropertyType(this, x))
+ .ToList();
+
+ if (ItemType == PublishedItemType.Member)
+ EnsureMemberProperties(propertyTypes, factory);
- if (itemType == PublishedItemType.Member)
- propertyTypes = WithMemberProperties(this, propertyTypes, factory);
_propertyTypes = propertyTypes.ToArray();
InitializeIndexes();
}
- private PublishedContentType(int id, string alias, PublishedItemType itemType, IEnumerable compositionAliases)
+ ///
+ /// Initializes a new instance of the with specific values.
+ ///
+ ///
+ /// This constructor is for tests and is not intended to be used directly from application code.
+ /// Values are assumed to be consisted and are not checked.
+ ///
+ public PublishedContentType(int id, string alias, PublishedItemType itemType, IEnumerable compositionAliases, IEnumerable propertyTypes, ContentVariation variations)
+ : this (id, alias, itemType, compositionAliases, variations)
+ {
+ var propertyTypesA = propertyTypes.ToArray();
+ foreach (var propertyType in propertyTypesA)
+ propertyType.ContentType = this;
+ _propertyTypes = propertyTypesA;
+
+ InitializeIndexes();
+ }
+
+ private PublishedContentType(int id, string alias, PublishedItemType itemType, IEnumerable compositionAliases, ContentVariation variations)
{
Id = id;
Alias = alias;
ItemType = itemType;
CompositionAliases = new HashSet(compositionAliases, StringComparer.InvariantCultureIgnoreCase);
- }
-
- // internal so it can be used for unit tests
- internal PublishedContentType(int id, string alias, IEnumerable propertyTypes, IPublishedContentTypeFactory factory)
- : this(id, alias, PublishedItemType.Content, Enumerable.Empty(), propertyTypes, factory)
- { }
-
- // internal so it can be used for unit tests
- internal PublishedContentType(int id, string alias, IEnumerable compositionAliases, IEnumerable propertyTypes, IPublishedContentTypeFactory factory)
- : this(id, alias, PublishedItemType.Content, compositionAliases, propertyTypes, factory)
- { }
-
- private PublishedContentType(int id, string alias, PublishedItemType itemType, IEnumerable compositionAliases, IEnumerable propertyTypes, IPublishedContentTypeFactory factory)
- : this (id, alias, itemType, compositionAliases)
- {
- var propertyTypesA = propertyTypes.ToArray();
- foreach (var propertyType in propertyTypesA)
- propertyType.ContentType = this;
-
- if (itemType == PublishedItemType.Member)
- propertyTypesA = WithMemberProperties(this, propertyTypesA, factory).ToArray();
- _propertyTypes = propertyTypesA;
-
- InitializeIndexes();
+ Variations = variations;
}
private void InitializeIndexes()
@@ -98,66 +66,80 @@ namespace Umbraco.Core.Models.PublishedContent
for (var i = 0; i < _propertyTypes.Length; i++)
{
var propertyType = _propertyTypes[i];
- _indexes[propertyType.PropertyTypeAlias] = i;
- _indexes[propertyType.PropertyTypeAlias.ToLowerInvariant()] = i;
+ _indexes[propertyType.Alias] = i;
+ _indexes[propertyType.Alias.ToLowerInvariant()] = i;
}
}
- // NOTE: code below defines and add custom, built-in, Umbraco properties for members
- // unless they are already user-defined in the content type, then they are skipped
- // not sure it's needed really - this is here for safety purposes
- private static readonly Dictionary> BuiltinMemberProperties = new Dictionary>
+ // Members have properties such as IMember LastLoginDate which are plain C# properties and not content
+ // properties; they are exposed as pseudo content properties, as long as a content property with the
+ // same alias does not exist already.
+ private void EnsureMemberProperties(List propertyTypes, IPublishedContentTypeFactory factory)
{
- // see also PublishedMember class - exposing special properties as properties
- { "Email", Tuple.Create(Constants.DataTypes.Textbox, Constants.PropertyEditors.TextboxAlias) },
- { "Username", Tuple.Create(Constants.DataTypes.Textbox, Constants.PropertyEditors.TextboxAlias) },
- { "PasswordQuestion", Tuple.Create(Constants.DataTypes.Textbox, Constants.PropertyEditors.TextboxAlias) },
- { "Comments", Tuple.Create(Constants.DataTypes.Textbox, Constants.PropertyEditors.TextboxAlias) },
- { "IsApproved", Tuple.Create(Constants.DataTypes.Boolean, Constants.PropertyEditors.BooleanAlias) },
- { "IsLockedOut", Tuple.Create(Constants.DataTypes.Boolean, Constants.PropertyEditors.BooleanAlias) },
- { "LastLockoutDate", Tuple.Create(Constants.DataTypes.Datetime, Constants.PropertyEditors.DateTimeAlias) },
- { "CreateDate", Tuple.Create(Constants.DataTypes.Datetime, Constants.PropertyEditors.DateTimeAlias) },
- { "LastLoginDate", Tuple.Create(Constants.DataTypes.Datetime, Constants.PropertyEditors.DateTimeAlias) },
- { "LastPasswordChangeDate", Tuple.Create(Constants.DataTypes.Datetime, Constants.PropertyEditors.DateTimeAlias) },
+ var aliases = new HashSet(propertyTypes.Select(x => x.Alias), StringComparer.OrdinalIgnoreCase);
+
+ foreach ((var alias, (var dataTypeId, var editorAlias)) in BuiltinMemberProperties)
+ {
+ if (aliases.Contains(alias)) continue;
+ propertyTypes.Add(factory.CreatePropertyType(this, alias, dataTypeId, editorAlias, ContentVariation.InvariantNeutral));
+ }
+ }
+
+ // fixme - this list somehow also exists in constants, see memberTypeRepository => remove duplicate!
+ private static readonly Dictionary BuiltinMemberProperties = new Dictionary
+ {
+ { "Email", (Constants.DataTypes.Textbox, Constants.PropertyEditors.TextboxAlias) },
+ { "Username", (Constants.DataTypes.Textbox, Constants.PropertyEditors.TextboxAlias) },
+ { "PasswordQuestion", (Constants.DataTypes.Textbox, Constants.PropertyEditors.TextboxAlias) },
+ { "Comments", (Constants.DataTypes.Textbox, Constants.PropertyEditors.TextboxAlias) },
+ { "IsApproved", (Constants.DataTypes.Boolean, Constants.PropertyEditors.BooleanAlias) },
+ { "IsLockedOut", (Constants.DataTypes.Boolean, Constants.PropertyEditors.BooleanAlias) },
+ { "LastLockoutDate", (Constants.DataTypes.Datetime, Constants.PropertyEditors.DateTimeAlias) },
+ { "CreateDate", (Constants.DataTypes.Datetime, Constants.PropertyEditors.DateTimeAlias) },
+ { "LastLoginDate", (Constants.DataTypes.Datetime, Constants.PropertyEditors.DateTimeAlias) },
+ { "LastPasswordChangeDate", (Constants.DataTypes.Datetime, Constants.PropertyEditors.DateTimeAlias) },
};
- private static IEnumerable WithMemberProperties(PublishedContentType contentType, IEnumerable propertyTypes, IPublishedContentTypeFactory factory)
- {
- var aliases = new HashSet(StringComparer.OrdinalIgnoreCase);
- foreach (var propertyType in propertyTypes)
- {
- aliases.Add(propertyType.PropertyTypeAlias);
- yield return propertyType;
- }
-
- foreach (var propertyType in BuiltinMemberProperties
- .Where(kvp => aliases.Contains(kvp.Key) == false)
- .Select(kvp => factory.CreatePropertyType(kvp.Key, kvp.Value.Item1, kvp.Value.Item2, umbraco: true)))
- {
- // fixme why would it be null?
- if (contentType != null) propertyType.ContentType = contentType;
- yield return propertyType;
- }
- }
-
#region Content type
+ ///
+ /// Gets the content type identifier.
+ ///
public int Id { get; }
+ ///
+ /// Gets the content type alias.
+ ///
public string Alias { get; }
+ ///
+ /// Gets the content item type.
+ ///
public PublishedItemType ItemType { get; }
+ ///
+ /// Gets the aliases of the content types participating in the composition.
+ ///
public HashSet CompositionAliases { get; }
+ ///
+ /// Gets the content variations of the content type.
+ ///
+ public ContentVariation Variations { get; }
+
#endregion
#region Properties
+ ///
+ /// Gets the content type properties.
+ ///
public IEnumerable PropertyTypes => _propertyTypes;
- // alias is case-insensitive
- // this is the ONLY place where we compare ALIASES!
+ ///
+ /// Gets a property type index.
+ ///
+ /// The alias is case-insensitive. This is the only place where alias strings are compared.
public int GetPropertyIndex(string alias)
{
if (_indexes.TryGetValue(alias, out var index)) return index; // fastest
@@ -165,14 +147,20 @@ namespace Umbraco.Core.Models.PublishedContent
return -1;
}
- // virtual for unit tests
+ // virtual for unit tests - fixme explain
+ ///
+ /// Gets a property type.
+ ///
public virtual PublishedPropertyType GetPropertyType(string alias)
{
var index = GetPropertyIndex(alias);
return GetPropertyType(index);
}
- // virtual for unit tests
+ // virtual for unit tests - fixme explain
+ ///
+ /// Gets a property type.
+ ///
public virtual PublishedPropertyType GetPropertyType(int index)
{
return index >= 0 && index < _propertyTypes.Length ? _propertyTypes[index] : null;
diff --git a/src/Umbraco.Core/Models/PublishedContent/PublishedContentTypeFactory.cs b/src/Umbraco.Core/Models/PublishedContent/PublishedContentTypeFactory.cs
index 1394ba4387..5a4214eab0 100644
--- a/src/Umbraco.Core/Models/PublishedContent/PublishedContentTypeFactory.cs
+++ b/src/Umbraco.Core/Models/PublishedContent/PublishedContentTypeFactory.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using System.Linq;
using Umbraco.Core.PropertyEditors;
namespace Umbraco.Core.Models.PublishedContent
@@ -20,33 +21,39 @@ namespace Umbraco.Core.Models.PublishedContent
}
///
- public PublishedContentType CreateContentType(PublishedItemType itemType, IContentTypeComposition contentType)
+ public PublishedContentType CreateContentType(IContentTypeComposition contentType)
{
- return new PublishedContentType(itemType, contentType, this);
+ return new PublishedContentType(contentType, this);
}
- // for tests
- internal PublishedContentType CreateContentType(int id, string alias, IEnumerable propertyTypes)
+ // for tests - fixme what's the point of the factory here?
+ internal PublishedContentType CreateContentType(int id, string alias, IEnumerable propertyTypes, ContentVariation variations = ContentVariation.InvariantNeutral)
{
- return new PublishedContentType(id, alias, propertyTypes, this);
+ return new PublishedContentType(id, alias, PublishedItemType.Content, Enumerable.Empty(), propertyTypes, variations);
}
- // for tests
- internal PublishedContentType CreateContentType(int id, string alias, IEnumerable compositionAliases, IEnumerable propertyTypes)
+ // for tests - fixme what's the point of the factory here?
+ internal PublishedContentType CreateContentType(int id, string alias, IEnumerable compositionAliases, IEnumerable propertyTypes, ContentVariation variations = ContentVariation.InvariantNeutral)
{
- return new PublishedContentType(id, alias, compositionAliases, propertyTypes, this);
+ return new PublishedContentType(id, alias, PublishedItemType.Content, compositionAliases, propertyTypes, variations);
}
///
public PublishedPropertyType CreatePropertyType(PublishedContentType contentType, PropertyType propertyType)
{
- return new PublishedPropertyType(contentType, propertyType, _publishedModelFactory, _propertyValueConverters, this);
+ return new PublishedPropertyType(contentType, propertyType, _propertyValueConverters, _publishedModelFactory, this);
}
///
- public PublishedPropertyType CreatePropertyType(string propertyTypeAlias, int dataTypeId, string editorAlias, bool umbraco = false)
+ public PublishedPropertyType CreatePropertyType(PublishedContentType contentType, string propertyTypeAlias, int dataTypeId, string propertyEditorAlias, ContentVariation variations = ContentVariation.InvariantNeutral)
{
- return new PublishedPropertyType(propertyTypeAlias, dataTypeId, editorAlias, umbraco, _publishedModelFactory, _propertyValueConverters, this);
+ return new PublishedPropertyType(contentType, propertyTypeAlias, dataTypeId, propertyEditorAlias, true, variations, _propertyValueConverters, _publishedModelFactory, this);
+ }
+
+ // for tests
+ internal PublishedPropertyType CreatePropertyType(string propertyTypeAlias, int dataTypeId, string propertyEditorAlias, bool umbraco = false, ContentVariation variations = ContentVariation.InvariantNeutral)
+ {
+ return new PublishedPropertyType(propertyTypeAlias, dataTypeId, propertyEditorAlias, umbraco, variations, _propertyValueConverters, _publishedModelFactory, this);
}
///
diff --git a/src/Umbraco.Core/Models/PublishedContent/PublishedDataType.cs b/src/Umbraco.Core/Models/PublishedContent/PublishedDataType.cs
index 3e0eb4633e..a6cdc81bba 100644
--- a/src/Umbraco.Core/Models/PublishedContent/PublishedDataType.cs
+++ b/src/Umbraco.Core/Models/PublishedContent/PublishedDataType.cs
@@ -43,7 +43,7 @@ namespace Umbraco.Core.Models.PublishedContent
=> _configuration ?? (_configuration = _dataTypeConfigurationSource.GetDataTypeConfiguration(EditorAlias, Id));
///
- /// Gets the data type configuration.
+ /// Gets the data type typed configuration.
///
/// The type of the configuration object.
/// The data type configuration.
diff --git a/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyBase.cs b/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyBase.cs
index 34b2ba9495..918bdb86e4 100644
--- a/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyBase.cs
+++ b/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyBase.cs
@@ -9,6 +9,9 @@ namespace Umbraco.Core.Models.PublishedContent
///
internal abstract class PublishedPropertyBase : IPublishedProperty
{
+ ///
+ /// Initializes a new instance of the class.
+ ///
protected PublishedPropertyBase(PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel)
{
PropertyType = propertyType ?? throw new ArgumentNullException(nameof(propertyType));
@@ -18,6 +21,7 @@ namespace Umbraco.Core.Models.PublishedContent
ValidateCacheLevel(PropertyType.CacheLevel, false);
}
+ // validates the cache level
private static void ValidateCacheLevel(PropertyCacheLevel cacheLevel, bool validateUnknown)
{
switch (cacheLevel)
@@ -35,14 +39,29 @@ namespace Umbraco.Core.Models.PublishedContent
}
}
+ ///
+ /// Gets the property type.
+ ///
public PublishedPropertyType PropertyType { get; }
- public string PropertyTypeAlias => PropertyType.PropertyTypeAlias;
+
+ ///
+ /// Gets the property reference cache level.
+ ///
public PropertyCacheLevel ReferenceCacheLevel { get; }
- // these have to be provided by the actual implementation
+ ///
+ public string Alias => PropertyType.Alias;
+
+ ///
public abstract bool HasValue(int? languageId = null, string segment = null);
+
+ ///
public abstract object GetSourceValue(int? languageId = null, string segment = null);
+
+ ///
public abstract object GetValue(int? languageId = null, string segment = null);
+
+ ///
public abstract object GetXPathValue(int? languageId = null, string segment = null);
}
}
diff --git a/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyType.cs b/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyType.cs
index 4329f982c3..0574ff2728 100644
--- a/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyType.cs
+++ b/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyType.cs
@@ -24,46 +24,51 @@ namespace Umbraco.Core.Models.PublishedContent
#region Constructors
- // the first ctor is the default one, used in PublishedContentType to create the property types
- // the second ctor is the test ctor,
- // some parameters are optional, and they are all assumed to be valid and consistent
-
///
- /// Initialize a new instance of the class within a ,
- /// and with a .
+ /// Initialize a new instance of the class with a property type.
///
- /// The new published property type belongs to the published content type and corresponds to the property type.
- public PublishedPropertyType(PublishedContentType contentType, PropertyType propertyType, IPublishedModelFactory publishedModelFactory, PropertyValueConverterCollection propertyValueConverters, IPublishedContentTypeFactory factory)
- : this(propertyType.Alias, propertyType.DataTypeDefinitionId, propertyType.PropertyEditorAlias, false, publishedModelFactory, propertyValueConverters, factory)
+ ///
+ /// The new published property type belongs to the published content type.
+ ///
+ public PublishedPropertyType(PublishedContentType contentType, PropertyType propertyType, PropertyValueConverterCollection propertyValueConverters, IPublishedModelFactory publishedModelFactory, IPublishedContentTypeFactory factory)
+ : this(propertyType.Alias, propertyType.DataTypeDefinitionId, propertyType.PropertyEditorAlias, true, propertyType.Variations, propertyValueConverters, publishedModelFactory, factory)
{
- // PropertyEditor [1:n] DataTypeDefinition [1:n] PropertyType
-
ContentType = contentType ?? throw new ArgumentNullException(nameof(contentType));
}
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class with specific values.
///
///
- /// The new published property type does not belong to a published content type. fixme should they?
- /// The values of parameters are assumed to be valid and consistent.
- ///
+ /// This constructor is for tests and is not intended to be used directly from application code.
+ /// Values are assumed to be consisted and are not checked.
+ /// The new published property type belongs to the published content type.
///
- internal PublishedPropertyType(string propertyTypeAlias, int dataTypeId, string editorAlias, bool umbraco, IPublishedModelFactory publishedModelFactory, PropertyValueConverterCollection propertyValueConverters, IPublishedContentTypeFactory factory)
+ public PublishedPropertyType(PublishedContentType contentType, string propertyTypeAlias, int dataTypeId, string editorAlias, bool isUserProperty, ContentVariation variations, PropertyValueConverterCollection propertyValueConverters, IPublishedModelFactory publishedModelFactory, IPublishedContentTypeFactory factory)
+ : this(propertyTypeAlias, dataTypeId, editorAlias, isUserProperty, variations, propertyValueConverters, publishedModelFactory, factory)
{
- // ContentType
- // - in unit tests, to be set by PublishedContentType when creating it
+ ContentType = contentType ?? throw new ArgumentNullException(nameof(contentType));
+ }
+ ///
+ /// Initializes a new instance of the class with specific values.
+ ///
+ ///
+ /// This constructor is for tests and is not intended to be used directly from application code.
+ /// Values are assumed to be consisted and are not checked.
+ /// The new published property type does not belong to a published content type.
+ ///
+ public PublishedPropertyType(string propertyTypeAlias, int dataTypeId, string editorAlias, bool isUserProperty, ContentVariation variations, PropertyValueConverterCollection propertyValueConverters, IPublishedModelFactory publishedModelFactory, IPublishedContentTypeFactory factory)
+ {
_publishedModelFactory = publishedModelFactory ?? throw new ArgumentNullException(nameof(publishedModelFactory));
_propertyValueConverters = propertyValueConverters ?? throw new ArgumentNullException(nameof(propertyValueConverters));
- PropertyTypeAlias = propertyTypeAlias;
+ Alias = propertyTypeAlias;
- DataTypeId = dataTypeId;
- PropertyEditorAlias = editorAlias;
- IsUmbraco = umbraco;
+ IsUserProperty = isUserProperty;
+ Variations = variations;
- DataType = factory.CreateDataType(DataTypeId, PropertyEditorAlias);
+ DataType = factory.CreateDataType(dataTypeId, editorAlias);
}
#endregion
@@ -72,34 +77,36 @@ namespace Umbraco.Core.Models.PublishedContent
///
/// Gets the published content type containing the property type.
- ///
- // internally set by PublishedContentType constructor
- public PublishedContentType ContentType { get; internal set; }
+ ///
+ public PublishedContentType ContentType { get; internal set; } // internally set by PublishedContentType constructor
///
- /// Gets the data type of the property.
+ /// Gets the data type.
///
public PublishedDataType DataType { get; }
///
- /// Gets the alias uniquely identifying the property type.
+ /// Gets property type alias.
///
- public string PropertyTypeAlias { get; } // fixme - should be .ContentType.??
+ public string Alias { get; }
///
- /// Gets the identifier uniquely identifying the data type supporting the property type.
+ /// Gets the property editor alias.
///
- public int DataTypeId { get; } // fixme - should be .DataType.Id
+ public string EditorAlias => DataType.EditorAlias;
///
- /// Gets the alias uniquely identifying the property editor for the property type.
+ /// Gets a value indicating whether the property is a user content property.
///
- public string PropertyEditorAlias { get; } // fixme - should be .DataType.EditorAlias
+ /// A non-user content property is a property that has been added to a
+ /// published content type by Umbraco but does not corresponds to a user-defined
+ /// published property.
+ public bool IsUserProperty { get; }
///
- /// Gets a value indicating whether the property is an Umbraco-defined property.
+ /// Gets the content variations of the property type.
///
- internal bool IsUmbraco { get; }
+ public ContentVariation Variations { get; }
#endregion
@@ -123,7 +130,7 @@ namespace Umbraco.Core.Models.PublishedContent
foreach (var converter in _propertyValueConverters)
{
- if (converter.IsConverter(this) == false)
+ if (!converter.IsConverter(this))
continue;
if (_converter == null)
@@ -153,7 +160,7 @@ namespace Umbraco.Core.Models.PublishedContent
throw new InvalidOperationException(string.Format("Type '{2}' cannot be an IPropertyValueConverter"
+ " for property '{1}' of content type '{0}' because type '{3}' has already been detected as a converter"
+ " for that property, and only one converter can exist for a property.",
- ContentType.Alias, PropertyTypeAlias,
+ ContentType.Alias, Alias,
converter.GetType().FullName, _converter.GetType().FullName));
}
}
@@ -176,7 +183,7 @@ namespace Umbraco.Core.Models.PublishedContent
throw new InvalidOperationException(string.Format("Type '{2}' cannot be an IPropertyValueConverter"
+ " for property '{1}' of content type '{0}' because type '{3}' has already been detected as a converter"
+ " for that property, and only one converter can exist for a property.",
- ContentType.Alias, PropertyTypeAlias,
+ ContentType.Alias, Alias,
converter.GetType().FullName, _converter.GetType().FullName));
}
}
diff --git a/src/Umbraco.Core/Models/PublishedContent/RawValueProperty.cs b/src/Umbraco.Core/Models/PublishedContent/RawValueProperty.cs
index d81a8962dc..f938880060 100644
--- a/src/Umbraco.Core/Models/PublishedContent/RawValueProperty.cs
+++ b/src/Umbraco.Core/Models/PublishedContent/RawValueProperty.cs
@@ -5,30 +5,45 @@ namespace Umbraco.Core.Models.PublishedContent
{
///
///
- /// A published property base that uses a raw object value.
+ /// Represents a published property that has a unique invariant-neutral value
+ /// and caches conversion results locally.
///
- /// Conversions results are stored within the property and will not
- /// be refreshed, so this class is not suitable for cached properties.
+ ///
+ /// Conversions results are stored within the property and will not
+ /// be refreshed, so this class is not suitable for cached properties.
+ /// Does not support variations: the ctor throws if the property type
+ /// supports variations.
+ ///
internal class RawValueProperty : PublishedPropertyBase
{
- private readonly object _propertyData; //the value in the db
+ private readonly object _sourceValue; //the value in the db
private readonly Lazy
[Serializable]
[DataContract(IsReference = true)]
- public class RedirectUrl : Entity, IRedirectUrl
+ public class RedirectUrl : EntityBase.EntityBase, IRedirectUrl
{
///
/// Initializes a new instance of the class.
diff --git a/src/Umbraco.Core/Models/Relation.cs b/src/Umbraco.Core/Models/Relation.cs
index e432c84fc2..a6d3023235 100644
--- a/src/Umbraco.Core/Models/Relation.cs
+++ b/src/Umbraco.Core/Models/Relation.cs
@@ -11,7 +11,7 @@ namespace Umbraco.Core.Models
///
[Serializable]
[DataContract(IsReference = true)]
- public class Relation : Entity, IAggregateRoot, IRelation
+ public class Relation : EntityBase.EntityBase, IRelation
{
//NOTE: The datetime column from umbracoRelation is set on CreateDate on the Entity
private int _parentId;
diff --git a/src/Umbraco.Core/Models/RelationType.cs b/src/Umbraco.Core/Models/RelationType.cs
index 0f6ce2ce69..70f14e3571 100644
--- a/src/Umbraco.Core/Models/RelationType.cs
+++ b/src/Umbraco.Core/Models/RelationType.cs
@@ -12,7 +12,7 @@ namespace Umbraco.Core.Models
///
[Serializable]
[DataContract(IsReference = true)]
- public class RelationType : Entity, IAggregateRoot, IRelationType
+ public class RelationType : EntityBase.EntityBase, IRelationType
{
private string _name;
private string _alias;
diff --git a/src/Umbraco.Core/Models/ServerRegistration.cs b/src/Umbraco.Core/Models/ServerRegistration.cs
index b6deafc242..9e0eef340a 100644
--- a/src/Umbraco.Core/Models/ServerRegistration.cs
+++ b/src/Umbraco.Core/Models/ServerRegistration.cs
@@ -8,7 +8,7 @@ namespace Umbraco.Core.Models
///
/// Represents a registered server in a multiple-servers environment.
///
- public class ServerRegistration : Entity, IServerRegistration
+ public class ServerRegistration : EntityBase.EntityBase, IServerRegistration
{
private string _serverAddress;
private string _serverIdentity;
diff --git a/src/Umbraco.Core/Models/StylesheetProperty.cs b/src/Umbraco.Core/Models/StylesheetProperty.cs
index 41fbd8d2b4..d014590a06 100644
--- a/src/Umbraco.Core/Models/StylesheetProperty.cs
+++ b/src/Umbraco.Core/Models/StylesheetProperty.cs
@@ -13,7 +13,7 @@ namespace Umbraco.Core.Models
///
[Serializable]
[DataContract(IsReference = true)]
- public class StylesheetProperty : TracksChangesEntityBase, IValueObject
+ public class StylesheetProperty : BeingDirtyBase, IValueObject
{
private string _alias;
private string _value;
diff --git a/src/Umbraco.Core/Models/Tag.cs b/src/Umbraco.Core/Models/Tag.cs
index 526ce9def4..7d45d3afcf 100644
--- a/src/Umbraco.Core/Models/Tag.cs
+++ b/src/Umbraco.Core/Models/Tag.cs
@@ -8,7 +8,7 @@ namespace Umbraco.Core.Models
{
[Serializable]
[DataContract(IsReference = true)]
- public class Tag : Entity, ITag
+ public class Tag : EntityBase.EntityBase, ITag
{
public Tag()
{
diff --git a/src/Umbraco.Core/Models/Task.cs b/src/Umbraco.Core/Models/Task.cs
index cbbe690288..2b0203b75e 100644
--- a/src/Umbraco.Core/Models/Task.cs
+++ b/src/Umbraco.Core/Models/Task.cs
@@ -10,7 +10,7 @@ namespace Umbraco.Core.Models
///
[Serializable]
[DataContract(IsReference = true)]
- public class Task : Entity, IAggregateRoot
+ public class Task : EntityBase.EntityBase
{
private bool _closed;
private TaskType _taskType;
diff --git a/src/Umbraco.Core/Models/TaskType.cs b/src/Umbraco.Core/Models/TaskType.cs
index 72b2e0f459..8440e8b846 100644
--- a/src/Umbraco.Core/Models/TaskType.cs
+++ b/src/Umbraco.Core/Models/TaskType.cs
@@ -10,7 +10,7 @@ namespace Umbraco.Core.Models
///
[Serializable]
[DataContract(IsReference = true)]
- public class TaskType : Entity, IAggregateRoot
+ public class TaskType : EntityBase.EntityBase
{
private string _alias;
diff --git a/src/Umbraco.Core/Models/UmbracoDomain.cs b/src/Umbraco.Core/Models/UmbracoDomain.cs
index aee3896795..839a8edf51 100644
--- a/src/Umbraco.Core/Models/UmbracoDomain.cs
+++ b/src/Umbraco.Core/Models/UmbracoDomain.cs
@@ -7,7 +7,7 @@ namespace Umbraco.Core.Models
{
[Serializable]
[DataContract(IsReference = true)]
- public class UmbracoDomain : Entity, IDomain
+ public class UmbracoDomain : EntityBase.EntityBase, IDomain
{
public UmbracoDomain(string domainName)
{
diff --git a/src/Umbraco.Core/Models/UmbracoEntity.cs b/src/Umbraco.Core/Models/UmbracoEntity.cs
index 310a3e51d8..aebf0a4de0 100644
--- a/src/Umbraco.Core/Models/UmbracoEntity.cs
+++ b/src/Umbraco.Core/Models/UmbracoEntity.cs
@@ -1,9 +1,7 @@
using System;
using System.Collections.Generic;
-using System.Globalization;
using System.Linq;
using System.Reflection;
-using System.Runtime.CompilerServices;
using Umbraco.Core.Models.EntityBase;
namespace Umbraco.Core.Models
@@ -11,20 +9,26 @@ namespace Umbraco.Core.Models
///
/// Implementation of the for internal use.
///
- public class UmbracoEntity : Entity, IUmbracoEntity
+ public class UmbracoEntity : EntityBase.EntityBase, IUmbracoEntity
{
private static readonly Lazy Ps = new Lazy();
private int _creatorId;
+
private int _level;
private string _name;
private int _parentId;
private string _path;
private int _sortOrder;
private bool _trashed;
+
private bool _hasChildren;
+
+ // fixme - these are for IContent only - MOVE!
private bool _published;
private bool _edited;
+
+ // fixme - these are for IContentBase only - MOVE!
private string _contentTypeAlias;
private Guid _nodeObjectTypeId;
@@ -189,22 +193,28 @@ namespace Umbraco.Core.Models
{
var clone = (UmbracoEntity) base.DeepClone();
- // turn off change tracking
+ // disable change tracking
clone.DisableChangeTracking();
- // ensure that any value in the dictionary that is deep cloneable is cloned too
+ // deep clone additional data properties
+ // fixme - BUT the values are... only set in EntityRepository to non-deepclonable stuff?!
foreach (var key in clone.AdditionalData.Keys.ToArray())
{
if (clone.AdditionalData[key] is IDeepCloneable deepCloneable)
clone.AdditionalData[key] = deepCloneable.DeepClone();
}
- // re-enable tracking
- clone.ResetDirtyProperties(false); // why? were not tracking
+ // enable tracking
clone.EnableChangeTracking();
+
return clone;
}
+ // fixme
+ // wtf? is clone.AdditionalData at least shallow cloned?
+ // and, considering the only thing we put in EntityProperty are strings,
+ // what's the point of EntityProperty ???
+
///
/// A struction that can be contained in the additional data of an UmbracoEntity representing
/// a user defined property
diff --git a/src/Umbraco.Core/Models/UmbracoObjectTypes.cs b/src/Umbraco.Core/Models/UmbracoObjectTypes.cs
index cf75d3c7cd..c58f69d223 100644
--- a/src/Umbraco.Core/Models/UmbracoObjectTypes.cs
+++ b/src/Umbraco.Core/Models/UmbracoObjectTypes.cs
@@ -122,7 +122,7 @@ namespace Umbraco.Core.Models
///
/// Data Type
///
- [UmbracoObjectType(Constants.ObjectTypes.Strings.DataType, typeof(IDataTypeDefinition))]
+ [UmbracoObjectType(Constants.ObjectTypes.Strings.DataType, typeof(IDataType))]
[FriendlyName("Data Type")]
[UmbracoUdiType(Constants.UdiEntityType.DataType)]
DataType,
diff --git a/src/Umbraco.Core/Packaging/Models/UninstallationSummary.cs b/src/Umbraco.Core/Packaging/Models/UninstallationSummary.cs
index 6f28ba567e..1c31283ee8 100644
--- a/src/Umbraco.Core/Packaging/Models/UninstallationSummary.cs
+++ b/src/Umbraco.Core/Packaging/Models/UninstallationSummary.cs
@@ -11,7 +11,7 @@ namespace Umbraco.Core.Packaging.Models
public class UninstallationSummary
{
public MetaData MetaData { get; set; }
- public IEnumerable DataTypesUninstalled { get; set; }
+ public IEnumerable DataTypesUninstalled { get; set; }
public IEnumerable LanguagesUninstalled { get; set; }
public IEnumerable DictionaryItemsUninstalled { get; set; }
public IEnumerable MacrosUninstalled { get; set; }
@@ -29,7 +29,7 @@ namespace Umbraco.Core.Packaging.Models
{
summary.ContentUninstalled = new List();
summary.ContentTypesUninstalled = new List();
- summary.DataTypesUninstalled = new List();
+ summary.DataTypesUninstalled = new List();
summary.DictionaryItemsUninstalled = new List();
summary.FilesUninstalled = new List();
summary.LanguagesUninstalled = new List();
diff --git a/src/Umbraco.Core/Packaging/PackageInstallation.cs b/src/Umbraco.Core/Packaging/PackageInstallation.cs
index 48f303d31d..9a62fe8b9a 100644
--- a/src/Umbraco.Core/Packaging/PackageInstallation.cs
+++ b/src/Umbraco.Core/Packaging/PackageInstallation.cs
@@ -147,7 +147,7 @@ namespace Umbraco.Core.Packaging
try
{
- var dataTypeDefinitions = EmptyEnumerableIfNull(dataTypes) ?? InstallDataTypes(dataTypes, userId);
+ var dataTypeDefinitions = EmptyEnumerableIfNull(dataTypes) ?? InstallDataTypes(dataTypes, userId);
installationSummary.DataTypesInstalled = dataTypeDefinitions;
var languagesInstalled = EmptyEnumerableIfNull(languages) ?? InstallLanguages(languages, userId);
@@ -412,7 +412,7 @@ namespace Umbraco.Core.Packaging
return _packagingService.ImportLanguages(languageElement, userId);
}
- private IEnumerable InstallDataTypes(XElement dataTypeElements, int userId = 0)
+ private IEnumerable InstallDataTypes(XElement dataTypeElements, int userId = 0)
{
if (string.Equals(Constants.Packaging.DataTypesNodeName, dataTypeElements.Name.LocalName) == false)
{
diff --git a/src/Umbraco.Core/Persistence/Factories/DataTypeDefinitionFactory.cs b/src/Umbraco.Core/Persistence/Factories/DataTypeFactory.cs
similarity index 86%
rename from src/Umbraco.Core/Persistence/Factories/DataTypeDefinitionFactory.cs
rename to src/Umbraco.Core/Persistence/Factories/DataTypeFactory.cs
index efe6fa2a3c..4e174f6476 100644
--- a/src/Umbraco.Core/Persistence/Factories/DataTypeDefinitionFactory.cs
+++ b/src/Umbraco.Core/Persistence/Factories/DataTypeFactory.cs
@@ -1,97 +1,97 @@
-using System;
-using System.Globalization;
-using Umbraco.Core.Models;
-using Umbraco.Core.Persistence.Dtos;
-
-namespace Umbraco.Core.Persistence.Factories
-{
- internal class DataTypeDefinitionFactory
- {
- private readonly Guid _nodeObjectTypeId;
- private int _primaryKey;
-
- public DataTypeDefinitionFactory(Guid nodeObjectTypeId)
- {
- _nodeObjectTypeId = nodeObjectTypeId;
- }
-
- #region Implementation of IEntityFactory
-
- public IDataTypeDefinition BuildEntity(DataTypeDto dto)
- {
- var dataTypeDefinition = new DataTypeDefinition(dto.PropertyEditorAlias);
-
-
- try
- {
- dataTypeDefinition.DisableChangeTracking();
-
- dataTypeDefinition.CreateDate = dto.NodeDto.CreateDate;
- dataTypeDefinition.DatabaseType = dto.DbType.EnumParse(true);
- dataTypeDefinition.Id = dto.DataTypeId;
- dataTypeDefinition.Key = dto.NodeDto.UniqueId;
- dataTypeDefinition.Level = dto.NodeDto.Level;
- dataTypeDefinition.UpdateDate = dto.NodeDto.CreateDate;
- dataTypeDefinition.Name = dto.NodeDto.Text;
- dataTypeDefinition.ParentId = dto.NodeDto.ParentId;
- dataTypeDefinition.Path = dto.NodeDto.Path;
- dataTypeDefinition.SortOrder = dto.NodeDto.SortOrder;
- dataTypeDefinition.Trashed = dto.NodeDto.Trashed;
- dataTypeDefinition.CreatorId = dto.NodeDto.UserId.Value;
-
- // reset dirty initial properties (U4-1946)
- dataTypeDefinition.ResetDirtyProperties(false);
- return dataTypeDefinition;
- }
- finally
- {
- dataTypeDefinition.EnableChangeTracking();
- }
- }
-
- public DataTypeDto BuildDto(IDataTypeDefinition entity)
- {
- var dataTypeDto = new DataTypeDto
- {
- PropertyEditorAlias = entity.PropertyEditorAlias,
- DataTypeId = entity.Id,
- DbType = entity.DatabaseType.ToString(),
- NodeDto = BuildNodeDto(entity)
- };
-
- if (_primaryKey > 0)
- {
- dataTypeDto.PrimaryKey = _primaryKey;
- }
-
- return dataTypeDto;
- }
-
- #endregion
-
- public void SetPrimaryKey(int primaryKey)
- {
- _primaryKey = primaryKey;
- }
-
- private NodeDto BuildNodeDto(IDataTypeDefinition entity)
- {
- var nodeDto = new NodeDto
- {
- CreateDate = entity.CreateDate,
- NodeId = entity.Id,
- Level = short.Parse(entity.Level.ToString(CultureInfo.InvariantCulture)),
- NodeObjectType = _nodeObjectTypeId,
- ParentId = entity.ParentId,
- Path = entity.Path,
- SortOrder = entity.SortOrder,
- Text = entity.Name,
- Trashed = entity.Trashed,
- UniqueId = entity.Key,
- UserId = entity.CreatorId
- };
-
- return nodeDto;
- }
- }
-}
+using System;
+using System.Globalization;
+using Umbraco.Core.Models;
+using Umbraco.Core.Persistence.Dtos;
+
+namespace Umbraco.Core.Persistence.Factories
+{
+ internal class DataTypeFactory
+ {
+ private readonly Guid _nodeObjectTypeId;
+ private int _primaryKey;
+
+ public DataTypeFactory(Guid nodeObjectTypeId)
+ {
+ _nodeObjectTypeId = nodeObjectTypeId;
+ }
+
+ #region Implementation of IEntityFactory
+
+ public IDataType BuildEntity(DataTypeDto dto)
+ {
+ var dataTypeDefinition = new DataType(dto.PropertyEditorAlias);
+
+
+ try
+ {
+ dataTypeDefinition.DisableChangeTracking();
+
+ dataTypeDefinition.CreateDate = dto.NodeDto.CreateDate;
+ dataTypeDefinition.DatabaseType = dto.DbType.EnumParse(true);
+ dataTypeDefinition.Id = dto.DataTypeId;
+ dataTypeDefinition.Key = dto.NodeDto.UniqueId;
+ dataTypeDefinition.Level = dto.NodeDto.Level;
+ dataTypeDefinition.UpdateDate = dto.NodeDto.CreateDate;
+ dataTypeDefinition.Name = dto.NodeDto.Text;
+ dataTypeDefinition.ParentId = dto.NodeDto.ParentId;
+ dataTypeDefinition.Path = dto.NodeDto.Path;
+ dataTypeDefinition.SortOrder = dto.NodeDto.SortOrder;
+ dataTypeDefinition.Trashed = dto.NodeDto.Trashed;
+ dataTypeDefinition.CreatorId = dto.NodeDto.UserId.Value;
+
+ // reset dirty initial properties (U4-1946)
+ dataTypeDefinition.ResetDirtyProperties(false);
+ return dataTypeDefinition;
+ }
+ finally
+ {
+ dataTypeDefinition.EnableChangeTracking();
+ }
+ }
+
+ public DataTypeDto BuildDto(IDataType entity)
+ {
+ var dataTypeDto = new DataTypeDto
+ {
+ PropertyEditorAlias = entity.EditorAlias,
+ DataTypeId = entity.Id,
+ DbType = entity.DatabaseType.ToString(),
+ NodeDto = BuildNodeDto(entity)
+ };
+
+ if (_primaryKey > 0)
+ {
+ dataTypeDto.PrimaryKey = _primaryKey;
+ }
+
+ return dataTypeDto;
+ }
+
+ #endregion
+
+ public void SetPrimaryKey(int primaryKey)
+ {
+ _primaryKey = primaryKey;
+ }
+
+ private NodeDto BuildNodeDto(IDataType entity)
+ {
+ var nodeDto = new NodeDto
+ {
+ CreateDate = entity.CreateDate,
+ NodeId = entity.Id,
+ Level = short.Parse(entity.Level.ToString(CultureInfo.InvariantCulture)),
+ NodeObjectType = _nodeObjectTypeId,
+ ParentId = entity.ParentId,
+ Path = entity.Path,
+ SortOrder = entity.SortOrder,
+ Text = entity.Name,
+ Trashed = entity.Trashed,
+ UniqueId = entity.Key,
+ UserId = entity.CreatorId
+ };
+
+ return nodeDto;
+ }
+ }
+}
diff --git a/src/Umbraco.Core/Persistence/Mappers/DataTypeDefinitionMapper.cs b/src/Umbraco.Core/Persistence/Mappers/DataTypeDefinitionMapper.cs
deleted file mode 100644
index 85466f65b0..0000000000
--- a/src/Umbraco.Core/Persistence/Mappers/DataTypeDefinitionMapper.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using System.Collections.Concurrent;
-using Umbraco.Core.Models;
-using Umbraco.Core.Persistence.Dtos;
-
-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(DataTypeDefinition))]
- [MapperFor(typeof(IDataTypeDefinition))]
- public sealed class DataTypeDefinitionMapper : BaseMapper
- {
- private static readonly ConcurrentDictionary PropertyInfoCacheInstance = new ConcurrentDictionary();
-
- internal override ConcurrentDictionary PropertyInfoCache => PropertyInfoCacheInstance;
-
- protected override void BuildMap()
- {
- CacheMap(src => src.Id, dto => dto.NodeId);
- CacheMap(src => src.CreateDate, dto => dto.CreateDate);
- CacheMap(src => src.Level, dto => dto.Level);
- CacheMap(src => src.ParentId, dto => dto.ParentId);
- CacheMap(src => src.Path, dto => dto.Path);
- CacheMap(src => src.SortOrder, dto => dto.SortOrder);
- CacheMap(src => src.Name, dto => dto.Text);
- CacheMap(src => src.Trashed, dto => dto.Trashed);
- CacheMap(src => src.Key, dto => dto.UniqueId);
- CacheMap(src => src.CreatorId, dto => dto.UserId);
- CacheMap(src => src.PropertyEditorAlias, dto => dto.PropertyEditorAlias);
- CacheMap(src => src.DatabaseType, dto => dto.DbType);
-
- }
- }
-}
diff --git a/src/Umbraco.Core/Persistence/Mappers/DataTypeMapper.cs b/src/Umbraco.Core/Persistence/Mappers/DataTypeMapper.cs
new file mode 100644
index 0000000000..3213095f6c
--- /dev/null
+++ b/src/Umbraco.Core/Persistence/Mappers/DataTypeMapper.cs
@@ -0,0 +1,36 @@
+using System.Collections.Concurrent;
+using Umbraco.Core.Models;
+using Umbraco.Core.Persistence.Dtos;
+
+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(DataType))]
+ [MapperFor(typeof(IDataType))]
+ public sealed class DataTypeMapper : BaseMapper
+ {
+ private static readonly ConcurrentDictionary PropertyInfoCacheInstance = new ConcurrentDictionary();
+
+ internal override ConcurrentDictionary PropertyInfoCache => PropertyInfoCacheInstance;
+
+ protected override void BuildMap()
+ {
+ CacheMap(src => src.Id, dto => dto.NodeId);
+ CacheMap(src => src.CreateDate, dto => dto.CreateDate);
+ CacheMap(src => src.Level, dto => dto.Level);
+ CacheMap(src => src.ParentId, dto => dto.ParentId);
+ CacheMap(src => src.Path, dto => dto.Path);
+ CacheMap(src => src.SortOrder, dto => dto.SortOrder);
+ CacheMap(src => src.Name, dto => dto.Text);
+ CacheMap(src => src.Trashed, dto => dto.Trashed);
+ CacheMap(src => src.Key, dto => dto.UniqueId);
+ CacheMap(src => src.CreatorId, dto => dto.UserId);
+ CacheMap(src => src.EditorAlias, dto => dto.PropertyEditorAlias);
+ CacheMap(src => src.DatabaseType, dto => dto.DbType);
+
+ }
+ }
+}
diff --git a/src/Umbraco.Core/Persistence/Mappers/MapperCollectionBuilder.cs b/src/Umbraco.Core/Persistence/Mappers/MapperCollectionBuilder.cs
index c742624695..6c79254a0f 100644
--- a/src/Umbraco.Core/Persistence/Mappers/MapperCollectionBuilder.cs
+++ b/src/Umbraco.Core/Persistence/Mappers/MapperCollectionBuilder.cs
@@ -30,7 +30,7 @@ namespace Umbraco.Core.Persistence.Mappers
Add();
Add();
Add();
- Add();
+ Add();
Add();
Add();
Add();
diff --git a/src/Umbraco.Core/Persistence/Repositories/IDataTypeDefinitionRepository.cs b/src/Umbraco.Core/Persistence/Repositories/IDataTypeRepository.cs
similarity index 53%
rename from src/Umbraco.Core/Persistence/Repositories/IDataTypeDefinitionRepository.cs
rename to src/Umbraco.Core/Persistence/Repositories/IDataTypeRepository.cs
index 20fd586d45..5e1aed9ba0 100644
--- a/src/Umbraco.Core/Persistence/Repositories/IDataTypeDefinitionRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/IDataTypeRepository.cs
@@ -4,14 +4,14 @@ using Umbraco.Core.Models;
namespace Umbraco.Core.Persistence.Repositories
{
- public interface IDataTypeDefinitionRepository : IReadWriteQueryRepository
+ public interface IDataTypeRepository : IReadWriteQueryRepository
{
PreValueCollection GetPreValuesCollectionByDataTypeId(int dataTypeId);
string GetPreValueAsString(int preValueId);
- void AddOrUpdatePreValues(IDataTypeDefinition dataType, IDictionary values);
+ void AddOrUpdatePreValues(IDataType dataType, IDictionary values);
void AddOrUpdatePreValues(int dataTypeId, IDictionary values);
- IEnumerable> Move(IDataTypeDefinition toMove, EntityContainer container);
+ IEnumerable> Move(IDataType toMove, EntityContainer container);
}
}
diff --git a/src/Umbraco.Core/Persistence/Repositories/IEntityRepository.cs b/src/Umbraco.Core/Persistence/Repositories/IEntityRepository.cs
index 9e9f0c73bd..3586bf8e27 100644
--- a/src/Umbraco.Core/Persistence/Repositories/IEntityRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/IEntityRepository.cs
@@ -21,8 +21,8 @@ namespace Umbraco.Core.Persistence.Repositories
UmbracoObjectTypes GetObjectType(int id);
UmbracoObjectTypes GetObjectType(Guid key);
- IEnumerable GetAllPaths(Guid objectType, params int[] ids);
- IEnumerable GetAllPaths(Guid objectType, params Guid[] keys);
+ IEnumerable GetAllPaths(Guid objectType, params int[] ids);
+ IEnumerable GetAllPaths(Guid objectType, params Guid[] keys);
///
/// Gets paged results
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/ContentTypeRepositoryBase.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/ContentTypeRepositoryBase.cs
index 72e1be760d..354a431d89 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/ContentTypeRepositoryBase.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/ContentTypeRepositoryBase.cs
@@ -698,7 +698,7 @@ AND umbracoNode.id <> @id",
}
// reset dirty initial properties (U4-1946)
- ((Entity)contentType).ResetDirtyProperties(false);
+ ((EntityBase)contentType).ResetDirtyProperties(false);
}
}
}
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/DataTypeDefinitionRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/DataTypeRepository.cs
similarity index 91%
rename from src/Umbraco.Core/Persistence/Repositories/Implement/DataTypeDefinitionRepository.cs
rename to src/Umbraco.Core/Persistence/Repositories/Implement/DataTypeRepository.cs
index fcc14f1059..9159eaacf9 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/DataTypeDefinitionRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/DataTypeRepository.cs
@@ -19,13 +19,13 @@ using Umbraco.Core.Services;
namespace Umbraco.Core.Persistence.Repositories.Implement
{
///
- /// Represents a repository for doing CRUD operations for
+ /// Represents a repository for doing CRUD operations for
///
- internal class DataTypeDefinitionRepository : NPocoRepositoryBase, IDataTypeDefinitionRepository
+ internal class DataTypeRepository : NPocoRepositoryBase, IDataTypeRepository
{
private readonly DataTypePreValueRepository _preValRepository;
- public DataTypeDefinitionRepository(IScopeAccessor scopeAccessor, CacheHelper cache, ILogger logger)
+ public DataTypeRepository(IScopeAccessor scopeAccessor, CacheHelper cache, ILogger logger)
: base(scopeAccessor, cache, logger)
{
_preValRepository = new DataTypePreValueRepository(scopeAccessor, CacheHelper.NoCache, logger);
@@ -33,14 +33,14 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
#region Overrides of RepositoryBase
- protected override IDataTypeDefinition PerformGet(int id)
+ protected override IDataType PerformGet(int id)
{
return GetMany(new[] { id }).FirstOrDefault();
}
- protected override IEnumerable PerformGetAll(params int[] ids)
+ protected override IEnumerable PerformGetAll(params int[] ids)
{
- var factory = new DataTypeDefinitionFactory(NodeObjectTypeId);
+ var factory = new DataTypeFactory(NodeObjectTypeId);
var dataTypeSql = GetBaseQuery(false);
if (ids.Any())
@@ -56,12 +56,12 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
return dtos.Select(factory.BuildEntity).ToArray();
}
- protected override IEnumerable PerformGetByQuery(IQuery query)
+ protected override IEnumerable PerformGetByQuery(IQuery query)
{
- var factory = new DataTypeDefinitionFactory(NodeObjectTypeId);
+ var factory = new DataTypeFactory(NodeObjectTypeId);
var sqlClause = GetBaseQuery(false);
- var translator = new SqlTranslator(sqlClause, query);
+ var translator = new SqlTranslator(sqlClause, query);
var sql = translator.Translate();
var dtos = Database.Fetch(sql);
@@ -105,9 +105,9 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
#region Unit of Work Implementation
- protected override void PersistNewItem(IDataTypeDefinition entity)
+ protected override void PersistNewItem(IDataType entity)
{
- ((DataTypeDefinition)entity).AddingEntity();
+ ((DataType)entity).AddingEntity();
//ensure a datatype has a unique name before creating it
entity.Name = EnsureUniqueNodeName(entity.Name);
@@ -122,7 +122,7 @@ WHERE umbracoNode." + SqlSyntax.GetQuotedColumnName("text") + "= @name", new { n
throw new DuplicateNameException("A data type with the name " + entity.Name + " already exists");
}
- var factory = new DataTypeDefinitionFactory(NodeObjectTypeId);
+ var factory = new DataTypeFactory(NodeObjectTypeId);
var dto = factory.BuildDto(entity);
//Logic for setting Path, Level and SortOrder
@@ -155,7 +155,7 @@ WHERE umbracoNode." + SqlSyntax.GetQuotedColumnName("text") + "= @name", new { n
entity.ResetDirtyProperties();
}
- protected override void PersistUpdatedItem(IDataTypeDefinition entity)
+ protected override void PersistUpdatedItem(IDataType entity)
{
entity.Name = EnsureUniqueNodeName(entity.Name, entity.Id);
@@ -172,7 +172,7 @@ AND umbracoNode.id <> @id",
}
//Updates Modified date
- ((DataTypeDefinition)entity).UpdatingEntity();
+ ((DataType)entity).UpdatingEntity();
//Look up parent to get and set the correct Path if ParentId has changed
if (entity.IsPropertyDirty("ParentId"))
@@ -187,7 +187,7 @@ AND umbracoNode.id <> @id",
entity.SortOrder = maxSortOrder + 1;
}
- var factory = new DataTypeDefinitionFactory(NodeObjectTypeId);
+ var factory = new DataTypeFactory(NodeObjectTypeId);
//Look up DataTypeDefinition entry to get Primary for updating the DTO
var dataTypeDto = Database.SingleOrDefault("WHERE nodeId = @Id", new { Id = entity.Id });
factory.SetPrimaryKey(dataTypeDto.PrimaryKey);
@@ -205,7 +205,7 @@ AND umbracoNode.id <> @id",
entity.ResetDirtyProperties();
}
- protected override void PersistDeletedItem(IDataTypeDefinition entity)
+ protected override void PersistDeletedItem(IDataType entity)
{
//Remove Notifications
Database.Delete("WHERE nodeId = @Id", new { Id = entity.Id });
@@ -234,7 +234,7 @@ AND umbracoNode.id <> @id",
//Delete (base) node data
Database.Delete("WHERE uniqueID = @Id", new { Id = entity.Key });
- entity.DeletedDate = DateTime.Now;
+ entity.DeleteDate = DateTime.Now;
}
#endregion
@@ -274,7 +274,7 @@ AND umbracoNode.id <> @id",
AddOrUpdatePreValues(dtd, values);
}
- public IEnumerable> Move(IDataTypeDefinition toMove, EntityContainer container)
+ public IEnumerable> Move(IDataType toMove, EntityContainer container)
{
var parentId = -1;
if (container != null)
@@ -288,9 +288,9 @@ AND umbracoNode.id <> @id",
}
//used to track all the moved entities to be given to the event
- var moveInfo = new List>
+ var moveInfo = new List>
{
- new MoveEventInfo(toMove, toMove.Path, parentId)
+ new MoveEventInfo(toMove, toMove.Path, parentId)
};
var origPath = toMove.Path;
@@ -305,12 +305,12 @@ AND umbracoNode.id <> @id",
Save(toMove);
//update all descendants from the original path, update in order of level
- var descendants = Get(Query().Where(type => type.Path.StartsWith(origPath + ",")));
+ var descendants = Get(Query().Where(type => type.Path.StartsWith(origPath + ",")));
var lastParent = toMove;
foreach (var descendant in descendants.OrderBy(x => x.Level))
{
- moveInfo.Add(new MoveEventInfo(descendant, descendant.Path, descendant.ParentId));
+ moveInfo.Add(new MoveEventInfo(descendant, descendant.Path, descendant.ParentId));
descendant.ParentId = lastParent.Id;
descendant.Path = string.Concat(lastParent.Path, ",", descendant.Id);
@@ -322,7 +322,7 @@ AND umbracoNode.id <> @id",
return moveInfo;
}
- public void AddOrUpdatePreValues(IDataTypeDefinition dataType, IDictionary values)
+ public void AddOrUpdatePreValues(IDataType dataType, IDictionary values)
{
var currentVals = new DataTypePreValueDto[] { };
if (dataType.HasIdentity)
@@ -422,11 +422,11 @@ AND umbracoNode.id <> @id",
///
/// Private class to handle pre-value crud based on units of work with transactions
///
- private class PreValueEntity : Entity, IAggregateRoot
+ private class PreValueEntity : EntityBase
{
public string Value { get; set; }
public string Alias { get; set; }
- public IDataTypeDefinition DataType { get; set; }
+ public IDataType DataType { get; set; }
public int SortOrder { get; set; }
}
@@ -480,7 +480,7 @@ AND umbracoNode.id <> @id",
{
Database.Execute("DELETE FROM cmsDataTypePreValues WHERE id=@Id", new { Id = entity.Id });
- entity.DeletedDate = DateTime.Now;
+ entity.DeleteDate = DateTime.Now;
}
protected override void PersistNewItem(PreValueEntity entity)
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/DictionaryRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/DictionaryRepository.cs
index 64020a6dce..856fe6af31 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/DictionaryRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/DictionaryRepository.cs
@@ -51,7 +51,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
var entity = ConvertFromDto(dto);
// reset dirty initial properties (U4-1946)
- ((Entity)entity).ResetDirtyProperties(false);
+ ((EntityBase)entity).ResetDirtyProperties(false);
return entity;
}
@@ -150,7 +150,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
protected override void PersistUpdatedItem(IDictionaryItem entity)
{
- ((Entity)entity).UpdatingEntity();
+ ((EntityBase)entity).UpdatingEntity();
foreach (var translation in entity.Translations)
translation.Value = translation.Value.ToValidXmlString();
@@ -193,7 +193,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
IsolatedCache.ClearCacheItem(RepositoryCacheKeys.GetKey(entity.ItemKey));
IsolatedCache.ClearCacheItem(RepositoryCacheKeys.GetKey(entity.Key));
- entity.DeletedDate = DateTime.Now;
+ entity.DeleteDate = DateTime.Now;
}
private void RecursiveDelete(Guid parentId)
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/EntityRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/EntityRepository.cs
index 6205739316..6631f79859 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/EntityRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/EntityRepository.cs
@@ -213,25 +213,25 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
return entities;
}
- public virtual IEnumerable GetAllPaths(Guid objectType, params int[] ids)
+ public virtual IEnumerable GetAllPaths(Guid objectType, params int[] ids)
{
return ids.Any()
? PerformGetAllPaths(objectType, sql => sql.WhereIn(x => x.NodeId, ids.Distinct()))
: PerformGetAllPaths(objectType);
}
- public virtual IEnumerable GetAllPaths(Guid objectType, params Guid[] keys)
+ public virtual IEnumerable GetAllPaths(Guid objectType, params Guid[] keys)
{
return keys.Any()
? PerformGetAllPaths(objectType, sql => sql.WhereIn(x => x.UniqueId, keys.Distinct()))
: PerformGetAllPaths(objectType);
}
- private IEnumerable PerformGetAllPaths(Guid objectType, Action> filter = null)
+ private IEnumerable PerformGetAllPaths(Guid objectType, Action> filter = null)
{
var sql = Sql().Select(x => x.NodeId, x => x.Path).From().Where(x => x.NodeObjectType == objectType);
filter?.Invoke(sql);
- return Database.Fetch(sql);
+ return Database.Fetch(sql);
}
public virtual IEnumerable GetByQuery(IQuery query)
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/ExternalLoginRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/ExternalLoginRepository.cs
index d5d08402af..9d31c06d49 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/ExternalLoginRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/ExternalLoginRepository.cs
@@ -89,7 +89,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
foreach (var entity in dtos.Select(factory.BuildEntity))
{
// reset dirty initial properties (U4-1946)
- ((TracksChangesEntityBase)entity).ResetDirtyProperties(false);
+ ((BeingDirtyBase)entity).ResetDirtyProperties(false);
yield return entity;
}
@@ -141,7 +141,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
protected override void PersistNewItem(IIdentityUserLogin entity)
{
- ((Entity)entity).AddingEntity();
+ ((EntityBase)entity).AddingEntity();
var factory = new ExternalLoginFactory();
var dto = factory.BuildDto(entity);
@@ -154,7 +154,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
protected override void PersistUpdatedItem(IIdentityUserLogin entity)
{
- ((Entity)entity).UpdatingEntity();
+ ((EntityBase)entity).UpdatingEntity();
var factory = new ExternalLoginFactory();
var dto = factory.BuildDto(entity);
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/LanguageRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/LanguageRepository.cs
index b593f6ea35..ffcf771a39 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/LanguageRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/LanguageRepository.cs
@@ -105,7 +105,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
protected override void PersistNewItem(ILanguage entity)
{
- ((Entity)entity).AddingEntity();
+ ((EntityBase)entity).AddingEntity();
var factory = new LanguageFactory();
var dto = factory.BuildDto(entity);
@@ -118,7 +118,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
protected override void PersistUpdatedItem(ILanguage entity)
{
- ((Entity)entity).UpdatingEntity();
+ ((EntityBase)entity).UpdatingEntity();
var factory = new LanguageFactory();
var dto = factory.BuildDto(entity);
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/MacroRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/MacroRepository.cs
index 3167385275..4583fdaef3 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/MacroRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/MacroRepository.cs
@@ -45,7 +45,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
var entity = factory.BuildEntity(macroDto);
// reset dirty initial properties (U4-1946)
- ((TracksChangesEntityBase)entity).ResetDirtyProperties(false);
+ ((BeingDirtyBase)entity).ResetDirtyProperties(false);
return entity;
}
@@ -83,7 +83,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
foreach (var entity in dtos.Select(factory.BuildEntity))
{
// reset dirty initial properties (U4-1946)
- ((TracksChangesEntityBase)entity).ResetDirtyProperties(false);
+ ((BeingDirtyBase)entity).ResetDirtyProperties(false);
yield return entity;
}
@@ -133,7 +133,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
protected override void PersistNewItem(IMacro entity)
{
- ((Entity)entity).AddingEntity();
+ ((EntityBase)entity).AddingEntity();
var factory = new MacroFactory();
var dto = factory.BuildDto(entity);
@@ -154,7 +154,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
protected override void PersistUpdatedItem(IMacro entity)
{
- ((Entity)entity).UpdatingEntity();
+ ((EntityBase)entity).UpdatingEntity();
var factory = new MacroFactory();
var dto = factory.BuildDto(entity);
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/NPocoRepositoryBase.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/NPocoRepositoryBase.cs
index c5cb65a9b6..d34651dbe2 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/NPocoRepositoryBase.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/NPocoRepositoryBase.cs
@@ -16,7 +16,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
///
///
internal abstract class NPocoRepositoryBase : RepositoryBase
- where TEntity : class, IAggregateRoot
+ where TEntity : class, IEntity
{
///
/// Initializes a new instance of the class.
@@ -75,7 +75,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
{
Database.Execute(delete, new { id = GetEntityId(entity) });
}
- entity.DeletedDate = DateTime.Now;
+ entity.DeleteDate = DateTime.Now;
}
}
}
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/PermissionRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/PermissionRepository.cs
index 5d50d03d45..8421678996 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/PermissionRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/PermissionRepository.cs
@@ -23,7 +23,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
/// like the normal repository pattern but the standard repository Get commands don't apply and will throw
///
internal class PermissionRepository : NPocoRepositoryBase
- where TEntity : class, IAggregateRoot
+ where TEntity : class, IEntity
{
public PermissionRepository(IScopeAccessor scopeAccessor, CacheHelper cache, ILogger logger)
: base(scopeAccessor, cache, logger)
@@ -305,8 +305,8 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
///
protected override void PersistUpdatedItem(ContentPermissionSet entity)
{
- var asAggregateRoot = (IAggregateRoot)entity;
- if (asAggregateRoot.HasIdentity == false)
+ var asIEntity = (IEntity) entity;
+ if (asIEntity.HasIdentity == false)
{
throw new InvalidOperationException("Cannot create permissions for an entity without an Id");
}
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/RelationRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/RelationRepository.cs
index 512da44089..2a7955fdfe 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/RelationRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/RelationRepository.cs
@@ -88,7 +88,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
var entity = factory.BuildEntity(dto);
// reset dirty initial properties (U4-1946)
- ((TracksChangesEntityBase)entity).ResetDirtyProperties(false);
+ ((BeingDirtyBase)entity).ResetDirtyProperties(false);
return entity;
}
@@ -136,7 +136,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
protected override void PersistNewItem(IRelation entity)
{
- ((Entity)entity).AddingEntity();
+ ((EntityBase)entity).AddingEntity();
var factory = new RelationFactory(entity.RelationType);
var dto = factory.BuildDto(entity);
@@ -149,7 +149,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
protected override void PersistUpdatedItem(IRelation entity)
{
- ((Entity)entity).UpdatingEntity();
+ ((EntityBase)entity).UpdatingEntity();
var factory = new RelationFactory(entity.RelationType);
var dto = factory.BuildDto(entity);
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/RelationTypeRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/RelationTypeRepository.cs
index a247ec11c8..39402a5d5b 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/RelationTypeRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/RelationTypeRepository.cs
@@ -84,7 +84,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
var entity = factory.BuildEntity(dto);
// reset dirty initial properties (U4-1946)
- ((TracksChangesEntityBase) entity).ResetDirtyProperties(false);
+ ((BeingDirtyBase) entity).ResetDirtyProperties(false);
return entity;
}
@@ -133,7 +133,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
protected override void PersistNewItem(IRelationType entity)
{
- ((Entity)entity).AddingEntity();
+ ((EntityBase)entity).AddingEntity();
var factory = new RelationTypeFactory();
var dto = factory.BuildDto(entity);
@@ -146,7 +146,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
protected override void PersistUpdatedItem(IRelationType entity)
{
- ((Entity)entity).UpdatingEntity();
+ ((EntityBase)entity).UpdatingEntity();
var factory = new RelationTypeFactory();
var dto = factory.BuildDto(entity);
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/RepositoryBaseOfTIdTEntity.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/RepositoryBaseOfTIdTEntity.cs
index b9e9dc182a..3fbcab7b99 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/RepositoryBaseOfTIdTEntity.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/RepositoryBaseOfTIdTEntity.cs
@@ -15,7 +15,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
/// The type of the entity managed by this repository.
/// The type of the entity's unique identifier.
internal abstract class RepositoryBase : IReadWriteQueryRepository
- where TEntity : class, IAggregateRoot
+ where TEntity : class, IEntity
{
private IRepositoryCachePolicy _cachePolicy;
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/SimpleGetRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/SimpleGetRepository.cs
index d4ab97030a..568ac65d54 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/SimpleGetRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/SimpleGetRepository.cs
@@ -15,7 +15,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
/// Simple abstract ReadOnly repository used to simply have PerformGet and PeformGetAll with an underlying cache
///
internal abstract class SimpleGetRepository : NPocoRepositoryBase
- where TEntity : class, IAggregateRoot
+ where TEntity : class, IEntity
where TDto: class
{
protected SimpleGetRepository(IScopeAccessor scopeAccessor, CacheHelper cache, ILogger logger)
@@ -42,7 +42,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
var entity = ConvertToEntity(dto);
- if (entity is Entity dirtyEntity)
+ if (entity is EntityBase dirtyEntity)
{
// reset dirty initial properties (U4-1946)
dirtyEntity.ResetDirtyProperties(false);
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/TagRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/TagRepository.cs
index 05fa6d8f4d..cb9ba006bb 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/TagRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/TagRepository.cs
@@ -32,7 +32,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
var entity = factory.BuildEntity(tagDto);
// reset dirty initial properties (U4-1946)
- ((TracksChangesEntityBase)entity).ResetDirtyProperties(false);
+ ((BeingDirtyBase)entity).ResetDirtyProperties(false);
return entity;
}
@@ -69,7 +69,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
foreach (var entity in dtos.Select(factory.BuildEntity))
{
// reset dirty initial properties (U4-1946)
- ((TracksChangesEntityBase)entity).ResetDirtyProperties(false);
+ ((BeingDirtyBase)entity).ResetDirtyProperties(false);
yield return entity;
}
}
@@ -119,7 +119,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
protected override void PersistNewItem(ITag entity)
{
- ((Entity)entity).AddingEntity();
+ ((EntityBase)entity).AddingEntity();
var factory = new TagFactory();
var dto = factory.BuildDto(entity);
@@ -132,7 +132,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
protected override void PersistUpdatedItem(ITag entity)
{
- ((Entity)entity).UpdatingEntity();
+ ((EntityBase)entity).UpdatingEntity();
var factory = new TagFactory();
var dto = factory.BuildDto(entity);
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/TemplateRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/TemplateRepository.cs
index 04192ac169..ced61658e4 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/TemplateRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/TemplateRepository.cs
@@ -317,7 +317,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
_masterpagesFileSystem.DeleteFile(masterpageName);
}
- entity.DeletedDate = DateTime.Now;
+ entity.DeleteDate = DateTime.Now;
}
#endregion
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/UserGroupRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/UserGroupRepository.cs
index 92a5bbdd44..877b26a27b 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/UserGroupRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/UserGroupRepository.cs
@@ -335,7 +335,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
///
/// used to persist a user group with associated users at once
///
- private class UserGroupWithUsers : Entity, IAggregateRoot
+ private class UserGroupWithUsers : EntityBase
{
public UserGroupWithUsers(IUserGroup userGroup, int[] userIds)
{
@@ -343,11 +343,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
UserIds = userIds;
}
- public override bool HasIdentity
- {
- get => UserGroup.HasIdentity;
- protected set => throw new NotSupportedException();
- }
+ public override bool HasIdentity => UserGroup.HasIdentity;
public IUserGroup UserGroup { get; }
public int[] UserIds { get; }
diff --git a/src/Umbraco.Core/PropertyEditors/PropertyEditor.cs b/src/Umbraco.Core/PropertyEditors/PropertyEditor.cs
index e77b86d86a..a7c2b92223 100644
--- a/src/Umbraco.Core/PropertyEditors/PropertyEditor.cs
+++ b/src/Umbraco.Core/PropertyEditors/PropertyEditor.cs
@@ -10,45 +10,45 @@ using Umbraco.Core.Models;
namespace Umbraco.Core.PropertyEditors
{
///
- /// Basic definition of a property editor
+ /// Provides a base class for property editors.
///
///
- /// The Json serialization attributes are required for manifest property editors to work
+ /// Editors can be deserialized from manifests, which is why the Json serialization
+ /// attributes are required, and the properties require an internal setter.
///
- [DebuggerDisplay("{DebuggerDisplay(),nq}")]
+ [DebuggerDisplay("{" + nameof(DebuggerDisplay) + "(),nq}")]
public class PropertyEditor : IParameterEditor
{
- ///
- /// Exposes a logger
- ///
- protected ILogger Logger { get; }
-
private readonly PropertyEditorAttribute _attribute;
///
- /// The constructor will setup the property editor based on the attribute if one is found
+ /// Initializes a new instance of the class.
///
public PropertyEditor(ILogger logger)
{
Logger = logger ?? throw new ArgumentNullException(nameof(logger));
- //defaults
+
+ // defaults
Icon = Constants.Icons.PropertyEditor;
Group = "common";
- //assign properties based on the attribute if it is found
+ // assign properties based on the attribute, if it is found
_attribute = GetType().GetCustomAttribute(false);
- if (_attribute != null)
- {
- //set the id/name from the attribute
- Alias = _attribute.Alias;
- Name = _attribute.Name;
- IsParameterEditor = _attribute.IsParameterEditor;
- Icon = _attribute.Icon;
- Group = _attribute.Group;
- IsDeprecated = _attribute.IsDeprecated;
- }
+ if (_attribute == null) return;
+
+ Alias = _attribute.Alias;
+ Name = _attribute.Name;
+ IsParameterEditor = _attribute.IsParameterEditor;
+ Icon = _attribute.Icon;
+ Group = _attribute.Group;
+ IsDeprecated = _attribute.IsDeprecated;
}
+ ///
+ /// Gets a logger.
+ ///
+ protected ILogger Logger { get; }
+
///
/// These are assigned by default normally based on property editor attributes or manifest definitions,
/// developers have the chance to override CreateValueEditor if they don't want to use the pre-defined instance
@@ -62,42 +62,44 @@ namespace Umbraco.Core.PropertyEditors
internal PreValueEditor ManifestDefinedPreValueEditor = null;
///
- /// Boolean flag determining if this can be used as a parameter editor
+ /// Gets or sets a value indicating whether this editor can be used as a parameter editor.
///
[JsonProperty("isParameterEditor")]
public bool IsParameterEditor { get; internal set; }
///
- /// The id of the property editor
+ /// Gets or sets the unique alias of the property editor.
///
[JsonProperty("alias", Required = Required.Always)]
public string Alias { get; internal set; }
///
- /// The name of the property editor
+ /// Gets or sets the name of the property editor.
///
[JsonProperty("name", Required = Required.Always)]
public string Name { get; internal set; }
///
- /// The icon of the property editor - if not set it uses a default icon
+ /// Gets or sets the icon of the property editor.
///
[JsonProperty("icon")]
public string Icon { get; internal set; }
///
- /// The group of the property editor - if not set the editor will list as a generic editor
+ /// Gets or sets the group of the property editor.
///
[JsonProperty("group")]
public string Group { get; internal set; }
+ ///
+ /// Gets or sets a value indicating whether the property editor is deprecated.
+ ///
+ [JsonIgnore]
+ public bool IsDeprecated { get; internal set; } // fixme kill it all in v8
[JsonProperty("editor", Required = Required.Always)]
public PropertyValueEditor ValueEditor => CreateValueEditor();
- [JsonIgnore]
- public bool IsDeprecated { get; internal set; } // fixme kill it all in v8
-
[JsonIgnore]
IValueEditor IParameterEditor.ValueEditor => ValueEditor;
@@ -113,28 +115,26 @@ namespace Umbraco.Core.PropertyEditors
///
/// Creates a value editor instance
///
- ///
protected virtual PropertyValueEditor CreateValueEditor()
{
+ // handle manifest-defined editors
if (ManifestDefinedPropertyValueEditor != null)
{
- //detect if the view is a virtual path (in most cases, yes) then convert it
+ // map view path if virtual
if (ManifestDefinedPropertyValueEditor.View.StartsWith("~/"))
- {
ManifestDefinedPropertyValueEditor.View = IOHelper.ResolveUrl(ManifestDefinedPropertyValueEditor.View);
- }
return ManifestDefinedPropertyValueEditor;
}
- //create a new editor
+ // create a new editor
var editor = new PropertyValueEditor();
+ var view = _attribute?.EditorView;
+ if (string.IsNullOrWhiteSpace(view))
+ throw new InvalidOperationException("The editor does not specify a view.");
- if (_attribute.EditorView.IsNullOrWhiteSpace())
- {
- throw new NotImplementedException("This method must be implemented if a view is not explicitly set");
- }
-
- editor.View = _attribute.EditorView.StartsWith("~/") ? IOHelper.ResolveUrl(_attribute.EditorView) : _attribute.EditorView;
+ if (view.StartsWith("~/"))
+ view = IOHelper.ResolveUrl(view);
+ editor.View = view;
editor.ValueType = _attribute.ValueType;
editor.HideLabel = _attribute.HideLabel;
return editor;
@@ -142,26 +142,23 @@ namespace Umbraco.Core.PropertyEditors
}
///
- /// Creates a pre value editor instance
+ /// Creates a configuration editor instance.
///
- ///
protected virtual PreValueEditor CreatePreValueEditor()
{
- //This will not be null if it is a manifest defined editor
+ // handle manifest-defined editors
if (ManifestDefinedPreValueEditor != null)
{
- foreach (var f in ManifestDefinedPreValueEditor.Fields)
+ foreach (var field in ManifestDefinedPreValueEditor.Fields)
{
- //detect if the view is a virtual path (in most cases, yes) then convert it
- if (f.View.StartsWith("~/"))
- {
- f.View = IOHelper.ResolveUrl(f.View);
- }
+ // map view path if virtual
+ if (field.View.StartsWith("~/"))
+ field.View = IOHelper.ResolveUrl(field.View);
}
return ManifestDefinedPreValueEditor;
}
- //There's no manifest, just return an empty one
+ // else return an empty one
return new PreValueEditor();
}
@@ -180,6 +177,9 @@ namespace Umbraco.Core.PropertyEditors
public override int GetHashCode()
{
+ // an internal setter is required for de-serialization from manifests
+ // but we are never going to change the alias once the editor exists
+ // ReSharper disable once NonReadonlyMemberInGetHashCode
return Alias.GetHashCode();
}
@@ -216,4 +216,16 @@ namespace Umbraco.Core.PropertyEditors
return configuration;
}
}
+
+ public class PropertyEditor : PropertyEditor
+ {
+ public PropertyEditor(ILogger logger)
+ : base(logger)
+ { }
+
+ public virtual TConfiguration MapConfiguration(string configuration)
+ {
+ return JsonConvert.DeserializeObject(configuration);
+ }
+ }
}
diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/CheckboxListValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/CheckboxListValueConverter.cs
index 02ee59f10d..5dd16ed69e 100644
--- a/src/Umbraco.Core/PropertyEditors/ValueConverters/CheckboxListValueConverter.cs
+++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/CheckboxListValueConverter.cs
@@ -11,7 +11,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
private static readonly char[] Comma = { ',' };
public override bool IsConverter(PublishedPropertyType propertyType)
- => propertyType.PropertyEditorAlias.InvariantEquals(Constants.PropertyEditors.CheckBoxListAlias);
+ => propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.CheckBoxListAlias);
public override Type GetPropertyValueType(PublishedPropertyType propertyType)
=> typeof (IEnumerable);
diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/ColorPickerValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/ColorPickerValueConverter.cs
index c86f569cdf..fa21b83a0f 100644
--- a/src/Umbraco.Core/PropertyEditors/ValueConverters/ColorPickerValueConverter.cs
+++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/ColorPickerValueConverter.cs
@@ -7,7 +7,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
public class ColorPickerValueConverter : PropertyValueConverterBase
{
public override bool IsConverter(PublishedPropertyType propertyType)
- => propertyType.PropertyEditorAlias.InvariantEquals(Constants.PropertyEditors.ColorPickerAlias);
+ => propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.ColorPickerAlias);
public override Type GetPropertyValueType(PublishedPropertyType propertyType)
=> typeof (string);
diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/DatePickerValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/DatePickerValueConverter.cs
index 00a25bf564..6ffe57151e 100644
--- a/src/Umbraco.Core/PropertyEditors/ValueConverters/DatePickerValueConverter.cs
+++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/DatePickerValueConverter.cs
@@ -15,7 +15,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
};
public override bool IsConverter(PublishedPropertyType propertyType)
- => PropertyEditorAliases.Contains(propertyType.PropertyEditorAlias);
+ => PropertyEditorAliases.Contains(propertyType.EditorAlias);
public override Type GetPropertyValueType(PublishedPropertyType propertyType)
=> typeof (DateTime);
diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/DecimalValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/DecimalValueConverter.cs
index 52530734fb..b42f1e785d 100644
--- a/src/Umbraco.Core/PropertyEditors/ValueConverters/DecimalValueConverter.cs
+++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/DecimalValueConverter.cs
@@ -8,7 +8,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
public class DecimalValueConverter : PropertyValueConverterBase
{
public override bool IsConverter(PublishedPropertyType propertyType)
- => Constants.PropertyEditors.DecimalAlias.Equals(propertyType.PropertyEditorAlias);
+ => Constants.PropertyEditors.DecimalAlias.Equals(propertyType.EditorAlias);
public override Type GetPropertyValueType(PublishedPropertyType propertyType)
=> typeof (decimal);
diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListMultipleValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListMultipleValueConverter.cs
index 8874ef6d0a..3815e00e01 100644
--- a/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListMultipleValueConverter.cs
+++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListMultipleValueConverter.cs
@@ -9,7 +9,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
public class DropdownListMultipleValueConverter : PropertyValueConverterBase
{
public override bool IsConverter(PublishedPropertyType propertyType)
- => propertyType.PropertyEditorAlias.InvariantEquals(Constants.PropertyEditors.DropDownListMultipleAlias);
+ => propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.DropDownListMultipleAlias);
public override Type GetPropertyValueType(PublishedPropertyType propertyType)
=> typeof (IEnumerable);
diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListMultipleWithKeysValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListMultipleWithKeysValueConverter.cs
index 1bdc4ae8db..b20261de60 100644
--- a/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListMultipleWithKeysValueConverter.cs
+++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListMultipleWithKeysValueConverter.cs
@@ -9,7 +9,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
public class DropdownListMultipleWithKeysValueConverter : PropertyValueConverterBase
{
public override bool IsConverter(PublishedPropertyType propertyType)
- => propertyType.PropertyEditorAlias.InvariantEquals(Constants.PropertyEditors.DropdownlistMultiplePublishKeysAlias);
+ => propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.DropdownlistMultiplePublishKeysAlias);
public override Type GetPropertyValueType(PublishedPropertyType propertyType)
=> typeof (IEnumerable);
diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListValueConverter.cs
index b6b1aa6dce..5134bd3ab8 100644
--- a/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListValueConverter.cs
+++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListValueConverter.cs
@@ -7,7 +7,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
public class DropdownListValueConverter : PropertyValueConverterBase
{
public override bool IsConverter(PublishedPropertyType propertyType)
- => propertyType.PropertyEditorAlias.InvariantEquals(Constants.PropertyEditors.DropDownListAlias);
+ => propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.DropDownListAlias);
public override Type GetPropertyValueType(PublishedPropertyType propertyType)
=> typeof (string);
diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListWithKeysValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListWithKeysValueConverter.cs
index 0656128296..7bda5332fe 100644
--- a/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListWithKeysValueConverter.cs
+++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListWithKeysValueConverter.cs
@@ -7,7 +7,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
public class DropdownListWithKeysValueConverter : PropertyValueConverterBase
{
public override bool IsConverter(PublishedPropertyType propertyType)
- => propertyType.PropertyEditorAlias.InvariantEquals(Constants.PropertyEditors.DropdownlistPublishingKeysAlias);
+ => propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.DropdownlistPublishingKeysAlias);
public override Type GetPropertyValueType(PublishedPropertyType propertyType)
=> typeof (int);
diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/EmailAddressValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/EmailAddressValueConverter.cs
index 9406aec0b7..6458c294e4 100644
--- a/src/Umbraco.Core/PropertyEditors/ValueConverters/EmailAddressValueConverter.cs
+++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/EmailAddressValueConverter.cs
@@ -7,7 +7,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
public class EmailAddressValueConverter : PropertyValueConverterBase
{
public override bool IsConverter(PublishedPropertyType propertyType)
- => propertyType.PropertyEditorAlias.InvariantEquals(Constants.PropertyEditors.EmailAddressAlias);
+ => propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.EmailAddressAlias);
public override Type GetPropertyValueType(PublishedPropertyType propertyType)
=> typeof (string);
diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/GridValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/GridValueConverter.cs
index 666eb4cdc7..4cc93d67a8 100644
--- a/src/Umbraco.Core/PropertyEditors/ValueConverters/GridValueConverter.cs
+++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/GridValueConverter.cs
@@ -20,7 +20,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
public class GridValueConverter : JsonValueConverter
{
public override bool IsConverter(PublishedPropertyType propertyType)
- => propertyType.PropertyEditorAlias.InvariantEquals(Constants.PropertyEditors.GridAlias);
+ => propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.GridAlias);
public override Type GetPropertyValueType(PublishedPropertyType propertyType)
=> typeof (JToken);
diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/ImageCropperValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/ImageCropperValueConverter.cs
index 8ff4cb8c45..2a845bf127 100644
--- a/src/Umbraco.Core/PropertyEditors/ValueConverters/ImageCropperValueConverter.cs
+++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/ImageCropperValueConverter.cs
@@ -19,7 +19,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
private readonly IDataTypeService _dataTypeService;
public override bool IsConverter(PublishedPropertyType propertyType)
- => propertyType.PropertyEditorAlias.InvariantEquals(Constants.PropertyEditors.ImageCropperAlias);
+ => propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.ImageCropperAlias);
public override Type GetPropertyValueType(PublishedPropertyType propertyType)
=> typeof (JToken);
@@ -115,7 +115,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
return sourceString;
}
- MergePreValues(obj, _dataTypeService, propertyType.DataTypeId);
+ MergePreValues(obj, _dataTypeService, propertyType.DataType.Id);
return obj;
}
diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/IntegerValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/IntegerValueConverter.cs
index f89dc2f84a..c663214608 100644
--- a/src/Umbraco.Core/PropertyEditors/ValueConverters/IntegerValueConverter.cs
+++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/IntegerValueConverter.cs
@@ -7,7 +7,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
public class IntegerValueConverter : PropertyValueConverterBase
{
public override bool IsConverter(PublishedPropertyType propertyType)
- => Constants.PropertyEditors.IntegerAlias.Equals(propertyType.PropertyEditorAlias);
+ => Constants.PropertyEditors.IntegerAlias.Equals(propertyType.EditorAlias);
public override Type GetPropertyValueType(PublishedPropertyType propertyType)
=> typeof (int);
diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/JsonValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/JsonValueConverter.cs
index a5f2ac3fc5..de695dd4d5 100644
--- a/src/Umbraco.Core/PropertyEditors/ValueConverters/JsonValueConverter.cs
+++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/JsonValueConverter.cs
@@ -23,7 +23,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
///
public override bool IsConverter(PublishedPropertyType propertyType)
{
- var propertyEditor = Current.PropertyEditors[propertyType.PropertyEditorAlias];
+ var propertyEditor = Current.PropertyEditors[propertyType.EditorAlias];
if (propertyEditor == null) return false;
return propertyEditor.ValueEditor.ValueType.InvariantEquals(PropertyEditorValueTypes.Json);
}
diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/LabelValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/LabelValueConverter.cs
index 23f80993e4..63faf19375 100644
--- a/src/Umbraco.Core/PropertyEditors/ValueConverters/LabelValueConverter.cs
+++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/LabelValueConverter.cs
@@ -16,7 +16,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
public class LabelValueConverter : PropertyValueConverterBase
{
public override bool IsConverter(PublishedPropertyType propertyType)
- => Constants.PropertyEditors.NoEditAlias.Equals(propertyType.PropertyEditorAlias);
+ => Constants.PropertyEditors.NoEditAlias.Equals(propertyType.EditorAlias);
public override Type GetPropertyValueType(PublishedPropertyType propertyType)
=> typeof (string);
diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/MarkdownEditorValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/MarkdownEditorValueConverter.cs
index 349b32d331..8b6870ba46 100644
--- a/src/Umbraco.Core/PropertyEditors/ValueConverters/MarkdownEditorValueConverter.cs
+++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/MarkdownEditorValueConverter.cs
@@ -8,7 +8,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
public class MarkdownEditorValueConverter : PropertyValueConverterBase
{
public override bool IsConverter(PublishedPropertyType propertyType)
- => Constants.PropertyEditors.MarkdownEditorAlias.Equals(propertyType.PropertyEditorAlias);
+ => Constants.PropertyEditors.MarkdownEditorAlias.Equals(propertyType.EditorAlias);
public override Type GetPropertyValueType(PublishedPropertyType propertyType)
=> typeof (IHtmlString);
diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/MemberGroupPickerValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/MemberGroupPickerValueConverter.cs
index 4f63d2a774..4b3965522e 100644
--- a/src/Umbraco.Core/PropertyEditors/ValueConverters/MemberGroupPickerValueConverter.cs
+++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/MemberGroupPickerValueConverter.cs
@@ -7,7 +7,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
public class MemberGroupPickerValueConverter : PropertyValueConverterBase
{
public override bool IsConverter(PublishedPropertyType propertyType)
- => propertyType.PropertyEditorAlias.InvariantEquals(Constants.PropertyEditors.MemberGroupPickerAlias);
+ => propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.MemberGroupPickerAlias);
public override Type GetPropertyValueType(PublishedPropertyType propertyType)
=> typeof (string);
diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/MultipleTextStringValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/MultipleTextStringValueConverter.cs
index 839281dc99..f581a68dea 100644
--- a/src/Umbraco.Core/PropertyEditors/ValueConverters/MultipleTextStringValueConverter.cs
+++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/MultipleTextStringValueConverter.cs
@@ -10,7 +10,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
public class MultipleTextStringValueConverter : PropertyValueConverterBase
{
public override bool IsConverter(PublishedPropertyType propertyType)
- => Constants.PropertyEditors.MultipleTextstringAlias.Equals(propertyType.PropertyEditorAlias);
+ => Constants.PropertyEditors.MultipleTextstringAlias.Equals(propertyType.EditorAlias);
public override Type GetPropertyValueType(PublishedPropertyType propertyType)
=> typeof (IEnumerable);
diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/MustBeStringValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/MustBeStringValueConverter.cs
index e27e313e9a..ac4468d8e3 100644
--- a/src/Umbraco.Core/PropertyEditors/ValueConverters/MustBeStringValueConverter.cs
+++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/MustBeStringValueConverter.cs
@@ -24,7 +24,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
};
public override bool IsConverter(PublishedPropertyType propertyType)
- => Aliases.Contains(propertyType.PropertyEditorAlias);
+ => Aliases.Contains(propertyType.EditorAlias);
public override Type GetPropertyValueType(PublishedPropertyType propertyType)
=> typeof (string);
diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/RadioButtonListValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/RadioButtonListValueConverter.cs
index f48b342636..d71d72c980 100644
--- a/src/Umbraco.Core/PropertyEditors/ValueConverters/RadioButtonListValueConverter.cs
+++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/RadioButtonListValueConverter.cs
@@ -7,7 +7,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
public class RadioButtonListValueConverter : PropertyValueConverterBase
{
public override bool IsConverter(PublishedPropertyType propertyType)
- => propertyType.PropertyEditorAlias.InvariantEquals(Constants.PropertyEditors.RadioButtonListAlias);
+ => propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.RadioButtonListAlias);
public override Type GetPropertyValueType(PublishedPropertyType propertyType)
=> typeof (int);
diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/SliderValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/SliderValueConverter.cs
index 47ef12030e..66d46f0e13 100644
--- a/src/Umbraco.Core/PropertyEditors/ValueConverters/SliderValueConverter.cs
+++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/SliderValueConverter.cs
@@ -19,10 +19,10 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
}
public override bool IsConverter(PublishedPropertyType propertyType)
- => propertyType.PropertyEditorAlias.InvariantEquals(Constants.PropertyEditors.SliderAlias);
+ => propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.SliderAlias);
public override Type GetPropertyValueType(PublishedPropertyType propertyType)
- => IsRangeDataType(propertyType.DataTypeId) ? typeof (Range) : typeof (decimal);
+ => IsRangeDataType(propertyType.DataType.Id) ? typeof (Range) : typeof (decimal);
public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType)
=> PropertyCacheLevel.Element;
@@ -32,7 +32,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
if (source == null)
return null;
- if (IsRangeDataType(propertyType.DataTypeId))
+ if (IsRangeDataType(propertyType.DataType.Id))
{
var rangeRawValues = source.ToString().Split(',');
var minimumAttempt = rangeRawValues[0].TryConvertTo();
diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/TagsValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/TagsValueConverter.cs
index 54ede366ff..4963aaf606 100644
--- a/src/Umbraco.Core/PropertyEditors/ValueConverters/TagsValueConverter.cs
+++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/TagsValueConverter.cs
@@ -20,7 +20,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
}
public override bool IsConverter(PublishedPropertyType propertyType)
- => propertyType.PropertyEditorAlias.InvariantEquals(Constants.PropertyEditors.TagsAlias);
+ => propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.TagsAlias);
public override Type GetPropertyValueType(PublishedPropertyType propertyType)
=> typeof (IEnumerable);
@@ -31,7 +31,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
public override object ConvertSourceToIntermediate(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview)
{
// if Json storage type deserialzie and return as string array
- if (JsonStorageType(propertyType.DataTypeId))
+ if (JsonStorageType(propertyType.DataType.Id))
{
var jArray = JsonConvert.DeserializeObject(source.ToString());
return jArray.ToObject();
diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/TextStringValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/TextStringValueConverter.cs
index bd07b55fb6..5ec9ef2f3c 100644
--- a/src/Umbraco.Core/PropertyEditors/ValueConverters/TextStringValueConverter.cs
+++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/TextStringValueConverter.cs
@@ -14,7 +14,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
};
public override bool IsConverter(PublishedPropertyType propertyType)
- => PropertyTypeAliases.Contains(propertyType.PropertyEditorAlias);
+ => PropertyTypeAliases.Contains(propertyType.EditorAlias);
public override Type GetPropertyValueType(PublishedPropertyType propertyType)
=> typeof (string);
diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/TinyMceValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/TinyMceValueConverter.cs
index 420053c53d..bb1f0ed78a 100644
--- a/src/Umbraco.Core/PropertyEditors/ValueConverters/TinyMceValueConverter.cs
+++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/TinyMceValueConverter.cs
@@ -11,7 +11,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
public class TinyMceValueConverter : PropertyValueConverterBase
{
public override bool IsConverter(PublishedPropertyType propertyType)
- => propertyType.PropertyEditorAlias == Constants.PropertyEditors.TinyMCEAlias;
+ => propertyType.EditorAlias == Constants.PropertyEditors.TinyMCEAlias;
public override Type GetPropertyValueType(PublishedPropertyType propertyType)
=> typeof (IHtmlString);
diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/UploadPropertyConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/UploadPropertyConverter.cs
index b37a5ea977..8ecdedad33 100644
--- a/src/Umbraco.Core/PropertyEditors/ValueConverters/UploadPropertyConverter.cs
+++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/UploadPropertyConverter.cs
@@ -10,7 +10,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
public class UploadPropertyConverter : PropertyValueConverterBase
{
public override bool IsConverter(PublishedPropertyType propertyType)
- => propertyType.PropertyEditorAlias.Equals(Constants.PropertyEditors.UploadFieldAlias);
+ => propertyType.EditorAlias.Equals(Constants.PropertyEditors.UploadFieldAlias);
public override Type GetPropertyValueType(PublishedPropertyType propertyType)
=> typeof (string);
diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/YesNoValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/YesNoValueConverter.cs
index d643c190af..795d4e4abb 100644
--- a/src/Umbraco.Core/PropertyEditors/ValueConverters/YesNoValueConverter.cs
+++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/YesNoValueConverter.cs
@@ -7,7 +7,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
public class YesNoValueConverter : PropertyValueConverterBase
{
public override bool IsConverter(PublishedPropertyType propertyType)
- => propertyType.PropertyEditorAlias == Constants.PropertyEditors.TrueFalseAlias;
+ => propertyType.EditorAlias == Constants.PropertyEditors.TrueFalseAlias;
public override Type GetPropertyValueType(PublishedPropertyType propertyType)
=> typeof (bool);
diff --git a/src/Umbraco.Core/Services/EntityXmlSerializer.cs b/src/Umbraco.Core/Services/EntityXmlSerializer.cs
index a7e44e77e2..a152fa29e3 100644
--- a/src/Umbraco.Core/Services/EntityXmlSerializer.cs
+++ b/src/Umbraco.Core/Services/EntityXmlSerializer.cs
@@ -133,10 +133,10 @@ namespace Umbraco.Core.Services
return xml;
}
- public XElement Serialize(IDataTypeService dataTypeService, IDataTypeDefinition dataTypeDefinition)
+ public XElement Serialize(IDataTypeService dataTypeService, IDataType dataType)
{
var prevalues = new XElement("PreValues");
- var prevalueList = dataTypeService.GetPreValuesCollectionByDataTypeId(dataTypeDefinition.Id)
+ var prevalueList = dataTypeService.GetPreValuesCollectionByDataTypeId(dataType.Id)
.FormatAsDictionary();
var sort = 0;
@@ -152,17 +152,17 @@ namespace Umbraco.Core.Services
}
var xml = new XElement("DataType", prevalues);
- xml.Add(new XAttribute("Name", dataTypeDefinition.Name));
+ xml.Add(new XAttribute("Name", dataType.Name));
//The 'ID' when exporting is actually the property editor alias (in pre v7 it was the IDataType GUID id)
- xml.Add(new XAttribute("Id", dataTypeDefinition.PropertyEditorAlias));
- xml.Add(new XAttribute("Definition", dataTypeDefinition.Key));
- xml.Add(new XAttribute("DatabaseType", dataTypeDefinition.DatabaseType.ToString()));
+ xml.Add(new XAttribute("Id", dataType.EditorAlias));
+ xml.Add(new XAttribute("Definition", dataType.Key));
+ xml.Add(new XAttribute("DatabaseType", dataType.DatabaseType.ToString()));
var folderNames = string.Empty;
- if (dataTypeDefinition.Level != 1)
+ if (dataType.Level != 1)
{
//get url encoded folder names
- var folders = dataTypeService.GetContainers(dataTypeDefinition)
+ var folders = dataTypeService.GetContainers(dataType)
.OrderBy(x => x.Level)
.Select(x => HttpUtility.UrlEncode(x.Name));
diff --git a/src/Umbraco.Core/Services/IDataTypeService.cs b/src/Umbraco.Core/Services/IDataTypeService.cs
index 660e06b365..6f3f41b817 100644
--- a/src/Umbraco.Core/Services/IDataTypeService.cs
+++ b/src/Umbraco.Core/Services/IDataTypeService.cs
@@ -5,7 +5,7 @@ using Umbraco.Core.Models;
namespace Umbraco.Core.Services
{
///
- /// Defines the DataType Service, which is an easy access to operations involving
+ /// Defines the DataType Service, which is an easy access to operations involving
///
public interface IDataTypeService : IService
{
@@ -14,83 +14,83 @@ namespace Umbraco.Core.Services
EntityContainer GetContainer(int containerId);
EntityContainer GetContainer(Guid containerId);
IEnumerable GetContainers(string folderName, int level);
- IEnumerable GetContainers(IDataTypeDefinition dataTypeDefinition);
+ IEnumerable GetContainers(IDataType dataType);
IEnumerable GetContainers(int[] containerIds);
Attempt DeleteContainer(int containerId, int userId = 0);
Attempt> RenameContainer(int id, string name, int userId = 0);
///
- /// Gets a by its Name
+ /// Gets a by its Name
///
- /// Name of the
- ///
- IDataTypeDefinition GetDataTypeDefinitionByName(string name);
+ /// Name of the
+ ///
+ IDataType GetDataTypeDefinitionByName(string name);
///
- /// Gets a by its Id
+ /// Gets a by its Id
///
- /// Id of the
- ///
- IDataTypeDefinition GetDataTypeDefinitionById(int id);
+ /// Id of the
+ ///
+ IDataType GetDataTypeDefinitionById(int id);
///
- /// Gets a by its unique guid Id
+ /// Gets a by its unique guid Id
///
/// Unique guid Id of the DataType
- ///
- IDataTypeDefinition GetDataTypeDefinitionById(Guid id);
+ ///
+ IDataType GetDataTypeDefinitionById(Guid id);
///
- /// Gets all objects or those with the ids passed in
+ /// Gets all objects or those with the ids passed in
///
/// Optional array of Ids
- /// An enumerable list of objects
- IEnumerable GetAllDataTypeDefinitions(params int[] ids);
+ /// An enumerable list of objects
+ IEnumerable GetAllDataTypeDefinitions(params int[] ids);
///
- /// Saves an
+ /// Saves an
///
- /// to save
+ /// to save
/// Id of the user issueing the save
- void Save(IDataTypeDefinition dataTypeDefinition, int userId = 0);
+ void Save(IDataType dataType, int userId = 0);
///
- /// Saves a collection of
+ /// Saves a collection of
///
- /// to save
+ /// to save
/// Id of the user issueing the save
- void Save(IEnumerable dataTypeDefinitions, int userId = 0);
+ void Save(IEnumerable dataTypeDefinitions, int userId = 0);
///
- /// Saves a collection of
+ /// Saves a collection of
///
- /// to save
+ /// to save
/// Id of the user issueing the save
/// Boolean indicating whether or not to raise events
- void Save(IEnumerable dataTypeDefinitions, int userId, bool raiseEvents);
+ void Save(IEnumerable dataTypeDefinitions, int userId, bool raiseEvents);
///
- /// Deletes an
+ /// Deletes an
///
///
- /// Please note that deleting a will remove
- /// all the data that references this .
+ /// Please note that deleting a will remove
+ /// all the data that references this .
///
- /// to delete
+ /// to delete
/// Id of the user issueing the deletion
- void Delete(IDataTypeDefinition dataTypeDefinition, int userId = 0);
+ void Delete(IDataType dataType, int userId = 0);
///
- /// Gets a by its control Id
+ /// Gets a by its control Id
///
/// Alias of the property editor
- /// Collection of objects with a matching contorl id
- IEnumerable GetDataTypeDefinitionByPropertyEditorAlias(string propertyEditorAlias);
+ /// Collection of objects with a matching contorl id
+ IEnumerable GetDataTypeDefinitionByPropertyEditorAlias(string propertyEditorAlias);
///
- /// Gets all values for an
+ /// Gets all values for an
///
- /// Id of the to retrieve prevalues from
+ /// Id of the to retrieve prevalues from
/// An enumerable list of string values
IEnumerable GetPreValuesByDataTypeId(int id);
@@ -119,17 +119,17 @@ namespace Umbraco.Core.Services
///
/// Saves a list of PreValues for a given DataTypeDefinition
///
- /// The DataTypeDefinition to save PreValues for
+ /// The DataTypeDefinition to save PreValues for
/// List of key/value pairs to save
- void SavePreValues(IDataTypeDefinition dataTypeDefinition, IDictionary values);
+ void SavePreValues(IDataType dataType, IDictionary values);
///
/// Saves the data type and it's prevalues
///
- ///
+ ///
///
///
- void SaveDataTypeAndPreValues(IDataTypeDefinition dataTypeDefinition, IDictionary values, int userId = 0);
+ void SaveDataTypeAndPreValues(IDataType dataType, IDictionary values, int userId = 0);
///
/// Gets a specific PreValue by its Id
@@ -138,7 +138,7 @@ namespace Umbraco.Core.Services
/// PreValue as a string
string GetPreValueAsString(int id);
- Attempt> Move(IDataTypeDefinition toMove, int parentId);
+ Attempt> Move(IDataType toMove, int parentId);
}
}
diff --git a/src/Umbraco.Core/Services/IEntityService.cs b/src/Umbraco.Core/Services/IEntityService.cs
index 5b9fdef86a..38eb2a0f05 100644
--- a/src/Umbraco.Core/Services/IEntityService.cs
+++ b/src/Umbraco.Core/Services/IEntityService.cs
@@ -252,12 +252,12 @@ namespace Umbraco.Core.Services
///
/// Gets paths for entities.
///
- IEnumerable GetAllPaths(UmbracoObjectTypes umbracoObjectType, params int[] ids);
+ IEnumerable GetAllPaths(UmbracoObjectTypes umbracoObjectType, params int[] ids);
///
/// Gets paths for entities.
///
- IEnumerable GetAllPaths(UmbracoObjectTypes umbracoObjectType, params Guid[] keys);
+ IEnumerable GetAllPaths(UmbracoObjectTypes umbracoObjectType, params Guid[] keys);
///
/// Gets the UmbracoObjectType from the integer id of an IUmbracoEntity.
diff --git a/src/Umbraco.Core/Services/IPackagingService.cs b/src/Umbraco.Core/Services/IPackagingService.cs
index 5a527c1983..ceab6e94bf 100644
--- a/src/Umbraco.Core/Services/IPackagingService.cs
+++ b/src/Umbraco.Core/Services/IPackagingService.cs
@@ -37,13 +37,13 @@ namespace Umbraco.Core.Services
IEnumerable ImportContentTypes(XElement element, bool importStructure, int userId = 0, bool raiseEvents = true);
///
- /// Imports and saves package xml as
+ /// Imports and saves package xml as
///
/// Xml to import
/// Optional id of the User performing the operation. Default is zero (admin).
/// Optional parameter indicating whether or not to raise events
/// An enumrable list of generated DataTypeDefinitions
- IEnumerable ImportDataTypeDefinitions(XElement element, int userId = 0, bool raiseEvents = true);
+ IEnumerable ImportDataTypeDefinitions(XElement element, int userId = 0, bool raiseEvents = true);
///
/// Imports and saves the 'DictionaryItems' part of the package xml as a list of
@@ -146,15 +146,15 @@ namespace Umbraco.Core.Services
/// List of data types to export
/// Optional parameter indicating whether or not to raise events
/// containing the xml representation of the IDataTypeDefinition objects
- XElement Export(IEnumerable dataTypeDefinitions, bool raiseEvents = true);
+ XElement Export(IEnumerable dataTypeDefinitions, bool raiseEvents = true);
///
/// Exports a single Data Type
///
- /// Data type to export
+ /// Data type to export
/// Optional parameter indicating whether or not to raise events
/// containing the xml representation of the IDataTypeDefinition object
- XElement Export(IDataTypeDefinition dataTypeDefinition, bool raiseEvents = true);
+ XElement Export(IDataType dataType, bool raiseEvents = true);
///
/// Exports a list of items to xml as an
diff --git a/src/Umbraco.Core/Services/Implement/ContentService.cs b/src/Umbraco.Core/Services/Implement/ContentService.cs
index 5e0efc4223..e4337f9dac 100644
--- a/src/Umbraco.Core/Services/Implement/ContentService.cs
+++ b/src/Umbraco.Core/Services/Implement/ContentService.cs
@@ -198,35 +198,6 @@ namespace Umbraco.Core.Services.Implement
return content;
}
- ///
- /// Creates an object of a specified content type, at root.
- ///
- /// This method simply returns a new, non-persisted, IContent without any identity. It
- /// is intended as a shortcut to creating new content objects that does not invoke a save
- /// operation against the database.
- ///
- /// The name of the content object.
- /// The alias of the content type.
- /// The optional id of the user creating the content.
- /// The content object.
- public IContent CreateContent(string name, string contentTypeAlias, int userId = 0)
- {
- // not locking since not saving anything
-
- var contentType = GetContentType(contentTypeAlias);
- if (contentType == null)
- throw new ArgumentException("No content type with that alias.", nameof(contentTypeAlias));
-
- var content = new Content(name, -1, contentType);
- using (var scope = ScopeProvider.CreateScope())
- {
- CreateContent(scope, content, null, userId, false);
- scope.Complete();
- }
-
- return content;
- }
-
///
/// Creates an object of a specified content type, under a parent.
///
@@ -323,29 +294,15 @@ namespace Umbraco.Core.Services.Implement
private void CreateContent(IScope scope, Content content, IContent parent, int userId, bool withIdentity)
{
- // NOTE: I really hate the notion of these Creating/Created events - they are so inconsistent, I've only just found
- // out that in these 'WithIdentity' methods, the Saving/Saved events were not fired, wtf. Anyways, they're added now.
- var newArgs = parent != null
- ? new NewEventArgs(content, content.ContentType.Alias, parent)
- : new NewEventArgs(content, content.ContentType.Alias, -1);
-
- if (scope.Events.DispatchCancelable(Creating, this, newArgs))
- {
- content.WasCancelled = true;
- return;
- }
-
content.CreatorId = userId;
content.WriterId = userId;
if (withIdentity)
{
+ // if saving is cancelled, content remains without an identity
var saveEventArgs = new SaveEventArgs(content);
if (scope.Events.DispatchCancelable(Saving, this, saveEventArgs, "Saving"))
- {
- content.WasCancelled = true;
return;
- }
_documentRepository.Save(content);
@@ -1903,12 +1860,6 @@ namespace Umbraco.Core.Services.Implement
///
public static event TypedEventHandler> Saved;
- ///
- /// Occurs before Create
- ///
- [Obsolete("Use the Created event instead, the Creating and Created events both offer the same functionality, Creating event has been deprecated.")]
- public static event TypedEventHandler> Creating;
-
///
/// Occurs after Create
///
diff --git a/src/Umbraco.Core/Services/Implement/DataTypeService.cs b/src/Umbraco.Core/Services/Implement/DataTypeService.cs
index 853c35f409..67b5387cbb 100644
--- a/src/Umbraco.Core/Services/Implement/DataTypeService.cs
+++ b/src/Umbraco.Core/Services/Implement/DataTypeService.cs
@@ -14,22 +14,22 @@ using Umbraco.Core.Scoping;
namespace Umbraco.Core.Services.Implement
{
///
- /// Represents the DataType Service, which is an easy access to operations involving
+ /// Represents the DataType Service, which is an easy access to operations involving
///
internal class DataTypeService : ScopeRepositoryService, IDataTypeService
{
- private readonly IDataTypeDefinitionRepository _dataTypeDefinitionRepository;
+ private readonly IDataTypeRepository _dataTypeRepository;
private readonly IDataTypeContainerRepository _dataTypeContainerRepository;
private readonly IContentTypeRepository _contentTypeRepository;
private readonly IAuditRepository _auditRepository;
private readonly IEntityRepository _entityRepository;
public DataTypeService(IScopeProvider provider, ILogger logger, IEventMessagesFactory eventMessagesFactory,
- IDataTypeDefinitionRepository dataTypeDefinitionRepository, IDataTypeContainerRepository dataTypeContainerRepository,
+ IDataTypeRepository dataTypeRepository, IDataTypeContainerRepository dataTypeContainerRepository,
IAuditRepository auditRepository, IEntityRepository entityRepository, IContentTypeRepository contentTypeRepository)
: base(provider, logger, eventMessagesFactory)
{
- _dataTypeDefinitionRepository = dataTypeDefinitionRepository;
+ _dataTypeRepository = dataTypeRepository;
_dataTypeContainerRepository = dataTypeContainerRepository;
_auditRepository = auditRepository;
_entityRepository = entityRepository;
@@ -97,15 +97,15 @@ namespace Umbraco.Core.Services.Implement
}
}
- public IEnumerable GetContainers(IDataTypeDefinition dataTypeDefinition)
+ public IEnumerable GetContainers(IDataType dataType)
{
- var ancestorIds = dataTypeDefinition.Path.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
+ var ancestorIds = dataType.Path.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
.Select(x =>
{
var asInt = x.TryConvertTo();
return asInt ? asInt.Result : int.MinValue;
})
- .Where(x => x != int.MinValue && x != dataTypeDefinition.Id)
+ .Where(x => x != int.MinValue && x != dataType.Id)
.ToArray();
return GetContainers(ancestorIds);
@@ -214,82 +214,82 @@ namespace Umbraco.Core.Services.Implement
#endregion
///
- /// Gets a by its Name
+ /// Gets a by its Name
///
- /// Name of the
- ///
- public IDataTypeDefinition GetDataTypeDefinitionByName(string name)
+ /// Name of the
+ ///
+ public IDataType GetDataTypeDefinitionByName(string name)
{
using (var scope = ScopeProvider.CreateScope(autoComplete: true))
{
- return _dataTypeDefinitionRepository.Get(Query().Where(x => x.Name == name)).FirstOrDefault();
+ return _dataTypeRepository.Get(Query().Where(x => x.Name == name)).FirstOrDefault();
}
}
///
- /// Gets a by its Id
+ /// Gets a by its Id
///
- /// Id of the
- ///
- public IDataTypeDefinition GetDataTypeDefinitionById(int id)
+ /// Id of the
+ ///
+ public IDataType GetDataTypeDefinitionById(int id)
{
using (var scope = ScopeProvider.CreateScope(autoComplete: true))
{
- return _dataTypeDefinitionRepository.Get(id);
+ return _dataTypeRepository.Get(id);
}
}
///
- /// Gets a by its unique guid Id
+ /// Gets a by its unique guid Id
///
/// Unique guid Id of the DataType
- ///
- public IDataTypeDefinition GetDataTypeDefinitionById(Guid id)
+ ///
+ public IDataType GetDataTypeDefinitionById(Guid id)
{
using (var scope = ScopeProvider.CreateScope(autoComplete: true))
{
- var query = Query().Where(x => x.Key == id);
- return _dataTypeDefinitionRepository.Get(query).FirstOrDefault();
+ var query = Query().Where(x => x.Key == id);
+ return _dataTypeRepository.Get(query).FirstOrDefault();
}
}
///
- /// Gets a by its control Id
+ /// Gets a by its control Id
///
/// Alias of the property editor
- /// Collection of objects with a matching contorl id
- public IEnumerable GetDataTypeDefinitionByPropertyEditorAlias(string propertyEditorAlias)
+ /// Collection of objects with a matching contorl id
+ public IEnumerable GetDataTypeDefinitionByPropertyEditorAlias(string propertyEditorAlias)
{
using (var scope = ScopeProvider.CreateScope(autoComplete: true))
{
- var query = Query().Where(x => x.PropertyEditorAlias == propertyEditorAlias);
- return _dataTypeDefinitionRepository.Get(query);
+ var query = Query().Where(x => x.EditorAlias == propertyEditorAlias);
+ return _dataTypeRepository.Get(query);
}
}
///
- /// Gets all objects or those with the ids passed in
+ /// Gets all objects or those with the ids passed in
///
/// Optional array of Ids
- /// An enumerable list of objects
- public IEnumerable GetAllDataTypeDefinitions(params int[] ids)
+ /// An enumerable list of objects
+ public IEnumerable GetAllDataTypeDefinitions(params int[] ids)
{
using (var scope = ScopeProvider.CreateScope(autoComplete: true))
{
- return _dataTypeDefinitionRepository.GetMany(ids);
+ return _dataTypeRepository.GetMany(ids);
}
}
///
- /// Gets all prevalues for an
+ /// Gets all prevalues for an
///
- /// Id of the to retrieve prevalues from
+ /// Id of the to retrieve prevalues from
/// An enumerable list of string values
public IEnumerable GetPreValuesByDataTypeId(int id)
{
using (var scope = ScopeProvider.CreateScope(autoComplete: true))
{
- var collection = _dataTypeDefinitionRepository.GetPreValuesCollectionByDataTypeId(id);
+ var collection = _dataTypeRepository.GetPreValuesCollectionByDataTypeId(id);
//now convert the collection to a string list
return collection.FormatAsDictionary()
.Select(x => x.Value.Value)
@@ -306,7 +306,7 @@ namespace Umbraco.Core.Services.Implement
{
using (var scope = ScopeProvider.CreateScope(autoComplete: true))
{
- return _dataTypeDefinitionRepository.GetPreValuesCollectionByDataTypeId(id);
+ return _dataTypeRepository.GetPreValuesCollectionByDataTypeId(id);
}
}
@@ -319,19 +319,19 @@ namespace Umbraco.Core.Services.Implement
{
using (var scope = ScopeProvider.CreateScope(autoComplete: true))
{
- return _dataTypeDefinitionRepository.GetPreValueAsString(id);
+ return _dataTypeRepository.GetPreValueAsString(id);
}
}
- public Attempt> Move(IDataTypeDefinition toMove, int parentId)
+ public Attempt> Move(IDataType toMove, int parentId)
{
var evtMsgs = EventMessagesFactory.Get();
- var moveInfo = new List>();
+ var moveInfo = new List>();
using (var scope = ScopeProvider.CreateScope())
{
- var moveEventInfo = new MoveEventInfo(toMove, toMove.Path, parentId);
- var moveEventArgs = new MoveEventArgs(evtMsgs, moveEventInfo);
+ var moveEventInfo = new MoveEventInfo(toMove, toMove.Path, parentId);
+ var moveEventArgs = new MoveEventArgs(evtMsgs, moveEventInfo);
if (scope.Events.DispatchCancelable(Moving, this, moveEventArgs))
{
scope.Complete();
@@ -347,7 +347,7 @@ namespace Umbraco.Core.Services.Implement
if (container == null)
throw new DataOperationException(MoveOperationStatusType.FailedParentNotFound); // causes rollback
}
- moveInfo.AddRange(_dataTypeDefinitionRepository.Move(toMove, container));
+ moveInfo.AddRange(_dataTypeRepository.Move(toMove, container));
moveEventArgs.MoveInfoCollection = moveInfo;
moveEventArgs.CanCancel = false;
@@ -365,57 +365,57 @@ namespace Umbraco.Core.Services.Implement
}
///
- /// Saves an
+ /// Saves an
///
- /// to save
+ /// to save
/// Id of the user issueing the save
- public void Save(IDataTypeDefinition dataTypeDefinition, int userId = 0)
+ public void Save(IDataType dataType, int userId = 0)
{
- dataTypeDefinition.CreatorId = userId;
+ dataType.CreatorId = userId;
using (var scope = ScopeProvider.CreateScope())
{
- var saveEventArgs = new SaveEventArgs(dataTypeDefinition);
+ var saveEventArgs = new SaveEventArgs(dataType);
if (scope.Events.DispatchCancelable(Saving, this, saveEventArgs))
{
scope.Complete();
return;
}
- if (string.IsNullOrWhiteSpace(dataTypeDefinition.Name))
+ if (string.IsNullOrWhiteSpace(dataType.Name))
{
throw new ArgumentException("Cannot save datatype with empty name.");
}
- _dataTypeDefinitionRepository.Save(dataTypeDefinition);
+ _dataTypeRepository.Save(dataType);
saveEventArgs.CanCancel = false;
scope.Events.Dispatch(Saved, this, saveEventArgs);
- Audit(AuditType.Save, "Save DataTypeDefinition performed by user", userId, dataTypeDefinition.Id);
+ Audit(AuditType.Save, "Save DataTypeDefinition performed by user", userId, dataType.Id);
scope.Complete();
}
}
///
- /// Saves a collection of
+ /// Saves a collection of
///
- /// to save
+ /// to save
/// Id of the user issueing the save
- public void Save(IEnumerable dataTypeDefinitions, int userId = 0)
+ public void Save(IEnumerable dataTypeDefinitions, int userId = 0)
{
Save(dataTypeDefinitions, userId, true);
}
///
- /// Saves a collection of
+ /// Saves a collection of
///
- /// to save
+ /// to save
/// Id of the user issueing the save
/// Boolean indicating whether or not to raise events
- public void Save(IEnumerable dataTypeDefinitions, int userId, bool raiseEvents)
+ public void Save(IEnumerable dataTypeDefinitions, int userId, bool raiseEvents)
{
var dataTypeDefinitionsA = dataTypeDefinitions.ToArray();
- var saveEventArgs = new SaveEventArgs(dataTypeDefinitionsA);
+ var saveEventArgs = new SaveEventArgs(dataTypeDefinitionsA);
using (var scope = ScopeProvider.CreateScope())
{
@@ -428,7 +428,7 @@ namespace Umbraco.Core.Services.Implement
foreach (var dataTypeDefinition in dataTypeDefinitionsA)
{
dataTypeDefinition.CreatorId = userId;
- _dataTypeDefinitionRepository.Save(dataTypeDefinition);
+ _dataTypeRepository.Save(dataTypeDefinition);
}
if (raiseEvents)
@@ -492,19 +492,19 @@ namespace Umbraco.Core.Services.Implement
///
/// Saves/updates the pre-values
///
- ///
+ ///
///
///
/// We need to actually look up each pre-value and maintain it's id if possible - this is because of silly property editors
/// like 'dropdown list publishing keys'
///
- public void SavePreValues(IDataTypeDefinition dataTypeDefinition, IDictionary values)
+ public void SavePreValues(IDataType dataType, IDictionary values)
{
//TODO: Should we raise an event here since we are really saving values for the data type?
using (var scope = ScopeProvider.CreateScope())
{
- _dataTypeDefinitionRepository.AddOrUpdatePreValues(dataTypeDefinition, values);
+ _dataTypeRepository.AddOrUpdatePreValues(dataType, values);
scope.Complete();
}
}
@@ -512,14 +512,14 @@ namespace Umbraco.Core.Services.Implement
///
/// This will save a data type and it's pre-values in one transaction
///
- ///
+ ///
///
///
- public void SaveDataTypeAndPreValues(IDataTypeDefinition dataTypeDefinition, IDictionary values, int userId = 0)
+ public void SaveDataTypeAndPreValues(IDataType dataType, IDictionary