Remove "additional data" from entities (#16024)
* Remove "additional data" from entities * Fix merge issue --------- Co-authored-by: Bjarke Berg <mail@bergmania.dk>
This commit is contained in:
@@ -22,8 +22,6 @@ public class EntitySlim : IEntitySlim
|
||||
/// </summary>
|
||||
public static readonly IEntitySlim Root = new EntitySlim { Path = "-1", Name = "root", HasChildren = true };
|
||||
|
||||
private IDictionary<string, object?>? _additionalData;
|
||||
|
||||
// implement IEntity
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -84,17 +82,6 @@ public class EntitySlim : IEntitySlim
|
||||
[DataMember]
|
||||
public bool Trashed { get; set; }
|
||||
|
||||
// implement IUmbracoEntity
|
||||
|
||||
/// <inheritdoc />
|
||||
[DataMember]
|
||||
public IDictionary<string, object?>? AdditionalData =>
|
||||
_additionalData ??= new Dictionary<string, object?>();
|
||||
|
||||
/// <inheritdoc />
|
||||
[IgnoreDataMember]
|
||||
public bool HasAdditionalData => _additionalData != null;
|
||||
|
||||
// implement IEntitySlim
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -3,7 +3,7 @@ namespace Umbraco.Cms.Core.Models.Entities;
|
||||
/// <summary>
|
||||
/// Represents a lightweight entity, managed by the entity service.
|
||||
/// </summary>
|
||||
public interface IEntitySlim : IUmbracoEntity, IHaveAdditionalData
|
||||
public interface IEntitySlim : IUmbracoEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the entity object type.
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
namespace Umbraco.Cms.Core.Models.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// Provides support for additional data.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>Additional data are transient, not deep-cloned.</para>
|
||||
/// </remarks>
|
||||
public interface IHaveAdditionalData
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets additional data for this entity.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Can be empty, but never null. To avoid allocating, do not
|
||||
/// test for emptiness, but use <see cref="HasAdditionalData" /> instead.
|
||||
/// </remarks>
|
||||
IDictionary<string, object?>? AdditionalData { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether this entity has additional data.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Use this property to check for additional data without
|
||||
/// getting <see cref="AdditionalData" />, to avoid allocating.
|
||||
/// </remarks>
|
||||
bool HasAdditionalData { get; }
|
||||
|
||||
// how to implement:
|
||||
|
||||
/*
|
||||
private IDictionary<string, object> _additionalData;
|
||||
|
||||
/// <inheritdoc />
|
||||
[DataMember]
|
||||
[DoNotClone]
|
||||
PublicAccessEntry IDictionary<string, object> AdditionalData => _additionalData ?? (_additionalData = new Dictionary<string, object>());
|
||||
|
||||
/// <inheritdoc />
|
||||
[IgnoreDataMember]
|
||||
PublicAccessEntry bool HasAdditionalData => _additionalData != null;
|
||||
*/
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
// Copyright (c) Umbraco.
|
||||
// See LICENSE for more details.
|
||||
|
||||
using Umbraco.Cms.Core.Models.Entities;
|
||||
|
||||
namespace Umbraco.Extensions;
|
||||
|
||||
public static class HaveAdditionalDataExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets additional data.
|
||||
/// </summary>
|
||||
public static object? GetAdditionalDataValueIgnoreCase(this IHaveAdditionalData entity, string key, object? defaultValue)
|
||||
{
|
||||
if (!entity.HasAdditionalData)
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
if (entity.AdditionalData?.ContainsKeyIgnoreCase(key) == false)
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
return entity.AdditionalData?.GetValueIgnoreCase(key, defaultValue);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
using System.ComponentModel;
|
||||
using Umbraco.Cms.Core.Models.Entities;
|
||||
using Umbraco.Cms.Core.Models.Membership;
|
||||
|
||||
namespace Umbraco.Cms.Core.Models;
|
||||
|
||||
public interface IMember : IContentBase, IMembershipUser, IHaveAdditionalData
|
||||
public interface IMember : IContentBase, IMembershipUser
|
||||
{
|
||||
/// <summary>
|
||||
/// String alias of the default ContentType
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace Umbraco.Cms.Core.Models;
|
||||
/// <summary>
|
||||
/// Represents a member type
|
||||
/// </summary>
|
||||
public interface IMemberGroup : IEntity, IRememberBeingDirty, IHaveAdditionalData
|
||||
public interface IMemberGroup : IEntity, IRememberBeingDirty
|
||||
{
|
||||
/// <summary>
|
||||
/// The name of the member group
|
||||
|
||||
@@ -11,7 +11,6 @@ namespace Umbraco.Cms.Core.Models;
|
||||
[DataContract(IsReference = true)]
|
||||
public class Member : ContentBase, IMember
|
||||
{
|
||||
private IDictionary<string, object?>? _additionalData;
|
||||
private string _email;
|
||||
private DateTime? _emailConfirmedDate;
|
||||
private int _failedPasswordAttempts;
|
||||
@@ -508,15 +507,6 @@ public class Member : ContentBase, IMember
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public string? PropertyTypeAlias { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
[DataMember]
|
||||
[DoNotClone]
|
||||
public IDictionary<string, object?> AdditionalData => _additionalData ??= new Dictionary<string, object?>();
|
||||
|
||||
/// <inheritdoc />
|
||||
[IgnoreDataMember]
|
||||
public bool HasAdditionalData => _additionalData != null;
|
||||
|
||||
private Attempt<T> WarnIfPropertyTypeNotFoundOnGet<T>(string propertyAlias, string propertyName, T defaultVal)
|
||||
{
|
||||
static void DoLog(string logPropertyAlias, string logPropertyName)
|
||||
|
||||
@@ -10,36 +10,14 @@ namespace Umbraco.Cms.Core.Models;
|
||||
[DataContract(IsReference = true)]
|
||||
public class MemberGroup : EntityBase, IMemberGroup
|
||||
{
|
||||
private IDictionary<string, object?>? _additionalData;
|
||||
private int _creatorId;
|
||||
private string? _name;
|
||||
|
||||
/// <inheritdoc />
|
||||
[DataMember]
|
||||
[DoNotClone]
|
||||
public IDictionary<string, object?> AdditionalData =>
|
||||
_additionalData ??= new Dictionary<string, object?>();
|
||||
|
||||
/// <inheritdoc />
|
||||
[IgnoreDataMember]
|
||||
public bool HasAdditionalData => _additionalData != null;
|
||||
|
||||
[DataMember]
|
||||
public string? Name
|
||||
{
|
||||
get => _name;
|
||||
set
|
||||
{
|
||||
if (_name != value)
|
||||
{
|
||||
// if the name has changed, add the value to the additional data,
|
||||
// this is required purely for event handlers to know the previous name of the group
|
||||
// so we can keep the public access up to date.
|
||||
AdditionalData["previousName"] = _name;
|
||||
}
|
||||
|
||||
SetPropertyValueAndDetectChanges(value, ref _name, nameof(Name));
|
||||
}
|
||||
set => SetPropertyValueAndDetectChanges(value, ref _name, nameof(Name));
|
||||
}
|
||||
|
||||
[DataMember]
|
||||
|
||||
Reference in New Issue
Block a user