Simplifies the interface inheritance removes SimpleContentTypeMapper (can't be used), improves how mappers are looked up, simplifies other models
This commit is contained in:
@@ -44,16 +44,13 @@ namespace Umbraco.Core.Models
|
||||
// property variation change?
|
||||
var hasAnyPropertyVariationChanged = contentType.PropertyTypes.Any(propertyType =>
|
||||
{
|
||||
if (!(propertyType is IRememberBeingDirty dirtyProperty))
|
||||
throw new Exception("oops");
|
||||
|
||||
// skip new properties
|
||||
// TODO: This used to be WasPropertyDirty("HasIdentity") but i don't think that actually worked for detecting new entities this does seem to work properly
|
||||
var isNewProperty = dirtyProperty.WasPropertyDirty("Id");
|
||||
var isNewProperty = propertyType.WasPropertyDirty("Id");
|
||||
if (isNewProperty) return false;
|
||||
|
||||
// variation change?
|
||||
var dirty = dirtyProperty.WasPropertyDirty("Variations");
|
||||
var dirty = propertyType.WasPropertyDirty("Variations");
|
||||
if (dirty)
|
||||
a.Add(propertyType.Alias);
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Specialized;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Models.Entities;
|
||||
@@ -403,6 +404,18 @@ namespace Umbraco.Core.Models.Identity
|
||||
_beingDirty.EnableChangeTracking();
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged
|
||||
{
|
||||
add
|
||||
{
|
||||
_beingDirty.PropertyChanged += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_beingDirty.PropertyChanged -= value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
//Custom comparer for enumerables
|
||||
@@ -413,5 +426,6 @@ namespace Umbraco.Core.Models.Identity
|
||||
private static readonly DelegateEqualityComparer<int[]> StartIdsComparer = new DelegateEqualityComparer<int[]>(
|
||||
(groups, enumerable) => groups.UnsortedSequenceEqual(enumerable),
|
||||
groups => groups.GetHashCode());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Umbraco.Core.Models.Entities;
|
||||
|
||||
namespace Umbraco.Core.Models
|
||||
{
|
||||
@@ -37,6 +35,7 @@ namespace Umbraco.Core.Models
|
||||
if (contentType == null) throw new ArgumentNullException(nameof(contentType));
|
||||
|
||||
Id = contentType.Id;
|
||||
Key = contentType.Key;
|
||||
Alias = contentType.Alias;
|
||||
Variations = contentType.Variations;
|
||||
Icon = contentType.Icon;
|
||||
@@ -46,32 +45,26 @@ namespace Umbraco.Core.Models
|
||||
IsElement = contentType.IsElement;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Alias { get; }
|
||||
|
||||
public int Id { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public Guid Key { get; }
|
||||
|
||||
public ITemplate DefaultTemplate { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public ContentVariation Variations { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Icon { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool IsContainer { get; }
|
||||
|
||||
public string Name { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool AllowedAsRoot { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool IsElement { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool SupportsPropertyVariation(string culture, string segment, bool wildcards = false)
|
||||
{
|
||||
// non-exact validation: can accept a 'null' culture if the property type varies
|
||||
@@ -85,7 +78,6 @@ namespace Umbraco.Core.Models
|
||||
return string.Equals(Alias, other.Alias) && Id == other.Id;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (ReferenceEquals(null, obj)) return false;
|
||||
@@ -94,7 +86,6 @@ namespace Umbraco.Core.Models
|
||||
return Equals((SimpleContentType) obj);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override int GetHashCode()
|
||||
{
|
||||
unchecked
|
||||
@@ -102,37 +93,5 @@ namespace Umbraco.Core.Models
|
||||
return ((Alias != null ? Alias.GetHashCode() : 0) * 397) ^ Id;
|
||||
}
|
||||
}
|
||||
|
||||
// we have to have all this, because we're an IUmbracoEntity, because that is
|
||||
// required by the query expression visitor / SimpleContentTypeMapper
|
||||
// TODO: Make the query expression visitor use a different common interface, or investigate removing IRememberBeingDirty from being a requirement on that interface and expliclty checking for that throughout the code?
|
||||
|
||||
string ITreeEntity.Name { get => this.Name; set => throw new NotImplementedException(); }
|
||||
int IEntity.Id { get => this.Id; set => throw new NotImplementedException(); }
|
||||
bool IEntity.HasIdentity => this.Id != default;
|
||||
void IEntity.ResetIdentity() => throw new NotImplementedException();
|
||||
int ITreeEntity.CreatorId { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
int ITreeEntity.ParentId { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
int ITreeEntity.Level { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
string ITreeEntity.Path { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
int ITreeEntity.SortOrder { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
bool ITreeEntity.Trashed => throw new NotImplementedException();
|
||||
Guid IEntity.Key { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
DateTime IEntity.CreateDate { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
DateTime IEntity.UpdateDate { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
DateTime? IEntity.DeleteDate { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
void ITreeEntity.SetParent(ITreeEntity parent) => throw new NotImplementedException();
|
||||
object IDeepCloneable.DeepClone() => throw new NotImplementedException();
|
||||
bool IRememberBeingDirty.WasDirty() => throw new NotImplementedException();
|
||||
bool IRememberBeingDirty.WasPropertyDirty(string propertyName) => throw new NotImplementedException();
|
||||
void IRememberBeingDirty.ResetWereDirtyProperties() => throw new NotImplementedException();
|
||||
void IRememberBeingDirty.ResetDirtyProperties(bool rememberDirty) => throw new NotImplementedException();
|
||||
IEnumerable<string> IRememberBeingDirty.GetWereDirtyProperties() => throw new NotImplementedException();
|
||||
bool ICanBeDirty.IsDirty() => throw new NotImplementedException();
|
||||
bool ICanBeDirty.IsPropertyDirty(string propName) => throw new NotImplementedException();
|
||||
IEnumerable<string> ICanBeDirty.GetDirtyProperties() => throw new NotImplementedException();
|
||||
void ICanBeDirty.ResetDirtyProperties() => throw new NotImplementedException();
|
||||
public void DisableChangeTracking() => throw new NotImplementedException();
|
||||
public void EnableChangeTracking() => throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user