From 6b9adfa929e76abb34172d6c954241ebb55077ae Mon Sep 17 00:00:00 2001 From: Stephan Date: Sat, 21 Apr 2018 11:11:31 +0200 Subject: [PATCH] Move IsCultureAvailable to IContentBase --- src/Umbraco.Core/Models/Content.cs | 4 -- src/Umbraco.Core/Models/ContentBase.cs | 54 ++++++++++++++----------- src/Umbraco.Core/Models/IContent.cs | 9 ----- src/Umbraco.Core/Models/IContentBase.cs | 11 ++++- 4 files changed, 41 insertions(+), 37 deletions(-) diff --git a/src/Umbraco.Core/Models/Content.cs b/src/Umbraco.Core/Models/Content.cs index 1f106124b4..bb2192f187 100644 --- a/src/Umbraco.Core/Models/Content.cs +++ b/src/Umbraco.Core/Models/Content.cs @@ -253,10 +253,6 @@ namespace Umbraco.Core.Models PublishName = null; _publishNames = null; } - - /// - public bool IsCultureAvailable(string culture) - => !string.IsNullOrWhiteSpace(GetName(culture)); /// public bool IsCulturePublished(string culture) diff --git a/src/Umbraco.Core/Models/ContentBase.cs b/src/Umbraco.Core/Models/ContentBase.cs index 32a26f9dc0..ca5f9024a7 100644 --- a/src/Umbraco.Core/Models/ContentBase.cs +++ b/src/Umbraco.Core/Models/ContentBase.cs @@ -121,6 +121,22 @@ namespace Umbraco.Core.Models } } + /// + /// Gets the enumeration of property groups for the entity. + /// fixme is a proxy, kill this + /// + [IgnoreDataMember] + public IEnumerable PropertyGroups => ContentTypeBase.CompositionPropertyGroups; + + /// + /// Gets the numeration of property types for the entity. + /// fixme is a proxy, kill this + /// + [IgnoreDataMember] + public IEnumerable PropertyTypes => ContentTypeBase.CompositionPropertyTypes; + + #region Cultures + /// [DataMember] public virtual IReadOnlyDictionary Names @@ -140,7 +156,7 @@ namespace Umbraco.Core.Models { ClearName(culture); return; - } + } if (culture == null) { @@ -158,6 +174,18 @@ namespace Umbraco.Core.Models OnPropertyChanged(Ps.Value.NamesSelector); } + /// + public virtual string GetName(string culture) + { + if (culture == null) return Name; + if (_names == null) return null; + return _names.TryGetValue(culture, out var name) ? name : null; + } + + /// + public bool IsCultureAvailable(string culture) + => !string.IsNullOrWhiteSpace(GetName(culture)); + private void ClearName(string culture) { if (culture == null) @@ -177,28 +205,8 @@ namespace Umbraco.Core.Models _names = null; OnPropertyChanged(Ps.Value.NamesSelector); } - - /// - public virtual string GetName(string culture) - { - if (culture == null) return Name; - if (_names == null) return null; - return _names.TryGetValue(culture, out var name) ? name : null; - } - - /// - /// Gets the enumeration of property groups for the entity. - /// fixme is a proxy, kill this - /// - [IgnoreDataMember] - public IEnumerable PropertyGroups => ContentTypeBase.CompositionPropertyGroups; - - /// - /// Gets the numeration of property types for the entity. - /// fixme is a proxy, kill this - /// - [IgnoreDataMember] - public IEnumerable PropertyTypes => ContentTypeBase.CompositionPropertyTypes; + + #endregion #region Has, Get, Set, Publish Property Value diff --git a/src/Umbraco.Core/Models/IContent.cs b/src/Umbraco.Core/Models/IContent.cs index 3df81f7314..69e01f4963 100644 --- a/src/Umbraco.Core/Models/IContent.cs +++ b/src/Umbraco.Core/Models/IContent.cs @@ -80,15 +80,6 @@ namespace Umbraco.Core.Models /// ContentStatus Status { get; } - /// - /// Gets a value indicating whether a given culture is available. - /// - /// - /// A culture becomes available whenever the content name for this culture is - /// non-null, and it becomes unavailable whenever the content name is null. - /// - bool IsCultureAvailable(string culture); - /// /// Gets a value indicating whether a given culture is published. /// diff --git a/src/Umbraco.Core/Models/IContentBase.cs b/src/Umbraco.Core/Models/IContentBase.cs index f8bb0e6985..93a6e82ada 100644 --- a/src/Umbraco.Core/Models/IContentBase.cs +++ b/src/Umbraco.Core/Models/IContentBase.cs @@ -51,9 +51,18 @@ namespace Umbraco.Core.Models /// /// Because a dictionary key cannot be null this cannot get nor set the invariant /// name, which must be get or set via the property. - /// + /// IReadOnlyDictionary Names { get; set; } + /// + /// Gets a value indicating whether a given culture is available. + /// + /// + /// A culture becomes available whenever the content name for this culture is + /// non-null, and it becomes unavailable whenever the content name is null. + /// + bool IsCultureAvailable(string culture); + /// /// List of properties, which make up all the data available for this Content object ///