Moves more stuff
This commit is contained in:
@@ -1,82 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using Umbraco.Core.Models.Entities;
|
||||
|
||||
namespace Umbraco.Core.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a Dictionary Item
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[DataContract(IsReference = true)]
|
||||
public class DictionaryItem : EntityBase, IDictionaryItem
|
||||
{
|
||||
public Func<int, ILanguage> GetLanguage { get; set; }
|
||||
private Guid? _parentId;
|
||||
private string _itemKey;
|
||||
private IEnumerable<IDictionaryTranslation> _translations;
|
||||
|
||||
public DictionaryItem(string itemKey)
|
||||
: this(null, itemKey)
|
||||
{}
|
||||
|
||||
public DictionaryItem(Guid? parentId, string itemKey)
|
||||
{
|
||||
_parentId = parentId;
|
||||
_itemKey = itemKey;
|
||||
_translations = new List<IDictionaryTranslation>();
|
||||
}
|
||||
|
||||
//Custom comparer for enumerable
|
||||
private static readonly DelegateEqualityComparer<IEnumerable<IDictionaryTranslation>> DictionaryTranslationComparer =
|
||||
new DelegateEqualityComparer<IEnumerable<IDictionaryTranslation>>(
|
||||
(enumerable, translations) => enumerable.UnsortedSequenceEqual(translations),
|
||||
enumerable => enumerable.GetHashCode());
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets the Parent Id of the Dictionary Item
|
||||
/// </summary>
|
||||
[DataMember]
|
||||
public Guid? ParentId
|
||||
{
|
||||
get { return _parentId; }
|
||||
set { SetPropertyValueAndDetectChanges(value, ref _parentId, nameof(ParentId)); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Key for the Dictionary Item
|
||||
/// </summary>
|
||||
[DataMember]
|
||||
public string ItemKey
|
||||
{
|
||||
get { return _itemKey; }
|
||||
set { SetPropertyValueAndDetectChanges(value, ref _itemKey, nameof(ItemKey)); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a list of translations for the Dictionary Item
|
||||
/// </summary>
|
||||
[DataMember]
|
||||
public IEnumerable<IDictionaryTranslation> Translations
|
||||
{
|
||||
get { return _translations; }
|
||||
set
|
||||
{
|
||||
var asArray = value.ToArray();
|
||||
//ensure the language callback is set on each translation
|
||||
if (GetLanguage != null)
|
||||
{
|
||||
foreach (var translation in asArray.OfType<DictionaryTranslation>())
|
||||
{
|
||||
translation.GetLanguage = GetLanguage;
|
||||
}
|
||||
}
|
||||
|
||||
SetPropertyValueAndDetectChanges(asArray, ref _translations, nameof(Translations),
|
||||
DictionaryTranslationComparer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
using System.Linq;
|
||||
|
||||
namespace Umbraco.Core.Models
|
||||
{
|
||||
public static class DictionaryItemExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the translation value for the language id, if no translation is found it returns an empty string
|
||||
/// </summary>
|
||||
/// <param name="d"></param>
|
||||
/// <param name="languageId"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetTranslatedValue(this IDictionaryItem d, int languageId)
|
||||
{
|
||||
var trans = d.Translations.FirstOrDefault(x => x.LanguageId == languageId);
|
||||
return trans == null ? string.Empty : trans.Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the default translated value based on the default language
|
||||
/// </summary>
|
||||
/// <param name="d"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetDefaultValue(this IDictionaryItem d)
|
||||
{
|
||||
var defaultTranslation = d.Translations.FirstOrDefault(x => x.Language.Id == 1);
|
||||
return defaultTranslation == null ? string.Empty : defaultTranslation.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,107 +0,0 @@
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
using Umbraco.Core.Models.Entities;
|
||||
|
||||
namespace Umbraco.Core.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a translation for a <see cref="DictionaryItem"/>
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[DataContract(IsReference = true)]
|
||||
public class DictionaryTranslation : EntityBase, IDictionaryTranslation
|
||||
{
|
||||
internal Func<int, ILanguage> GetLanguage { get; set; }
|
||||
|
||||
private ILanguage _language;
|
||||
private string _value;
|
||||
//note: this will be memberwise cloned
|
||||
private int _languageId;
|
||||
|
||||
public DictionaryTranslation(ILanguage language, string value)
|
||||
{
|
||||
if (language == null) throw new ArgumentNullException("language");
|
||||
_language = language;
|
||||
_languageId = _language.Id;
|
||||
_value = value;
|
||||
}
|
||||
|
||||
public DictionaryTranslation(ILanguage language, string value, Guid uniqueId)
|
||||
{
|
||||
if (language == null) throw new ArgumentNullException("language");
|
||||
_language = language;
|
||||
_languageId = _language.Id;
|
||||
_value = value;
|
||||
Key = uniqueId;
|
||||
}
|
||||
|
||||
internal DictionaryTranslation(int languageId, string value)
|
||||
{
|
||||
_languageId = languageId;
|
||||
_value = value;
|
||||
}
|
||||
|
||||
internal DictionaryTranslation(int languageId, string value, Guid uniqueId)
|
||||
{
|
||||
_languageId = languageId;
|
||||
_value = value;
|
||||
Key = uniqueId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="Language"/> for the translation
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Marked as DoNotClone - TODO: this member shouldn't really exist here in the first place, the DictionaryItem
|
||||
/// class will have a deep hierarchy of objects which all get deep cloned which we don't want. This should have simply
|
||||
/// just referenced a language ID not the actual language object. In v8 we need to fix this.
|
||||
/// We're going to have to do the same hacky stuff we had to do with the Template/File contents so that this is returned
|
||||
/// on a callback.
|
||||
/// </remarks>
|
||||
[DataMember]
|
||||
[DoNotClone]
|
||||
public ILanguage Language
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_language != null)
|
||||
return _language;
|
||||
|
||||
// else, must lazy-load
|
||||
if (GetLanguage != null && _languageId > 0)
|
||||
_language = GetLanguage(_languageId);
|
||||
return _language;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetPropertyValueAndDetectChanges(value, ref _language, nameof(Language));
|
||||
_languageId = _language == null ? -1 : _language.Id;
|
||||
}
|
||||
}
|
||||
|
||||
public int LanguageId
|
||||
{
|
||||
get { return _languageId; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the translated text
|
||||
/// </summary>
|
||||
[DataMember]
|
||||
public string Value
|
||||
{
|
||||
get { return _value; }
|
||||
set { SetPropertyValueAndDetectChanges(value, ref _value, nameof(Value)); }
|
||||
}
|
||||
|
||||
protected override void PerformDeepClone(object clone)
|
||||
{
|
||||
base.PerformDeepClone(clone);
|
||||
|
||||
var clonedEntity = (DictionaryTranslation)clone;
|
||||
|
||||
// clear fields that were memberwise-cloned and that we don't want to clone
|
||||
clonedEntity._language = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
using Umbraco.Core.Models.Entities;
|
||||
|
||||
namespace Umbraco.Core.Models
|
||||
{
|
||||
public static class EntityExtensions
|
||||
{
|
||||
/// <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,157 +0,0 @@
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
using Umbraco.Core.Models.Entities;
|
||||
|
||||
namespace Umbraco.Core.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a Macro Property
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[DataContract(IsReference = true)]
|
||||
public class MacroProperty : BeingDirtyBase, IMacroProperty, IRememberBeingDirty, IDeepCloneable
|
||||
{
|
||||
public MacroProperty()
|
||||
{
|
||||
_key = Guid.NewGuid();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ctor for creating a new property
|
||||
/// </summary>
|
||||
/// <param name="alias"></param>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="sortOrder"></param>
|
||||
/// <param name="editorAlias"></param>
|
||||
public MacroProperty(string @alias, string name, int sortOrder, string editorAlias)
|
||||
{
|
||||
_alias = alias;
|
||||
_name = name;
|
||||
_sortOrder = sortOrder;
|
||||
_key = Guid.NewGuid();
|
||||
_editorAlias = editorAlias;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ctor for creating an existing property
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="alias"></param>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="sortOrder"></param>
|
||||
/// <param name="editorAlias"></param>
|
||||
internal MacroProperty(int id, Guid key, string @alias, string name, int sortOrder, string editorAlias)
|
||||
{
|
||||
_id = id;
|
||||
_alias = alias;
|
||||
_name = name;
|
||||
_sortOrder = sortOrder;
|
||||
_key = key;
|
||||
_editorAlias = editorAlias;
|
||||
}
|
||||
|
||||
private Guid _key;
|
||||
private string _alias;
|
||||
private string _name;
|
||||
private int _sortOrder;
|
||||
private int _id;
|
||||
private string _editorAlias;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Key of the Property
|
||||
/// </summary>
|
||||
[DataMember]
|
||||
public Guid Key
|
||||
{
|
||||
get => _key;
|
||||
set => SetPropertyValueAndDetectChanges(value, ref _key, nameof(Key));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Alias of the Property
|
||||
/// </summary>
|
||||
[DataMember]
|
||||
public int Id
|
||||
{
|
||||
get => _id;
|
||||
set => SetPropertyValueAndDetectChanges(value, ref _id, nameof(Id));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Alias of the Property
|
||||
/// </summary>
|
||||
[DataMember]
|
||||
public string Alias
|
||||
{
|
||||
get => _alias;
|
||||
set => SetPropertyValueAndDetectChanges(value, ref _alias, nameof(Alias));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Name of the Property
|
||||
/// </summary>
|
||||
[DataMember]
|
||||
public string Name
|
||||
{
|
||||
get => _name;
|
||||
set => SetPropertyValueAndDetectChanges(value, ref _name, nameof(Name));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Sort Order of the Property
|
||||
/// </summary>
|
||||
[DataMember]
|
||||
public int SortOrder
|
||||
{
|
||||
get => _sortOrder;
|
||||
set => SetPropertyValueAndDetectChanges(value, ref _sortOrder, nameof(SortOrder));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Type for this Property
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The MacroPropertyTypes acts as a plugin for Macros.
|
||||
/// All types was previously contained in the database, but has been ported to code.
|
||||
/// </remarks>
|
||||
[DataMember]
|
||||
public string EditorAlias
|
||||
{
|
||||
get => _editorAlias;
|
||||
set => SetPropertyValueAndDetectChanges(value, ref _editorAlias, nameof(EditorAlias));
|
||||
}
|
||||
|
||||
public object DeepClone()
|
||||
{
|
||||
//Memberwise clone on MacroProperty 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 clone = (MacroProperty)MemberwiseClone();
|
||||
//Automatically deep clone ref properties that are IDeepCloneable
|
||||
DeepCloneHelper.DeepCloneRefProperties(this, clone);
|
||||
clone.ResetDirtyProperties(false);
|
||||
return clone;
|
||||
}
|
||||
|
||||
protected bool Equals(MacroProperty other)
|
||||
{
|
||||
return string.Equals(_alias, other._alias) && _id == other._id;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (ReferenceEquals(null, obj)) return false;
|
||||
if (ReferenceEquals(this, obj)) return true;
|
||||
if (obj.GetType() != this.GetType()) return false;
|
||||
return Equals((MacroProperty) obj);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
return ((_alias != null ? _alias.GetHashCode() : 0)*397) ^ _id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
using Umbraco.Core.Models.Entities;
|
||||
|
||||
namespace Umbraco.Core.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a member type
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[DataContract(IsReference = true)]
|
||||
public class MemberGroup : EntityBase, IMemberGroup
|
||||
{
|
||||
private IDictionary<string, object> _additionalData;
|
||||
private string _name;
|
||||
private int _creatorId;
|
||||
|
||||
/// <inheritdoc />
|
||||
[DataMember]
|
||||
[DoNotClone]
|
||||
public IDictionary<string, object> AdditionalData => _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));
|
||||
}
|
||||
}
|
||||
|
||||
[DataMember]
|
||||
public int CreatorId
|
||||
{
|
||||
get => _creatorId;
|
||||
set => SetPropertyValueAndDetectChanges(value, ref _creatorId, nameof(CreatorId));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
namespace Umbraco.Core.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Used to track the property types that are visible/editable on member profiles
|
||||
/// </summary>
|
||||
internal class MemberTypePropertyProfileAccess
|
||||
{
|
||||
public MemberTypePropertyProfileAccess(bool isVisible, bool isEditable, bool isSenstive)
|
||||
{
|
||||
IsVisible = isVisible;
|
||||
IsEditable = isEditable;
|
||||
IsSensitive = isSenstive;
|
||||
}
|
||||
|
||||
public bool IsVisible { get; set; }
|
||||
public bool IsEditable { get; set; }
|
||||
public bool IsSensitive { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Umbraco.Core.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a paged result for a model collection
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
[DataContract(Name = "pagedCollection", Namespace = "")]
|
||||
public class PagedResult<T> : PagedResult
|
||||
{
|
||||
public PagedResult(long totalItems, long pageNumber, long pageSize)
|
||||
: base(totalItems, pageNumber, pageSize)
|
||||
{ }
|
||||
|
||||
[DataMember(Name = "items")]
|
||||
public IEnumerable<T> Items { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,156 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using Umbraco.Core.Models.Entities;
|
||||
|
||||
namespace Umbraco.Core.Models
|
||||
{
|
||||
[Serializable]
|
||||
[DataContract(IsReference = true)]
|
||||
public class PublicAccessEntry : EntityBase
|
||||
{
|
||||
private readonly ObservableCollection<PublicAccessRule> _ruleCollection;
|
||||
private int _protectedNodeId;
|
||||
private int _noAccessNodeId;
|
||||
private int _loginNodeId;
|
||||
private readonly List<Guid> _removedRules = new List<Guid>();
|
||||
|
||||
public PublicAccessEntry(IContent protectedNode, IContent loginNode, IContent noAccessNode, IEnumerable<PublicAccessRule> ruleCollection)
|
||||
{
|
||||
if (protectedNode == null) throw new ArgumentNullException(nameof(protectedNode));
|
||||
if (loginNode == null) throw new ArgumentNullException(nameof(loginNode));
|
||||
if (noAccessNode == null) throw new ArgumentNullException(nameof(noAccessNode));
|
||||
|
||||
LoginNodeId = loginNode.Id;
|
||||
NoAccessNodeId = noAccessNode.Id;
|
||||
_protectedNodeId = protectedNode.Id;
|
||||
|
||||
_ruleCollection = new ObservableCollection<PublicAccessRule>(ruleCollection);
|
||||
_ruleCollection.CollectionChanged += _ruleCollection_CollectionChanged;
|
||||
|
||||
foreach (var rule in _ruleCollection)
|
||||
rule.AccessEntryId = Key;
|
||||
}
|
||||
|
||||
public PublicAccessEntry(Guid id, int protectedNodeId, int loginNodeId, int noAccessNodeId, IEnumerable<PublicAccessRule> ruleCollection)
|
||||
{
|
||||
Key = id;
|
||||
Id = Key.GetHashCode();
|
||||
|
||||
LoginNodeId = loginNodeId;
|
||||
NoAccessNodeId = noAccessNodeId;
|
||||
_protectedNodeId = protectedNodeId;
|
||||
|
||||
_ruleCollection = new ObservableCollection<PublicAccessRule>(ruleCollection);
|
||||
_ruleCollection.CollectionChanged += _ruleCollection_CollectionChanged;
|
||||
|
||||
foreach (var rule in _ruleCollection)
|
||||
rule.AccessEntryId = Key;
|
||||
}
|
||||
|
||||
void _ruleCollection_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
OnPropertyChanged(nameof(Rules));
|
||||
|
||||
//if (e.Action == NotifyCollectionChangedAction.Add)
|
||||
//{
|
||||
// var item = e.NewItems.Cast<PublicAccessRule>().First();
|
||||
|
||||
// if (_addedSections.Contains(item) == false)
|
||||
// {
|
||||
// _addedSections.Add(item);
|
||||
// }
|
||||
//}
|
||||
|
||||
if (e.Action == NotifyCollectionChangedAction.Remove)
|
||||
{
|
||||
var item = e.OldItems.Cast<PublicAccessRule>().First();
|
||||
|
||||
if (_removedRules.Contains(item.Key) == false)
|
||||
{
|
||||
_removedRules.Add(item.Key);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
internal IEnumerable<Guid> RemovedRules => _removedRules;
|
||||
|
||||
public IEnumerable<PublicAccessRule> Rules => _ruleCollection;
|
||||
|
||||
public PublicAccessRule AddRule(string ruleValue, string ruleType)
|
||||
{
|
||||
var rule = new PublicAccessRule
|
||||
{
|
||||
AccessEntryId = Key,
|
||||
RuleValue = ruleValue,
|
||||
RuleType = ruleType
|
||||
};
|
||||
_ruleCollection.Add(rule);
|
||||
return rule;
|
||||
}
|
||||
|
||||
public void RemoveRule(PublicAccessRule rule)
|
||||
{
|
||||
_ruleCollection.Remove(rule);
|
||||
}
|
||||
|
||||
public void ClearRules()
|
||||
{
|
||||
_ruleCollection.Clear();
|
||||
}
|
||||
|
||||
|
||||
internal void ClearRemovedRules()
|
||||
{
|
||||
_removedRules.Clear();
|
||||
}
|
||||
|
||||
[DataMember]
|
||||
public int LoginNodeId
|
||||
{
|
||||
get => _loginNodeId;
|
||||
set => SetPropertyValueAndDetectChanges(value, ref _loginNodeId, nameof(LoginNodeId));
|
||||
}
|
||||
|
||||
[DataMember]
|
||||
public int NoAccessNodeId
|
||||
{
|
||||
get => _noAccessNodeId;
|
||||
set => SetPropertyValueAndDetectChanges(value, ref _noAccessNodeId, nameof(NoAccessNodeId));
|
||||
}
|
||||
|
||||
[DataMember]
|
||||
public int ProtectedNodeId
|
||||
{
|
||||
get => _protectedNodeId;
|
||||
set => SetPropertyValueAndDetectChanges(value, ref _protectedNodeId, nameof(ProtectedNodeId));
|
||||
}
|
||||
|
||||
public override void ResetDirtyProperties(bool rememberDirty)
|
||||
{
|
||||
_removedRules.Clear();
|
||||
base.ResetDirtyProperties(rememberDirty);
|
||||
foreach (var publicAccessRule in _ruleCollection)
|
||||
{
|
||||
publicAccessRule.ResetDirtyProperties(rememberDirty);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void PerformDeepClone(object clone)
|
||||
{
|
||||
base.PerformDeepClone(clone);
|
||||
|
||||
var cloneEntity = (PublicAccessEntry)clone;
|
||||
|
||||
if (cloneEntity._ruleCollection != null)
|
||||
{
|
||||
cloneEntity._ruleCollection.CollectionChanged -= _ruleCollection_CollectionChanged; //clear this event handler if any
|
||||
cloneEntity._ruleCollection.CollectionChanged += cloneEntity._ruleCollection_CollectionChanged; //re-assign correct event handler
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
using Umbraco.Core.Models.Entities;
|
||||
|
||||
namespace Umbraco.Core.Models
|
||||
{
|
||||
[Serializable]
|
||||
[DataContract(IsReference = true)]
|
||||
public class UmbracoDomain : EntityBase, IDomain
|
||||
{
|
||||
public UmbracoDomain(string domainName)
|
||||
{
|
||||
_domainName = domainName;
|
||||
}
|
||||
|
||||
public UmbracoDomain(string domainName, string languageIsoCode)
|
||||
: this(domainName)
|
||||
{
|
||||
LanguageIsoCode = languageIsoCode;
|
||||
}
|
||||
|
||||
private int? _contentId;
|
||||
private int? _languageId;
|
||||
private string _domainName;
|
||||
|
||||
[DataMember]
|
||||
public int? LanguageId
|
||||
{
|
||||
get => _languageId;
|
||||
set => SetPropertyValueAndDetectChanges(value, ref _languageId, nameof(LanguageId));
|
||||
}
|
||||
|
||||
[DataMember]
|
||||
public string DomainName
|
||||
{
|
||||
get => _domainName;
|
||||
set => SetPropertyValueAndDetectChanges(value, ref _domainName, nameof(DomainName));
|
||||
}
|
||||
|
||||
[DataMember]
|
||||
public int? RootContentId
|
||||
{
|
||||
get => _contentId;
|
||||
set => SetPropertyValueAndDetectChanges(value, ref _contentId, nameof(RootContentId));
|
||||
}
|
||||
|
||||
public bool IsWildcard => string.IsNullOrWhiteSpace(DomainName) || DomainName.StartsWith("*");
|
||||
|
||||
/// <summary>
|
||||
/// Readonly value of the language ISO code for the domain
|
||||
/// </summary>
|
||||
public string LanguageIsoCode { get; internal set; }
|
||||
}
|
||||
}
|
||||
@@ -16,35 +16,7 @@ namespace Umbraco.Core.Models
|
||||
{
|
||||
public static class UserExtensions
|
||||
{
|
||||
public static IEnumerable<string> GetPermissions(this IUser user, string path, IUserService userService)
|
||||
{
|
||||
return userService.GetPermissionsForPath(user, path).GetAllPermissions();
|
||||
}
|
||||
|
||||
public static bool HasSectionAccess(this IUser user, string app)
|
||||
{
|
||||
var apps = user.AllowedSections;
|
||||
return apps.Any(uApp => uApp.InvariantEquals(app));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether this user is the 'super' user.
|
||||
/// </summary>
|
||||
public static bool IsSuper(this IUser user)
|
||||
{
|
||||
if (user == null) throw new ArgumentNullException(nameof(user));
|
||||
return user.Id == Constants.Security.SuperUserId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether this user belongs to the administrators group.
|
||||
/// </summary>
|
||||
/// <remarks>The 'super' user does not automatically belongs to the administrators group.</remarks>
|
||||
public static bool IsAdmin(this IUser user)
|
||||
{
|
||||
if (user == null) throw new ArgumentNullException(nameof(user));
|
||||
return user.Groups != null && user.Groups.Any(x => x.Alias == Constants.Security.AdminGroupAlias);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Tries to lookup the user's Gravatar to see if the endpoint can be reached, if so it returns the valid URL
|
||||
@@ -117,37 +89,7 @@ namespace Umbraco.Core.Models
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the culture info associated with this user, based on the language they're assigned to in the back office
|
||||
/// </summary>
|
||||
/// <param name="user"></param>
|
||||
/// <param name="textService"></param>
|
||||
/// <param name="globalSettings"></param>
|
||||
/// <returns></returns>
|
||||
public static CultureInfo GetUserCulture(this IUser user, ILocalizedTextService textService, IGlobalSettings globalSettings)
|
||||
{
|
||||
if (user == null) throw new ArgumentNullException(nameof(user));
|
||||
if (textService == null) throw new ArgumentNullException(nameof(textService));
|
||||
return GetUserCulture(user.Language, textService, globalSettings);
|
||||
}
|
||||
|
||||
internal static CultureInfo GetUserCulture(string userLanguage, ILocalizedTextService textService, IGlobalSettings globalSettings)
|
||||
{
|
||||
try
|
||||
{
|
||||
var culture = CultureInfo.GetCultureInfo(userLanguage.Replace("_", "-"));
|
||||
// TODO: This is a hack because we store the user language as 2 chars instead of the full culture
|
||||
// which is actually stored in the language files (which are also named with 2 chars!) so we need to attempt
|
||||
// to convert to a supported full culture
|
||||
var result = textService.ConvertToSupportedCultureWithRegionCode(culture);
|
||||
return result;
|
||||
}
|
||||
catch (CultureNotFoundException)
|
||||
{
|
||||
//return the default one
|
||||
return CultureInfo.GetCultureInfo(globalSettings.DefaultUILanguage);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
internal static bool HasContentRootAccess(this IUser user, IEntityService entityService)
|
||||
{
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
|
||||
namespace Umbraco.Core.Models.Validation
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies that a data field value is required in order to persist an object.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>There are two levels of validation in Umbraco. (1) value validation is performed by <see cref="IValueValidator"/>
|
||||
/// instances; it can prevent a content item from being published, but not from being saved. (2) required validation
|
||||
/// of properties marked with <see cref="RequiredForPersistenceAttribute"/>; it does prevent an object from being saved
|
||||
/// and is used for properties that are absolutely mandatory, such as the name of a content item.</para>
|
||||
/// </remarks>
|
||||
public class RequiredForPersistenceAttribute : RequiredAttribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Determines whether an object has all required values for persistence.
|
||||
/// </summary>
|
||||
internal static bool HasRequiredValuesForPersistence(object model)
|
||||
{
|
||||
return model.GetType().GetProperties().All(x =>
|
||||
{
|
||||
var a = x.GetCustomAttribute<RequiredForPersistenceAttribute>();
|
||||
return a == null || a.IsValid(x.GetValue(model));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user