From 40f7d820a624d403b7ee885c2dd7ed873d86a59f Mon Sep 17 00:00:00 2001 From: Shannon Date: Thu, 29 Dec 2016 11:36:39 +1100 Subject: [PATCH] publicizes a few APIs and adds more API docs --- .../Models/Editors/ContentPropertyData.cs | 8 +++++ .../Repositories/VersionableRepositoryBase.cs | 4 +-- .../PropertyEditors/TagValueType.cs | 3 +- src/Umbraco.Core/Services/TagExtractor.cs | 35 +++++++++++++++---- 4 files changed, 39 insertions(+), 11 deletions(-) diff --git a/src/Umbraco.Core/Models/Editors/ContentPropertyData.cs b/src/Umbraco.Core/Models/Editors/ContentPropertyData.cs index 14c8640fc9..3798cb08e0 100644 --- a/src/Umbraco.Core/Models/Editors/ContentPropertyData.cs +++ b/src/Umbraco.Core/Models/Editors/ContentPropertyData.cs @@ -16,6 +16,11 @@ namespace Umbraco.Core.Models.Editors /// public class ContentPropertyData { + public ContentPropertyData(object value, PreValueCollection preValues) + : this(value, preValues, new Dictionary()) + { + } + public ContentPropertyData(object value, PreValueCollection preValues, IDictionary additionalData) { Value = value; @@ -28,6 +33,9 @@ namespace Umbraco.Core.Models.Editors /// public object Value { get; private set; } + /// + /// The pre-value collection for the content property + /// public PreValueCollection PreValues { get; private set; } /// diff --git a/src/Umbraco.Core/Persistence/Repositories/VersionableRepositoryBase.cs b/src/Umbraco.Core/Persistence/Repositories/VersionableRepositoryBase.cs index ded026bbec..163e0810ad 100644 --- a/src/Umbraco.Core/Persistence/Repositories/VersionableRepositoryBase.cs +++ b/src/Umbraco.Core/Persistence/Repositories/VersionableRepositoryBase.cs @@ -561,9 +561,7 @@ WHERE EXISTS( var preVals = new PreValueCollection(asDictionary); - var contentPropData = new ContentPropertyData(property.Value, - preVals, - new Dictionary()); + var contentPropData = new ContentPropertyData(property.Value, preVals); TagExtractor.SetPropertyTags(property, contentPropData, property.Value, tagSupport); } diff --git a/src/Umbraco.Core/PropertyEditors/TagValueType.cs b/src/Umbraco.Core/PropertyEditors/TagValueType.cs index e5f65933ab..e837d1e8bf 100644 --- a/src/Umbraco.Core/PropertyEditors/TagValueType.cs +++ b/src/Umbraco.Core/PropertyEditors/TagValueType.cs @@ -14,7 +14,8 @@ /// The list of tags will be supplied by the property editor's ConvertEditorToDb method result which will need to return an IEnumerable{string} value /// /// - /// if the ConvertEditorToDb doesn't return an IEnumerable{string} then an exception will be thrown. + /// if the ConvertEditorToDb doesn't return an IEnumerable{string} then it will automatically try to be detected as either CSV or JSON and if neither of those match + /// an exception will be thrown. /// CustomTagList } diff --git a/src/Umbraco.Core/Services/TagExtractor.cs b/src/Umbraco.Core/Services/TagExtractor.cs index 0e6d605e41..aa88a9a1aa 100644 --- a/src/Umbraco.Core/Services/TagExtractor.cs +++ b/src/Umbraco.Core/Services/TagExtractor.cs @@ -9,10 +9,15 @@ using Umbraco.Core.PropertyEditors; namespace Umbraco.Core.Services { /// - /// A simple utility class to extract the tag values from a property/property editor and set them on the content + /// A utility class to extract the tag values from a property/property editor and set them on the content /// - internal class TagExtractor + public class TagExtractor { + /// + /// Will return the for the given + /// + /// + /// public static SupportTagsAttribute GetAttribute(PropertyEditor propEd) { if (propEd == null) return null; @@ -23,9 +28,12 @@ namespace Umbraco.Core.Services /// /// Sets the tag values on the content property based on the property editor's tags attribute /// - /// - /// - /// + /// The content's Property + /// The data that has been submitted to be saved for a content property + /// + /// If the is then this is expected to be a delimited string, + /// otherwise if it is then this is expected to be IEnumerable{string} + /// /// public static void SetPropertyTags(Property property, ContentPropertyData propertyData, object convertedPropertyValue, SupportTagsAttribute attribute) { @@ -51,7 +59,20 @@ namespace Umbraco.Core.Services } } - public static void SetPropertyTags(Property property, object convertedPropertyValue, string delimiter, bool replaceTags, string tagGroup, TagValueType valueType, TagCacheStorageType storageType) + /// + /// Sets the tag values on the content property based on the property editor's tags attribute + /// + /// The content's Property + /// + /// If the is then this is expected to be a delimited string, + /// otherwise if it is then this is expected to be IEnumerable{string} + /// + /// The delimiter for the value if convertedPropertyValue is a string delimited value + /// Whether or not to replace the tags with the new value or append them (true to replace, false to append) + /// The tag group to use when tagging + /// Defines how the tag values will be extracted + /// Defines how to store the tags in cache (CSV or Json) + internal static void SetPropertyTags(Property property, object convertedPropertyValue, string delimiter, bool replaceTags, string tagGroup, TagValueType valueType, TagCacheStorageType storageType) { if (convertedPropertyValue == null) { @@ -65,7 +86,7 @@ namespace Umbraco.Core.Services property.SetTags(storageType, property.Alias, tags, replaceTags, tagGroup); break; case TagValueType.CustomTagList: - //for this to work the object value must be IENumerable + //for this to work the object value must be IEnumerable var stringList = convertedPropertyValue as IEnumerable; if (stringList != null) {