From fb18317c0f67ec876c578148e65821a67645aa97 Mon Sep 17 00:00:00 2001 From: Bjarke Berg Date: Fri, 4 Dec 2020 19:01:52 +0100 Subject: [PATCH] Moved lots of property editors into core --- .../PropertyEditors/BlockListConfiguration.cs | 29 ++++++----- .../PropertyEditors/DataEditor.cs | 16 ++++-- .../PropertyEditors/DataValueEditor.cs | 39 +++++++++----- .../PropertyEditors/DateValueEditor.cs | 11 +++- .../PropertyEditors/DecimalPropertyEditor.cs | 6 ++- .../PropertyEditors/IntegerPropertyEditor.cs | 11 +++- .../MemberGroupPickerPropertyEditor.cs | 6 ++- .../MemberPickerPropertyEditor.cs | 6 ++- .../ContentTypeParameterEditor.cs | 6 ++- .../MultipleContentPickerParameterEditor.cs | 6 ++- .../MultipleContentTypeParameterEditor.cs | 6 ++- .../MultipleMediaPickerParameterEditor.cs | 10 ++-- .../MultiplePropertyGroupParameterEditor.cs | 6 ++- .../MultiplePropertyTypeParameterEditor.cs | 6 ++- .../PropertyGroupParameterEditor.cs | 6 ++- .../PropertyTypeParameterEditor.cs | 6 ++- .../PropertyEditors/RichTextConfiguration.cs | 5 +- .../PropertyEditors/TextOnlyValueEditor.cs | 11 +++- .../UserPickerPropertyEditor.cs | 6 ++- ...omplexEditorElementTypeValidationResult.cs | 0 ...mplexEditorPropertyTypeValidationResult.cs | 0 .../ComplexEditorValidationResult.cs | 0 .../MemberPickerValueConverter.cs | 0 .../PropertyEditors/VoidEditor.cs | 18 +++++-- .../Manifest/DataEditorConverter.cs | 18 +++++-- .../Manifest/ManifestParser.cs | 2 +- .../Packaging/PackageDataInstallation.cs | 6 ++- .../BlockEditorPropertyEditor.cs | 16 +++--- .../BlockListPropertyEditor.cs | 12 ++--- .../CheckBoxListPropertyEditor.cs | 7 +-- .../ColorPickerConfigurationEditor.cs | 19 ++++--- .../ColorPickerPropertyEditor.cs | 7 +-- .../ContentPickerPropertyEditor.cs | 11 ++-- .../PropertyEditors/DateTimePropertyEditor.cs | 5 +- .../DropDownFlexiblePropertyEditor.cs | 14 +++-- .../EmailAddressPropertyEditor.cs | 6 ++- .../FileUploadPropertyEditor.cs | 13 ++--- .../FileUploadPropertyValueEditor.cs | 6 ++- .../PropertyEditors/GridPropertyEditor.cs | 17 +++--- .../ImageCropperConfiguration.cs | 0 .../ImageCropperPropertyEditor.cs | 11 ++-- .../ImageCropperPropertyValueEditor.cs | 6 ++- .../PropertyEditors/LabelPropertyEditor.cs | 11 ++-- .../PropertyEditors/ListViewPropertyEditor.cs | 13 +++-- .../PropertyEditors/MarkdownPropertyEditor.cs | 6 ++- .../MediaPickerPropertyEditor.cs | 18 +++++-- .../MultiNodeTreePickerPropertyEditor.cs | 24 +++++++-- .../MultiUrlPickerPropertyEditor.cs | 18 +++++-- .../MultiUrlPickerValueEditor.cs | 18 +++++-- .../MultipleTextStringPropertyEditor.cs | 24 +++++++-- .../PropertyEditors/MultipleValueEditor.cs | 13 ++++- .../NestedContentPropertyEditor.cs | 13 +++-- .../RadioButtonsPropertyEditor.cs | 6 ++- .../PropertyEditors/RichTextPropertyEditor.cs | 13 +++-- .../PropertyEditors/SliderPropertyEditor.cs | 6 ++- .../PropertyEditors/TagsPropertyEditor.cs | 12 +++-- .../PropertyEditors/TextAreaPropertyEditor.cs | 14 +++-- .../PropertyEditors/TextboxPropertyEditor.cs | 14 +++-- .../TrueFalsePropertyEditor.cs | 12 ++++- .../Services/Implement/DataTypeService.cs | 10 ++-- .../Builders/DataEditorBuilder.cs | 5 +- .../Builders/DataValueEditorBuilder.cs | 4 +- .../TestHelpers/MockedValueEditors.cs | 2 + .../TestHelpers/SolidPublishedSnapshot.cs | 6 +-- .../DataTypeDefinitionRepositoryTest.cs | 25 ++++----- .../Services/CachedDataTypeServiceTests.cs | 3 +- .../Services/DataTypeServiceTests.cs | 5 +- .../Filters/ContentModelValidatorTests.cs | 24 +++++---- .../Umbraco.Core/Models/VariationTests.cs | 4 +- .../PropertyEditors/ColorListValidatorTest.cs | 11 ++-- ...ataValueReferenceFactoryCollectionTests.cs | 20 +++---- .../EnsureUniqueValuesValidatorTest.cs | 15 +++--- .../MultiValuePropertyEditorTests.cs | 5 +- .../Umbraco.Core/Published/ConvertersTests.cs | 5 +- .../Published/NestedContentTests.cs | 4 +- .../Published/PropertyCacheLevelTests.cs | 21 +++++--- .../Persistence/Querying/ExpressionTests.cs | 12 ++--- .../PropertyValidationServiceTests.cs | 12 ++++- src/Umbraco.Tests/Models/MediaXmlTest.cs | 3 +- .../Packaging/PackageDataInstallationTests.cs | 5 +- .../Packaging/PackageInstallationTest.cs | 6 +-- .../Published/ConvertersTests.cs | 4 +- .../PublishedContent/NuCacheChildrenTests.cs | 13 ++--- .../PublishedContent/NuCacheTests.cs | 7 +-- .../PublishedContentDataTableTests.cs | 6 +-- .../PublishedContentSnapshotTestBase.cs | 13 +++-- .../PublishedContentTestBase.cs | 31 ++++++----- .../PublishedContent/PublishedContentTests.cs | 32 ++++++------ .../SolidPublishedSnapshot.cs | 4 +- .../Routing/MediaUrlProviderTests.cs | 4 +- src/Umbraco.Tests/TestHelpers/BaseWebTest.cs | 5 +- src/Umbraco.Tests/Testing/UmbracoTestBase.cs | 22 ++++---- .../Controllers/ContentTypeController.cs | 52 ++++++++++++------- 93 files changed, 646 insertions(+), 381 deletions(-) rename src/{Umbraco.Infrastructure => Umbraco.Core}/PropertyEditors/BlockListConfiguration.cs (76%) rename src/{Umbraco.Infrastructure => Umbraco.Core}/PropertyEditors/DataEditor.cs (92%) rename src/{Umbraco.Infrastructure => Umbraco.Core}/PropertyEditors/DataValueEditor.cs (93%) rename src/{Umbraco.Infrastructure => Umbraco.Core}/PropertyEditors/DateValueEditor.cs (70%) rename src/{Umbraco.Infrastructure => Umbraco.Core}/PropertyEditors/DecimalPropertyEditor.cs (88%) rename src/{Umbraco.Infrastructure => Umbraco.Core}/PropertyEditors/IntegerPropertyEditor.cs (72%) rename src/{Umbraco.Infrastructure => Umbraco.Core}/PropertyEditors/MemberGroupPickerPropertyEditor.cs (81%) rename src/{Umbraco.Infrastructure => Umbraco.Core}/PropertyEditors/MemberPickerPropertyEditor.cs (83%) rename src/{Umbraco.Infrastructure => Umbraco.Core}/PropertyEditors/ParameterEditors/ContentTypeParameterEditor.cs (85%) rename src/{Umbraco.Infrastructure => Umbraco.Core}/PropertyEditors/ParameterEditors/MultipleContentPickerParameterEditor.cs (86%) rename src/{Umbraco.Infrastructure => Umbraco.Core}/PropertyEditors/ParameterEditors/MultipleContentTypeParameterEditor.cs (82%) rename src/{Umbraco.Infrastructure => Umbraco.Core}/PropertyEditors/ParameterEditors/MultipleMediaPickerParameterEditor.cs (81%) rename src/{Umbraco.Infrastructure => Umbraco.Core}/PropertyEditors/ParameterEditors/MultiplePropertyGroupParameterEditor.cs (84%) rename src/{Umbraco.Infrastructure => Umbraco.Core}/PropertyEditors/ParameterEditors/MultiplePropertyTypeParameterEditor.cs (84%) rename src/{Umbraco.Infrastructure => Umbraco.Core}/PropertyEditors/ParameterEditors/PropertyGroupParameterEditor.cs (84%) rename src/{Umbraco.Infrastructure => Umbraco.Core}/PropertyEditors/ParameterEditors/PropertyTypeParameterEditor.cs (83%) rename src/{Umbraco.Infrastructure => Umbraco.Core}/PropertyEditors/RichTextConfiguration.cs (92%) rename src/{Umbraco.Infrastructure => Umbraco.Core}/PropertyEditors/TextOnlyValueEditor.cs (80%) rename src/{Umbraco.Infrastructure => Umbraco.Core}/PropertyEditors/UserPickerPropertyEditor.cs (82%) rename src/{Umbraco.Infrastructure => Umbraco.Core}/PropertyEditors/Validation/ComplexEditorElementTypeValidationResult.cs (100%) rename src/{Umbraco.Infrastructure => Umbraco.Core}/PropertyEditors/Validation/ComplexEditorPropertyTypeValidationResult.cs (100%) rename src/{Umbraco.Infrastructure => Umbraco.Core}/PropertyEditors/Validation/ComplexEditorValidationResult.cs (100%) rename src/{Umbraco.Infrastructure => Umbraco.Core}/PropertyEditors/ValueConverters/MemberPickerValueConverter.cs (100%) rename src/{Umbraco.Infrastructure => Umbraco.Core}/PropertyEditors/VoidEditor.cs (73%) rename src/{Umbraco.Core => Umbraco.Infrastructure}/PropertyEditors/ImageCropperConfiguration.cs (100%) diff --git a/src/Umbraco.Infrastructure/PropertyEditors/BlockListConfiguration.cs b/src/Umbraco.Core/PropertyEditors/BlockListConfiguration.cs similarity index 76% rename from src/Umbraco.Infrastructure/PropertyEditors/BlockListConfiguration.cs rename to src/Umbraco.Core/PropertyEditors/BlockListConfiguration.cs index 1af3aa1303..f0aa1f0b77 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/BlockListConfiguration.cs +++ b/src/Umbraco.Core/PropertyEditors/BlockListConfiguration.cs @@ -1,5 +1,5 @@ -using Newtonsoft.Json; -using System; +using System; +using System.Runtime.Serialization; using Umbraco.Core.PropertyEditors; namespace Umbraco.Web.PropertyEditors @@ -12,37 +12,38 @@ namespace Umbraco.Web.PropertyEditors [ConfigurationField("blocks", "Available Blocks", "views/propertyeditors/blocklist/prevalue/blocklist.blockconfiguration.html", Description = "Define the available blocks.")] public BlockConfiguration[] Blocks { get; set; } + [DataContract] public class BlockConfiguration { - [JsonProperty("backgroundColor")] + [DataMember(Name ="backgroundColor")] public string BackgroundColor { get; set; } - [JsonProperty("iconColor")] + [DataMember(Name ="iconColor")] public string IconColor { get; set; } - [JsonProperty("thumbnail")] + [DataMember(Name ="thumbnail")] public string Thumbnail { get; set; } - [JsonProperty("contentElementTypeKey")] + [DataMember(Name ="contentElementTypeKey")] public Guid ContentElementTypeKey { get; set; } - [JsonProperty("settingsElementTypeKey")] + [DataMember(Name ="settingsElementTypeKey")] public Guid? SettingsElementTypeKey { get; set; } - [JsonProperty("view")] + [DataMember(Name ="view")] public string View { get; set; } - [JsonProperty("stylesheet")] + [DataMember(Name ="stylesheet")] public string Stylesheet { get; set; } - [JsonProperty("label")] + [DataMember(Name ="label")] public string Label { get; set; } - [JsonProperty("editorSize")] + [DataMember(Name ="editorSize")] public string EditorSize { get; set; } - [JsonProperty("forceHideContentEditorInOverlay")] + [DataMember(Name ="forceHideContentEditorInOverlay")] public bool ForceHideContentEditorInOverlay { get; set; } } @@ -51,10 +52,10 @@ namespace Umbraco.Web.PropertyEditors public class NumberRange { - [JsonProperty("min")] + [DataMember(Name ="min")] public int? Min { get; set; } - [JsonProperty("max")] + [DataMember(Name ="max")] public int? Max { get; set; } } diff --git a/src/Umbraco.Infrastructure/PropertyEditors/DataEditor.cs b/src/Umbraco.Core/PropertyEditors/DataEditor.cs similarity index 92% rename from src/Umbraco.Infrastructure/PropertyEditors/DataEditor.cs rename to src/Umbraco.Core/PropertyEditors/DataEditor.cs index d74f285553..ef533aa083 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/DataEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/DataEditor.cs @@ -4,6 +4,7 @@ using System.Diagnostics; using System.Runtime.Serialization; using Microsoft.Extensions.Logging; using Umbraco.Core.Composing; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -26,13 +27,21 @@ namespace Umbraco.Core.PropertyEditors /// /// Initializes a new instance of the class. /// - public DataEditor(ILoggerFactory loggerFactory, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, EditorType type = EditorType.PropertyValue) + public DataEditor( + ILoggerFactory loggerFactory, + IDataTypeService dataTypeService, + ILocalizationService localizationService, + ILocalizedTextService localizedTextService, + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer, + EditorType type = EditorType.PropertyValue) { LoggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory)); DataTypeService = dataTypeService ?? throw new ArgumentNullException(nameof(dataTypeService)); LocalizationService = localizationService ?? throw new ArgumentNullException(nameof(localizationService)); LocalizedTextService = localizedTextService ?? throw new ArgumentNullException(nameof(localizedTextService)); ShortStringHelper = shortStringHelper ?? throw new ArgumentNullException(nameof(shortStringHelper)); + JsonSerializer = jsonSerializer ?? throw new ArgumentNullException(nameof(jsonSerializer)); // defaults @@ -58,6 +67,7 @@ namespace Umbraco.Core.PropertyEditors protected DataEditorAttribute Attribute { get; } protected IShortStringHelper ShortStringHelper { get; } + public IJsonSerializer JsonSerializer { get; } protected ILocalizedTextService LocalizedTextService { get; } protected ILocalizationService LocalizationService { get; } protected ILoggerFactory LoggerFactory { get; } @@ -65,7 +75,7 @@ namespace Umbraco.Core.PropertyEditors /// [DataMember(Name = "alias", IsRequired = true)] - public string Alias { get; internal set; } + public string Alias { get; set; } /// [IgnoreDataMember] @@ -174,7 +184,7 @@ namespace Umbraco.Core.PropertyEditors if (Attribute == null) throw new InvalidOperationException($"The editor is not attributed with {nameof(DataEditorAttribute)}"); - return new DataValueEditor(DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, Attribute); + return new DataValueEditor(DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, JsonSerializer, Attribute); } /// diff --git a/src/Umbraco.Infrastructure/PropertyEditors/DataValueEditor.cs b/src/Umbraco.Core/PropertyEditors/DataValueEditor.cs similarity index 93% rename from src/Umbraco.Infrastructure/PropertyEditors/DataValueEditor.cs rename to src/Umbraco.Core/PropertyEditors/DataValueEditor.cs index fec245009f..237af042cf 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/DataValueEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/DataValueEditor.cs @@ -3,14 +3,13 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using System.Xml.Linq; using Microsoft.Extensions.Logging; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using Umbraco.Core.Composing; using Umbraco.Core.Models; using Umbraco.Core.Models.Editors; using Umbraco.Core.PropertyEditors.Validators; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -19,20 +18,28 @@ namespace Umbraco.Core.PropertyEditors /// /// Represents a value editor. /// + [DataContract] public class DataValueEditor : IDataValueEditor { private readonly ILocalizedTextService _localizedTextService; private readonly IShortStringHelper _shortStringHelper; + private readonly IJsonSerializer _jsonSerializer; protected IDataTypeService DataTypeService { get; } protected ILocalizationService LocalizationService { get; } /// /// Initializes a new instance of the class. /// - public DataValueEditor(IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper) // for tests, and manifest + public DataValueEditor( + IDataTypeService dataTypeService, + ILocalizationService localizationService, + ILocalizedTextService localizedTextService, + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) // for tests, and manifest { _localizedTextService = localizedTextService; _shortStringHelper = shortStringHelper; + _jsonSerializer = jsonSerializer; ValueType = ValueTypes.String; Validators = new List(); DataTypeService = dataTypeService; @@ -42,11 +49,18 @@ namespace Umbraco.Core.PropertyEditors /// /// Initializes a new instance of the class. /// - public DataValueEditor(IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, DataEditorAttribute attribute) + public DataValueEditor( + IDataTypeService dataTypeService, + ILocalizationService localizationService, + ILocalizedTextService localizedTextService, + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer, + DataEditorAttribute attribute) { if (attribute == null) throw new ArgumentNullException(nameof(attribute)); _localizedTextService = localizedTextService; _shortStringHelper = shortStringHelper; + _jsonSerializer = jsonSerializer; var view = attribute.View; if (string.IsNullOrWhiteSpace(view)) @@ -72,13 +86,14 @@ namespace Umbraco.Core.PropertyEditors /// The view can be three things: (1) the full virtual path, or (2) the relative path to the current Umbraco /// folder, or (3) a view name which maps to views/propertyeditors/{view}/{view}.html. /// - [JsonProperty("view", Required = Required.Always)] + [Required] + [DataMember(Name = "view")] public string View { get; set; } /// /// The value type which reflects how it is validated and stored in the database /// - [JsonProperty("valueType")] + [DataMember(Name = "valueType")] public string ValueType { get; set; } /// @@ -111,7 +126,7 @@ namespace Umbraco.Core.PropertyEditors /// /// A collection of validators for the pre value editor /// - [JsonProperty("validation")] + [DataMember(Name = "validation")] public List Validators { get; private set; } = new List(); /// @@ -127,7 +142,7 @@ namespace Umbraco.Core.PropertyEditors /// /// If this is true than the editor will be displayed full width without a label /// - [JsonProperty("hideLabel")] + [DataMember(Name = "hideLabel")] public bool HideLabel { get; set; } /// @@ -142,8 +157,8 @@ namespace Umbraco.Core.PropertyEditors /// internal Attempt TryConvertValueToCrlType(object value) { - if (value is JValue) - value = value.ToString(); + // if (value is JValue) + // value = value.ToString(); //this is a custom check to avoid any errors, if it's a string and it's empty just make it null if (value is string s && string.IsNullOrWhiteSpace(s)) @@ -250,7 +265,7 @@ namespace Umbraco.Core.PropertyEditors { try { - var json = JsonConvert.DeserializeObject(asString); + var json = _jsonSerializer.Deserialize(asString); return json; } catch diff --git a/src/Umbraco.Infrastructure/PropertyEditors/DateValueEditor.cs b/src/Umbraco.Core/PropertyEditors/DateValueEditor.cs similarity index 70% rename from src/Umbraco.Infrastructure/PropertyEditors/DateValueEditor.cs rename to src/Umbraco.Core/PropertyEditors/DateValueEditor.cs index 8973dd812b..b6208197c7 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/DateValueEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/DateValueEditor.cs @@ -2,6 +2,7 @@ using Umbraco.Core; using Umbraco.Core.Models; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -13,8 +14,14 @@ namespace Umbraco.Web.PropertyEditors /// internal class DateValueEditor : DataValueEditor { - public DateValueEditor(IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, DataEditorAttribute attribute) - : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, attribute) + public DateValueEditor( + IDataTypeService dataTypeService, + ILocalizationService localizationService, + ILocalizedTextService localizedTextService, + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer, + DataEditorAttribute attribute) + : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer, attribute) { Validators.Add(new DateTimeValidator()); } diff --git a/src/Umbraco.Infrastructure/PropertyEditors/DecimalPropertyEditor.cs b/src/Umbraco.Core/PropertyEditors/DecimalPropertyEditor.cs similarity index 88% rename from src/Umbraco.Infrastructure/PropertyEditors/DecimalPropertyEditor.cs rename to src/Umbraco.Core/PropertyEditors/DecimalPropertyEditor.cs index 8d2280b23b..4aea9f944f 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/DecimalPropertyEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/DecimalPropertyEditor.cs @@ -2,6 +2,7 @@ using Umbraco.Core; using Umbraco.Core.PropertyEditors; using Umbraco.Core.PropertyEditors.Validators; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -26,8 +27,9 @@ namespace Umbraco.Web.PropertyEditors IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, - IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { } /// diff --git a/src/Umbraco.Infrastructure/PropertyEditors/IntegerPropertyEditor.cs b/src/Umbraco.Core/PropertyEditors/IntegerPropertyEditor.cs similarity index 72% rename from src/Umbraco.Infrastructure/PropertyEditors/IntegerPropertyEditor.cs rename to src/Umbraco.Core/PropertyEditors/IntegerPropertyEditor.cs index 417ec112d7..43b988a49f 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/IntegerPropertyEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/IntegerPropertyEditor.cs @@ -2,6 +2,7 @@ using Umbraco.Core; using Umbraco.Core.PropertyEditors; using Umbraco.Core.PropertyEditors.Validators; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -18,8 +19,14 @@ namespace Umbraco.Web.PropertyEditors ValueType = ValueTypes.Integer)] public class IntegerPropertyEditor : DataEditor { - public IntegerPropertyEditor(ILoggerFactory loggerFactory, IDataTypeService dataTypeService, ILocalizationService localizationService, IShortStringHelper shortStringHelper, ILocalizedTextService localizedTextService) - : base(loggerFactory, dataTypeService, localizationService,localizedTextService, shortStringHelper) + public IntegerPropertyEditor( + ILoggerFactory loggerFactory, + IDataTypeService dataTypeService, + ILocalizationService localizationService, + IShortStringHelper shortStringHelper, + ILocalizedTextService localizedTextService, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService,localizedTextService, shortStringHelper, jsonSerializer) { } /// diff --git a/src/Umbraco.Infrastructure/PropertyEditors/MemberGroupPickerPropertyEditor.cs b/src/Umbraco.Core/PropertyEditors/MemberGroupPickerPropertyEditor.cs similarity index 81% rename from src/Umbraco.Infrastructure/PropertyEditors/MemberGroupPickerPropertyEditor.cs rename to src/Umbraco.Core/PropertyEditors/MemberGroupPickerPropertyEditor.cs index eb50d02284..34448b3816 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/MemberGroupPickerPropertyEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/MemberGroupPickerPropertyEditor.cs @@ -1,6 +1,7 @@ using Microsoft.Extensions.Logging; using Umbraco.Core; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -20,8 +21,9 @@ namespace Umbraco.Web.PropertyEditors IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, - IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { } } } diff --git a/src/Umbraco.Infrastructure/PropertyEditors/MemberPickerPropertyEditor.cs b/src/Umbraco.Core/PropertyEditors/MemberPickerPropertyEditor.cs similarity index 83% rename from src/Umbraco.Infrastructure/PropertyEditors/MemberPickerPropertyEditor.cs rename to src/Umbraco.Core/PropertyEditors/MemberPickerPropertyEditor.cs index 3676340aee..b572f47cfd 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/MemberPickerPropertyEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/MemberPickerPropertyEditor.cs @@ -1,6 +1,7 @@ using Microsoft.Extensions.Logging; using Umbraco.Core; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -20,8 +21,9 @@ namespace Umbraco.Web.PropertyEditors IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, - IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { } protected override IConfigurationEditor CreateConfigurationEditor() => new MemberPickerConfiguration(); diff --git a/src/Umbraco.Infrastructure/PropertyEditors/ParameterEditors/ContentTypeParameterEditor.cs b/src/Umbraco.Core/PropertyEditors/ParameterEditors/ContentTypeParameterEditor.cs similarity index 85% rename from src/Umbraco.Infrastructure/PropertyEditors/ParameterEditors/ContentTypeParameterEditor.cs rename to src/Umbraco.Core/PropertyEditors/ParameterEditors/ContentTypeParameterEditor.cs index 2da9e184c3..619fd89692 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/ParameterEditors/ContentTypeParameterEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/ParameterEditors/ContentTypeParameterEditor.cs @@ -1,5 +1,6 @@ using Microsoft.Extensions.Logging; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -23,8 +24,9 @@ namespace Umbraco.Web.PropertyEditors.ParameterEditors IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, - IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { // configure DefaultConfiguration.Add("multiple", false); diff --git a/src/Umbraco.Infrastructure/PropertyEditors/ParameterEditors/MultipleContentPickerParameterEditor.cs b/src/Umbraco.Core/PropertyEditors/ParameterEditors/MultipleContentPickerParameterEditor.cs similarity index 86% rename from src/Umbraco.Infrastructure/PropertyEditors/ParameterEditors/MultipleContentPickerParameterEditor.cs rename to src/Umbraco.Core/PropertyEditors/ParameterEditors/MultipleContentPickerParameterEditor.cs index d416cf111a..5110dfdc79 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/ParameterEditors/MultipleContentPickerParameterEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/ParameterEditors/MultipleContentPickerParameterEditor.cs @@ -1,6 +1,7 @@ using Microsoft.Extensions.Logging; using Umbraco.Core; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -24,8 +25,9 @@ namespace Umbraco.Web.PropertyEditors.ParameterEditors IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, - IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { // configure DefaultConfiguration.Add("multiPicker", "1"); diff --git a/src/Umbraco.Infrastructure/PropertyEditors/ParameterEditors/MultipleContentTypeParameterEditor.cs b/src/Umbraco.Core/PropertyEditors/ParameterEditors/MultipleContentTypeParameterEditor.cs similarity index 82% rename from src/Umbraco.Infrastructure/PropertyEditors/ParameterEditors/MultipleContentTypeParameterEditor.cs rename to src/Umbraco.Core/PropertyEditors/ParameterEditors/MultipleContentTypeParameterEditor.cs index 613d6a6a5e..ff08420cd9 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/ParameterEditors/MultipleContentTypeParameterEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/ParameterEditors/MultipleContentTypeParameterEditor.cs @@ -1,5 +1,6 @@ using Microsoft.Extensions.Logging; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -17,8 +18,9 @@ namespace Umbraco.Web.PropertyEditors.ParameterEditors IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, - IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { // configure DefaultConfiguration.Add("multiple", true); diff --git a/src/Umbraco.Infrastructure/PropertyEditors/ParameterEditors/MultipleMediaPickerParameterEditor.cs b/src/Umbraco.Core/PropertyEditors/ParameterEditors/MultipleMediaPickerParameterEditor.cs similarity index 81% rename from src/Umbraco.Infrastructure/PropertyEditors/ParameterEditors/MultipleMediaPickerParameterEditor.cs rename to src/Umbraco.Core/PropertyEditors/ParameterEditors/MultipleMediaPickerParameterEditor.cs index 73a3b42610..a2750447a8 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/ParameterEditors/MultipleMediaPickerParameterEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/ParameterEditors/MultipleMediaPickerParameterEditor.cs @@ -1,6 +1,7 @@ -using Umbraco.Core; -using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging; +using Umbraco.Core; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -25,8 +26,9 @@ namespace Umbraco.Web.PropertyEditors.ParameterEditors IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, - IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { DefaultConfiguration.Add("multiPicker", "1"); } diff --git a/src/Umbraco.Infrastructure/PropertyEditors/ParameterEditors/MultiplePropertyGroupParameterEditor.cs b/src/Umbraco.Core/PropertyEditors/ParameterEditors/MultiplePropertyGroupParameterEditor.cs similarity index 84% rename from src/Umbraco.Infrastructure/PropertyEditors/ParameterEditors/MultiplePropertyGroupParameterEditor.cs rename to src/Umbraco.Core/PropertyEditors/ParameterEditors/MultiplePropertyGroupParameterEditor.cs index 16cd596fc8..22571db975 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/ParameterEditors/MultiplePropertyGroupParameterEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/ParameterEditors/MultiplePropertyGroupParameterEditor.cs @@ -1,5 +1,6 @@ using Microsoft.Extensions.Logging; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -17,8 +18,9 @@ namespace Umbraco.Web.PropertyEditors.ParameterEditors IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, - IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { // configure DefaultConfiguration.Add("multiple", true); diff --git a/src/Umbraco.Infrastructure/PropertyEditors/ParameterEditors/MultiplePropertyTypeParameterEditor.cs b/src/Umbraco.Core/PropertyEditors/ParameterEditors/MultiplePropertyTypeParameterEditor.cs similarity index 84% rename from src/Umbraco.Infrastructure/PropertyEditors/ParameterEditors/MultiplePropertyTypeParameterEditor.cs rename to src/Umbraco.Core/PropertyEditors/ParameterEditors/MultiplePropertyTypeParameterEditor.cs index e9576fab02..251d982777 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/ParameterEditors/MultiplePropertyTypeParameterEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/ParameterEditors/MultiplePropertyTypeParameterEditor.cs @@ -1,5 +1,6 @@ using Microsoft.Extensions.Logging; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -17,8 +18,9 @@ namespace Umbraco.Web.PropertyEditors.ParameterEditors IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, - IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { // configure DefaultConfiguration.Add("multiple", "1"); diff --git a/src/Umbraco.Infrastructure/PropertyEditors/ParameterEditors/PropertyGroupParameterEditor.cs b/src/Umbraco.Core/PropertyEditors/ParameterEditors/PropertyGroupParameterEditor.cs similarity index 84% rename from src/Umbraco.Infrastructure/PropertyEditors/ParameterEditors/PropertyGroupParameterEditor.cs rename to src/Umbraco.Core/PropertyEditors/ParameterEditors/PropertyGroupParameterEditor.cs index 345afa3b46..aabef3e1b0 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/ParameterEditors/PropertyGroupParameterEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/ParameterEditors/PropertyGroupParameterEditor.cs @@ -1,5 +1,6 @@ using Microsoft.Extensions.Logging; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -17,8 +18,9 @@ namespace Umbraco.Web.PropertyEditors.ParameterEditors IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, - IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { // configure DefaultConfiguration.Add("multiple", "0"); diff --git a/src/Umbraco.Infrastructure/PropertyEditors/ParameterEditors/PropertyTypeParameterEditor.cs b/src/Umbraco.Core/PropertyEditors/ParameterEditors/PropertyTypeParameterEditor.cs similarity index 83% rename from src/Umbraco.Infrastructure/PropertyEditors/ParameterEditors/PropertyTypeParameterEditor.cs rename to src/Umbraco.Core/PropertyEditors/ParameterEditors/PropertyTypeParameterEditor.cs index be682a35d3..c3178d3138 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/ParameterEditors/PropertyTypeParameterEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/ParameterEditors/PropertyTypeParameterEditor.cs @@ -1,5 +1,6 @@ using Microsoft.Extensions.Logging; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -17,8 +18,9 @@ namespace Umbraco.Web.PropertyEditors.ParameterEditors IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, - IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { // configure DefaultConfiguration.Add("multiple", "0"); diff --git a/src/Umbraco.Infrastructure/PropertyEditors/RichTextConfiguration.cs b/src/Umbraco.Core/PropertyEditors/RichTextConfiguration.cs similarity index 92% rename from src/Umbraco.Infrastructure/PropertyEditors/RichTextConfiguration.cs rename to src/Umbraco.Core/PropertyEditors/RichTextConfiguration.cs index c6d4e3ce70..c1fb61bde8 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/RichTextConfiguration.cs +++ b/src/Umbraco.Core/PropertyEditors/RichTextConfiguration.cs @@ -1,5 +1,4 @@ -using Newtonsoft.Json.Linq; -using Umbraco.Core; +using Umbraco.Core; using Umbraco.Core.PropertyEditors; namespace Umbraco.Web.PropertyEditors @@ -11,7 +10,7 @@ namespace Umbraco.Web.PropertyEditors { // TODO: Make these strongly typed, for now this works though [ConfigurationField("editor", "Editor", "views/propertyeditors/rte/rte.prevalues.html", HideLabel = true)] - public JObject Editor { get; set; } + public object Editor { get; set; } [ConfigurationField("hideLabel", "Hide Label", "boolean")] public bool HideLabel { get; set; } diff --git a/src/Umbraco.Infrastructure/PropertyEditors/TextOnlyValueEditor.cs b/src/Umbraco.Core/PropertyEditors/TextOnlyValueEditor.cs similarity index 80% rename from src/Umbraco.Infrastructure/PropertyEditors/TextOnlyValueEditor.cs rename to src/Umbraco.Core/PropertyEditors/TextOnlyValueEditor.cs index ec48cf8b57..aeac87079c 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/TextOnlyValueEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/TextOnlyValueEditor.cs @@ -1,6 +1,7 @@ using System; using Umbraco.Core.Models; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -12,8 +13,14 @@ namespace Umbraco.Web.PropertyEditors /// public class TextOnlyValueEditor : DataValueEditor { - public TextOnlyValueEditor(IDataTypeService dataTypeService, ILocalizationService localizationService, DataEditorAttribute attribute, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper) - : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, attribute) + public TextOnlyValueEditor( + IDataTypeService dataTypeService, + ILocalizationService localizationService, + DataEditorAttribute attribute, + ILocalizedTextService localizedTextService, + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer, attribute) { } /// diff --git a/src/Umbraco.Infrastructure/PropertyEditors/UserPickerPropertyEditor.cs b/src/Umbraco.Core/PropertyEditors/UserPickerPropertyEditor.cs similarity index 82% rename from src/Umbraco.Infrastructure/PropertyEditors/UserPickerPropertyEditor.cs rename to src/Umbraco.Core/PropertyEditors/UserPickerPropertyEditor.cs index 891fb54ee3..f22c3d94dc 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/UserPickerPropertyEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/UserPickerPropertyEditor.cs @@ -1,6 +1,7 @@ using Microsoft.Extensions.Logging; using Umbraco.Core; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -20,8 +21,9 @@ namespace Umbraco.Web.PropertyEditors IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, - IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { } protected override IConfigurationEditor CreateConfigurationEditor() => new UserPickerConfiguration(); diff --git a/src/Umbraco.Infrastructure/PropertyEditors/Validation/ComplexEditorElementTypeValidationResult.cs b/src/Umbraco.Core/PropertyEditors/Validation/ComplexEditorElementTypeValidationResult.cs similarity index 100% rename from src/Umbraco.Infrastructure/PropertyEditors/Validation/ComplexEditorElementTypeValidationResult.cs rename to src/Umbraco.Core/PropertyEditors/Validation/ComplexEditorElementTypeValidationResult.cs diff --git a/src/Umbraco.Infrastructure/PropertyEditors/Validation/ComplexEditorPropertyTypeValidationResult.cs b/src/Umbraco.Core/PropertyEditors/Validation/ComplexEditorPropertyTypeValidationResult.cs similarity index 100% rename from src/Umbraco.Infrastructure/PropertyEditors/Validation/ComplexEditorPropertyTypeValidationResult.cs rename to src/Umbraco.Core/PropertyEditors/Validation/ComplexEditorPropertyTypeValidationResult.cs diff --git a/src/Umbraco.Infrastructure/PropertyEditors/Validation/ComplexEditorValidationResult.cs b/src/Umbraco.Core/PropertyEditors/Validation/ComplexEditorValidationResult.cs similarity index 100% rename from src/Umbraco.Infrastructure/PropertyEditors/Validation/ComplexEditorValidationResult.cs rename to src/Umbraco.Core/PropertyEditors/Validation/ComplexEditorValidationResult.cs diff --git a/src/Umbraco.Infrastructure/PropertyEditors/ValueConverters/MemberPickerValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/MemberPickerValueConverter.cs similarity index 100% rename from src/Umbraco.Infrastructure/PropertyEditors/ValueConverters/MemberPickerValueConverter.cs rename to src/Umbraco.Core/PropertyEditors/ValueConverters/MemberPickerValueConverter.cs diff --git a/src/Umbraco.Infrastructure/PropertyEditors/VoidEditor.cs b/src/Umbraco.Core/PropertyEditors/VoidEditor.cs similarity index 73% rename from src/Umbraco.Infrastructure/PropertyEditors/VoidEditor.cs rename to src/Umbraco.Core/PropertyEditors/VoidEditor.cs index e26cd4129a..d2e84b7952 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/VoidEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/VoidEditor.cs @@ -1,5 +1,6 @@ using Microsoft.Extensions.Logging; using Umbraco.Core.Composing; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -14,6 +15,8 @@ namespace Umbraco.Core.PropertyEditors [HideFromTypeFinder] public class VoidEditor : DataEditor { + private readonly IJsonSerializer _jsonSerializer; + /// /// Initializes a new instance of the class. /// @@ -21,8 +24,15 @@ namespace Umbraco.Core.PropertyEditors /// A logger factory. /// The default alias of the editor is "Umbraco.Void". When a suffix is provided, /// it is appended to the alias. Eg if the suffix is "Foo" the alias is "Umbraco.Void.Foo". - public VoidEditor(string aliasSuffix, ILoggerFactory loggerFactory, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + public VoidEditor( + string aliasSuffix, + ILoggerFactory loggerFactory, + IDataTypeService dataTypeService, + ILocalizationService localizationService, + ILocalizedTextService localizedTextService, + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { Alias = "Umbraco.Void"; if (string.IsNullOrWhiteSpace(aliasSuffix)) return; @@ -34,8 +44,8 @@ namespace Umbraco.Core.PropertyEditors /// /// A logger factory. /// The alias of the editor is "Umbraco.Void". - public VoidEditor(ILoggerFactory loggerFactory, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper) - : this(null, loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + public VoidEditor(ILoggerFactory loggerFactory, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, IJsonSerializer jsonSerializer) + : this(null, loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { } } } diff --git a/src/Umbraco.Infrastructure/Manifest/DataEditorConverter.cs b/src/Umbraco.Infrastructure/Manifest/DataEditorConverter.cs index 94b868f145..1bbd9042b0 100644 --- a/src/Umbraco.Infrastructure/Manifest/DataEditorConverter.cs +++ b/src/Umbraco.Infrastructure/Manifest/DataEditorConverter.cs @@ -2,7 +2,6 @@ using Microsoft.Extensions.Logging; using Newtonsoft.Json; using Newtonsoft.Json.Linq; -using Umbraco.Core.Composing; using Umbraco.Core.IO; using Umbraco.Core.PropertyEditors; using Umbraco.Core.Serialization; @@ -22,11 +21,19 @@ namespace Umbraco.Core.Manifest private readonly ILocalizationService _localizationService; private readonly ILocalizedTextService _textService; private readonly IShortStringHelper _shortStringHelper; + private readonly IJsonSerializer _jsonSerializer; /// /// Initializes a new instance of the class. /// - public DataEditorConverter(ILoggerFactory loggerFactory, IIOHelper ioHelper, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService textService, IShortStringHelper shortStringHelper) + public DataEditorConverter( + ILoggerFactory loggerFactory, + IIOHelper ioHelper, + IDataTypeService dataTypeService, + ILocalizationService localizationService, + ILocalizedTextService textService, + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) { _loggerFactory = loggerFactory; _ioHelper = ioHelper; @@ -34,6 +41,7 @@ namespace Umbraco.Core.Manifest _localizationService = localizationService; _textService = textService; _shortStringHelper = shortStringHelper; + _jsonSerializer = jsonSerializer; } /// @@ -61,7 +69,7 @@ namespace Umbraco.Core.Manifest type = EditorType.MacroParameter; } - return new DataEditor(_loggerFactory, _dataTypeService, _localizationService, _textService, _shortStringHelper, type); + return new DataEditor(_loggerFactory, _dataTypeService, _localizationService, _textService, _shortStringHelper, _jsonSerializer, type); } /// @@ -88,7 +96,7 @@ namespace Umbraco.Core.Manifest // explicitly assign a value editor of type ValueEditor // (else the deserializer will try to read it before setting it) // (and besides it's an interface) - target.ExplicitValueEditor = new DataValueEditor(_dataTypeService, _localizationService, _textService, _shortStringHelper); + target.ExplicitValueEditor = new DataValueEditor(_dataTypeService, _localizationService, _textService, _shortStringHelper, _jsonSerializer); // in the manifest, validators are a simple dictionary eg // { @@ -160,7 +168,7 @@ namespace Umbraco.Core.Manifest if (jobject.Property("view") != null) { // explicitly assign a value editor of type ParameterValueEditor - target.ExplicitValueEditor = new DataValueEditor(_dataTypeService, _localizationService, _textService, _shortStringHelper); + target.ExplicitValueEditor = new DataValueEditor(_dataTypeService, _localizationService, _textService, _shortStringHelper, _jsonSerializer); // move the 'view' property jobject["editor"] = new JObject { ["view"] = jobject["view"] }; diff --git a/src/Umbraco.Infrastructure/Manifest/ManifestParser.cs b/src/Umbraco.Infrastructure/Manifest/ManifestParser.cs index eec83dffef..15ddcebb7e 100644 --- a/src/Umbraco.Infrastructure/Manifest/ManifestParser.cs +++ b/src/Umbraco.Infrastructure/Manifest/ManifestParser.cs @@ -196,7 +196,7 @@ namespace Umbraco.Core.Manifest if (string.IsNullOrWhiteSpace(text)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(text)); var manifest = JsonConvert.DeserializeObject(text, - new DataEditorConverter(_loggerFactory, _ioHelper, _dataTypeService, _localizationService, _localizedTextService, _shortStringHelper), + new DataEditorConverter(_loggerFactory, _ioHelper, _dataTypeService, _localizationService, _localizedTextService, _shortStringHelper, _jsonSerializer), new ValueValidatorConverter(_validators), new DashboardAccessRuleConverter()); diff --git a/src/Umbraco.Infrastructure/Packaging/PackageDataInstallation.cs b/src/Umbraco.Infrastructure/Packaging/PackageDataInstallation.cs index 5f5ee63642..f8bf6283f5 100644 --- a/src/Umbraco.Infrastructure/Packaging/PackageDataInstallation.cs +++ b/src/Umbraco.Infrastructure/Packaging/PackageDataInstallation.cs @@ -34,6 +34,7 @@ namespace Umbraco.Core.Packaging private readonly GlobalSettings _globalSettings; private readonly ILocalizedTextService _localizedTextService; private readonly IConfigurationEditorJsonSerializer _serializer; + private readonly IJsonSerializer _jsonSerializer; private readonly IEntityService _entityService; private readonly IContentTypeService _contentTypeService; private readonly IContentService _contentService; @@ -41,7 +42,7 @@ namespace Umbraco.Core.Packaging public PackageDataInstallation(ILogger logger, ILoggerFactory loggerFactory, IFileService fileService, IMacroService macroService, ILocalizationService localizationService, IDataTypeService dataTypeService, IEntityService entityService, IContentTypeService contentTypeService, IContentService contentService, PropertyEditorCollection propertyEditors, IScopeProvider scopeProvider, IShortStringHelper shortStringHelper, IOptions globalSettings, - ILocalizedTextService localizedTextService, IConfigurationEditorJsonSerializer serializer) + ILocalizedTextService localizedTextService, IConfigurationEditorJsonSerializer serializer, IJsonSerializer jsonSerializer) { _logger = logger; _loggerFactory = loggerFactory; @@ -55,6 +56,7 @@ namespace Umbraco.Core.Packaging _globalSettings = globalSettings.Value; _localizedTextService = localizedTextService; _serializer = serializer; + _jsonSerializer = jsonSerializer; _entityService = entityService; _contentTypeService = contentTypeService; _contentService = contentService; @@ -911,7 +913,7 @@ namespace Umbraco.Core.Packaging var editorAlias = dataTypeElement.Attribute("Id")?.Value?.Trim(); if (!_propertyEditors.TryGet(editorAlias, out var editor)) - editor = new VoidEditor(_loggerFactory, _dataTypeService, _localizationService, _localizedTextService, _shortStringHelper) { Alias = editorAlias }; + editor = new VoidEditor(_loggerFactory, _dataTypeService, _localizationService, _localizedTextService, _shortStringHelper, _jsonSerializer) { Alias = editorAlias }; var dataType = new DataType(editor, _serializer) { diff --git a/src/Umbraco.Infrastructure/PropertyEditors/BlockEditorPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/BlockEditorPropertyEditor.cs index b1e5fb0199..81281a3302 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/BlockEditorPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/BlockEditorPropertyEditor.cs @@ -1,14 +1,15 @@ -using Newtonsoft.Json; -using System; +using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using Microsoft.Extensions.Logging; +using Newtonsoft.Json; using Umbraco.Core; using Umbraco.Core.Models; using Umbraco.Core.Models.Blocks; using Umbraco.Core.Models.Editors; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; using static Umbraco.Core.Models.Blocks.BlockItemData; @@ -35,8 +36,9 @@ namespace Umbraco.Web.PropertyEditors IContentTypeService contentTypeService, ILocalizedTextService localizedTextService, ILocalizationService localizationService, - IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService,localizationService,localizedTextService, shortStringHelper) + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService,localizationService,localizedTextService, shortStringHelper, jsonSerializer) { _localizedTextService = localizedTextService; _propertyEditors = propertyEditors; @@ -49,7 +51,7 @@ namespace Umbraco.Web.PropertyEditors #region Value Editor - protected override IDataValueEditor CreateValueEditor() => new BlockEditorPropertyValueEditor(Attribute, PropertyEditors, _dataTypeService, _contentTypeService, _localizedTextService, LoggerFactory.CreateLogger(), LocalizationService,ShortStringHelper); + protected override IDataValueEditor CreateValueEditor() => new BlockEditorPropertyValueEditor(Attribute, PropertyEditors, _dataTypeService, _contentTypeService, _localizedTextService, LoggerFactory.CreateLogger(), LocalizationService,ShortStringHelper, JsonSerializer); internal class BlockEditorPropertyValueEditor : DataValueEditor, IDataValueReference { @@ -58,8 +60,8 @@ namespace Umbraco.Web.PropertyEditors private readonly ILogger _logger; private readonly BlockEditorValues _blockEditorValues; - public BlockEditorPropertyValueEditor(DataEditorAttribute attribute, PropertyEditorCollection propertyEditors, IDataTypeService dataTypeService, IContentTypeService contentTypeService, ILocalizedTextService textService, ILogger logger, ILocalizationService localizationService, IShortStringHelper shortStringHelper) - : base(dataTypeService, localizationService, textService, shortStringHelper, attribute) + public BlockEditorPropertyValueEditor(DataEditorAttribute attribute, PropertyEditorCollection propertyEditors, IDataTypeService dataTypeService, IContentTypeService contentTypeService, ILocalizedTextService textService, ILogger logger, ILocalizationService localizationService, IShortStringHelper shortStringHelper, IJsonSerializer jsonSerializer) + : base(dataTypeService, localizationService, textService, shortStringHelper, jsonSerializer, attribute) { _propertyEditors = propertyEditors; _dataTypeService = dataTypeService; diff --git a/src/Umbraco.Infrastructure/PropertyEditors/BlockListPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/BlockListPropertyEditor.cs index 6a23d0da00..1657b4098d 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/BlockListPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/BlockListPropertyEditor.cs @@ -1,12 +1,9 @@ -using Newtonsoft.Json.Linq; -using System; -using System.Collections.Generic; -using System.Linq; +using System; using Microsoft.Extensions.Logging; using Umbraco.Core; using Umbraco.Core.IO; -using Umbraco.Core.Models.Blocks; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -34,8 +31,9 @@ namespace Umbraco.Web.PropertyEditors ILocalizedTextService localizedTextService, IIOHelper ioHelper, ILocalizationService localizationService, - IShortStringHelper shortStringHelper) - : base(loggerFactory, propertyEditors, dataTypeService, contentTypeService, localizedTextService, localizationService, shortStringHelper) + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(loggerFactory, propertyEditors, dataTypeService, contentTypeService, localizedTextService, localizationService, shortStringHelper, jsonSerializer) { _ioHelper = ioHelper; } diff --git a/src/Umbraco.Infrastructure/PropertyEditors/CheckBoxListPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/CheckBoxListPropertyEditor.cs index 09600d86ae..27d729e319 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/CheckBoxListPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/CheckBoxListPropertyEditor.cs @@ -2,6 +2,7 @@ using Umbraco.Core; using Umbraco.Core.IO; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -28,8 +29,8 @@ namespace Umbraco.Web.PropertyEditors /// /// The constructor will setup the property editor based on the attribute if one is found /// - public CheckBoxListPropertyEditor(ILoggerFactory loggerFactory, ILocalizedTextService textService, IDataTypeService dataTypeService, ILocalizationService localizationService, IShortStringHelper shortStringHelper, IIOHelper ioHelper, ILocalizedTextService localizedTextService) - : base(loggerFactory, dataTypeService, localizationService,localizedTextService, shortStringHelper) + public CheckBoxListPropertyEditor(ILoggerFactory loggerFactory, ILocalizedTextService textService, IDataTypeService dataTypeService, ILocalizationService localizationService, IShortStringHelper shortStringHelper, IIOHelper ioHelper, ILocalizedTextService localizedTextService, IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService,localizedTextService, shortStringHelper, jsonSerializer) { _textService = textService; _dataTypeService = dataTypeService; @@ -43,6 +44,6 @@ namespace Umbraco.Web.PropertyEditors protected override IConfigurationEditor CreateConfigurationEditor() => new ValueListConfigurationEditor(_textService, _ioHelper); /// - protected override IDataValueEditor CreateValueEditor() => new MultipleValueEditor(LoggerFactory.CreateLogger(), _dataTypeService, _localizationService, _localizedTextService, _shortStringHelper, Attribute); + protected override IDataValueEditor CreateValueEditor() => new MultipleValueEditor(LoggerFactory.CreateLogger(), _dataTypeService, _localizationService, _localizedTextService, _shortStringHelper, JsonSerializer, Attribute); } } diff --git a/src/Umbraco.Infrastructure/PropertyEditors/ColorPickerConfigurationEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/ColorPickerConfigurationEditor.cs index e2cc93bd7c..f5776b7c28 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/ColorPickerConfigurationEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/ColorPickerConfigurationEditor.cs @@ -1,19 +1,23 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; +using System.Runtime.Serialization; using System.Text.RegularExpressions; -using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Umbraco.Core; using Umbraco.Core.IO; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; namespace Umbraco.Web.PropertyEditors { internal class ColorPickerConfigurationEditor : ConfigurationEditor { - public ColorPickerConfigurationEditor(IIOHelper ioHelper) : base(ioHelper) + private readonly IJsonSerializer _jsonSerializer; + + public ColorPickerConfigurationEditor(IIOHelper ioHelper, IJsonSerializer jsonSerializer) : base(ioHelper) { + _jsonSerializer = jsonSerializer; var items = Fields.First(x => x.Key == "items"); // customize the items field @@ -67,7 +71,7 @@ namespace Umbraco.Web.PropertyEditors { try { - var o = JsonConvert.DeserializeObject(item.Value); + var o = _jsonSerializer.Deserialize(item.Value); o.SortOrder = sortOrder; return o; } @@ -82,15 +86,16 @@ namespace Umbraco.Web.PropertyEditors } // represents an item we are exchanging with the editor + [DataContract] private class ItemValue { - [JsonProperty("value")] + [DataMember(Name ="value")] public string Color { get; set; } - [JsonProperty("label")] + [DataMember(Name ="label")] public string Label { get; set; } - [JsonProperty("sortOrder")] + [DataMember(Name ="sortOrder")] public int SortOrder { get; set; } } @@ -131,7 +136,7 @@ namespace Umbraco.Web.PropertyEditors if (id >= nextId) nextId = id + 1; var label = item.Property("label")?.Value?.Value(); - value = JsonConvert.SerializeObject(new { value, label }); + value = _jsonSerializer.Serialize(new { value, label }); output.Items.Add(new ValueListConfiguration.ValueListItem { Id = id, Value = value }); } diff --git a/src/Umbraco.Infrastructure/PropertyEditors/ColorPickerPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/ColorPickerPropertyEditor.cs index 575609a934..aec8e4b137 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/ColorPickerPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/ColorPickerPropertyEditor.cs @@ -2,6 +2,7 @@ using Umbraco.Core; using Umbraco.Core.IO; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -17,13 +18,13 @@ namespace Umbraco.Web.PropertyEditors { private readonly IIOHelper _ioHelper; - public ColorPickerPropertyEditor(ILoggerFactory loggerFactory, IDataTypeService dataTypeService, ILocalizationService localizationService, IIOHelper ioHelper, IShortStringHelper shortStringHelper, ILocalizedTextService localizedTextService) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + public ColorPickerPropertyEditor(ILoggerFactory loggerFactory, IDataTypeService dataTypeService, ILocalizationService localizationService, IIOHelper ioHelper, IShortStringHelper shortStringHelper, ILocalizedTextService localizedTextService, IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { _ioHelper = ioHelper; } /// - protected override IConfigurationEditor CreateConfigurationEditor() => new ColorPickerConfigurationEditor(_ioHelper); + protected override IConfigurationEditor CreateConfigurationEditor() => new ColorPickerConfigurationEditor(_ioHelper, JsonSerializer); } } diff --git a/src/Umbraco.Infrastructure/PropertyEditors/ContentPickerPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/ContentPickerPropertyEditor.cs index 4c172ccb2e..c95f14e8e0 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/ContentPickerPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/ContentPickerPropertyEditor.cs @@ -4,6 +4,7 @@ using Umbraco.Core; using Umbraco.Core.IO; using Umbraco.Core.Models.Editors; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -32,8 +33,9 @@ namespace Umbraco.Web.PropertyEditors ILocalizedTextService localizedTextService, ILoggerFactory loggerFactory, IIOHelper ioHelper, - IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService,localizationService,localizedTextService, shortStringHelper) + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService,localizationService,localizedTextService, shortStringHelper, jsonSerializer) { _dataTypeService = dataTypeService; _localizationService = localizationService; @@ -46,11 +48,12 @@ namespace Umbraco.Web.PropertyEditors return new ContentPickerConfigurationEditor(_ioHelper); } - protected override IDataValueEditor CreateValueEditor() => new ContentPickerPropertyValueEditor(_dataTypeService, _localizationService, _localizedTextService, ShortStringHelper, Attribute); + protected override IDataValueEditor CreateValueEditor() => new ContentPickerPropertyValueEditor(_dataTypeService, _localizationService, _localizedTextService, ShortStringHelper, JsonSerializer, Attribute); internal class ContentPickerPropertyValueEditor : DataValueEditor, IDataValueReference { - public ContentPickerPropertyValueEditor(IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, DataEditorAttribute attribute) : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, attribute) + public ContentPickerPropertyValueEditor(IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, IJsonSerializer jsonSerializer, DataEditorAttribute attribute) + : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer, attribute) { } diff --git a/src/Umbraco.Infrastructure/PropertyEditors/DateTimePropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/DateTimePropertyEditor.cs index db4c6734a8..40ece10a1e 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/DateTimePropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/DateTimePropertyEditor.cs @@ -2,6 +2,7 @@ using Umbraco.Core; using Umbraco.Core.IO; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -24,8 +25,8 @@ namespace Umbraco.Web.PropertyEditors /// Initializes a new instance of the class. /// /// - public DateTimePropertyEditor(ILoggerFactory loggerFactory, IIOHelper ioHelper, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService, localizationService,localizedTextService, shortStringHelper) + public DateTimePropertyEditor(ILoggerFactory loggerFactory, IIOHelper ioHelper, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService,localizedTextService, shortStringHelper, jsonSerializer) { _ioHelper = ioHelper; } diff --git a/src/Umbraco.Infrastructure/PropertyEditors/DropDownFlexiblePropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/DropDownFlexiblePropertyEditor.cs index 66f605bc36..186730775e 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/DropDownFlexiblePropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/DropDownFlexiblePropertyEditor.cs @@ -2,6 +2,7 @@ using Umbraco.Core; using Umbraco.Core.IO; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -21,8 +22,15 @@ namespace Umbraco.Web.PropertyEditors private readonly IShortStringHelper _shortStringHelper; private readonly IIOHelper _ioHelper; - public DropDownFlexiblePropertyEditor(ILocalizedTextService textService, ILoggerFactory loggerFactory, IDataTypeService dataTypeService, ILocalizationService localizationService, IShortStringHelper shortStringHelper, IIOHelper ioHelper) - : base(loggerFactory, dataTypeService, localizationService, textService, shortStringHelper) + public DropDownFlexiblePropertyEditor( + ILocalizedTextService textService, + ILoggerFactory loggerFactory, + IDataTypeService dataTypeService, + ILocalizationService localizationService, + IShortStringHelper shortStringHelper, + IIOHelper ioHelper, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, textService, shortStringHelper, jsonSerializer) { _textService = textService; _dataTypeService = dataTypeService; @@ -33,7 +41,7 @@ namespace Umbraco.Web.PropertyEditors protected override IDataValueEditor CreateValueEditor() { - return new MultipleValueEditor(LoggerFactory.CreateLogger(), _dataTypeService, _localizationService, _textService, _shortStringHelper, Attribute); + return new MultipleValueEditor(LoggerFactory.CreateLogger(), _dataTypeService, _localizationService, _textService, _shortStringHelper, JsonSerializer, Attribute); } protected override IConfigurationEditor CreateConfigurationEditor() => new DropDownFlexibleConfigurationEditor(_textService, _ioHelper); diff --git a/src/Umbraco.Infrastructure/PropertyEditors/EmailAddressPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/EmailAddressPropertyEditor.cs index 2cdfd4f7eb..120a522cd7 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/EmailAddressPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/EmailAddressPropertyEditor.cs @@ -3,6 +3,7 @@ using Umbraco.Core; using Umbraco.Core.IO; using Umbraco.Core.PropertyEditors; using Umbraco.Core.PropertyEditors.Validators; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -27,8 +28,9 @@ namespace Umbraco.Web.PropertyEditors IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, - IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { _ioHelper = ioHelper; } diff --git a/src/Umbraco.Infrastructure/PropertyEditors/FileUploadPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/FileUploadPropertyEditor.cs index 448e2043c0..b425432b01 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/FileUploadPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/FileUploadPropertyEditor.cs @@ -7,9 +7,9 @@ using Umbraco.Core; using Umbraco.Core.Configuration; using Umbraco.Core.Configuration.Models; using Umbraco.Core.IO; -using Umbraco.Core.Media; using Umbraco.Core.Models; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; using Umbraco.Web.Media; @@ -39,8 +39,9 @@ namespace Umbraco.Web.PropertyEditors ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, - UploadAutoFillProperties uploadAutoFillProperties) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + UploadAutoFillProperties uploadAutoFillProperties, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { _mediaFileSystem = mediaFileSystem ?? throw new ArgumentNullException(nameof(mediaFileSystem)); _contentSettings = contentSettings.Value; @@ -56,7 +57,7 @@ namespace Umbraco.Web.PropertyEditors /// The corresponding property value editor. protected override IDataValueEditor CreateValueEditor() { - var editor = new FileUploadPropertyValueEditor(Attribute, _mediaFileSystem, _dataTypeService, _localizationService, _localizedTextService, ShortStringHelper, Options.Create(_contentSettings)); + var editor = new FileUploadPropertyValueEditor(Attribute, _mediaFileSystem, _dataTypeService, _localizationService, _localizedTextService, ShortStringHelper, Options.Create(_contentSettings), JsonSerializer); editor.Validators.Add(new UploadFileTypeValidator(_localizedTextService, Options.Create(_contentSettings))); return editor; } @@ -162,7 +163,7 @@ namespace Umbraco.Web.PropertyEditors /// /// The event sender. /// The event arguments. - internal void MediaServiceSaving(IMediaService sender, Core.Events.SaveEventArgs args) + public void MediaServiceSaving(IMediaService sender, Core.Events.SaveEventArgs args) { foreach (var entity in args.SavedEntities) AutoFillProperties(entity); @@ -173,7 +174,7 @@ namespace Umbraco.Web.PropertyEditors /// /// The event sender. /// The event arguments. - internal void ContentServiceSaving(IContentService sender, Core.Events.SaveEventArgs args) + public void ContentServiceSaving(IContentService sender, Core.Events.SaveEventArgs args) { foreach (var entity in args.SavedEntities) AutoFillProperties(entity); diff --git a/src/Umbraco.Infrastructure/PropertyEditors/FileUploadPropertyValueEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/FileUploadPropertyValueEditor.cs index db675e2e42..8ccb59988d 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/FileUploadPropertyValueEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/FileUploadPropertyValueEditor.cs @@ -6,6 +6,7 @@ using Umbraco.Core.Configuration.Models; using Umbraco.Core.IO; using Umbraco.Core.Models.Editors; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -26,8 +27,9 @@ namespace Umbraco.Web.PropertyEditors ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, - IOptions contentSettings) - : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, attribute) + IOptions contentSettings, + IJsonSerializer jsonSerializer) + : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer, attribute) { _mediaFileSystem = mediaFileSystem ?? throw new ArgumentNullException(nameof(mediaFileSystem)); _contentSettings = contentSettings.Value ?? throw new ArgumentNullException(nameof(contentSettings)); diff --git a/src/Umbraco.Infrastructure/PropertyEditors/GridPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/GridPropertyEditor.cs index e6db6a4328..2bac76e6f9 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/GridPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/GridPropertyEditor.cs @@ -10,6 +10,7 @@ using Umbraco.Core.Models; using Umbraco.Core.Models.Editors; using Umbraco.Core.PropertyEditors; using Umbraco.Core.Security; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; using Umbraco.Web.Templates; @@ -47,8 +48,9 @@ namespace Umbraco.Web.PropertyEditors HtmlLocalLinkParser localLinkParser, IIOHelper ioHelper, IShortStringHelper shortStringHelper, - IImageUrlGenerator imageUrlGenerator) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + IImageUrlGenerator imageUrlGenerator, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { _backOfficeSecurityAccessor = backOfficeSecurityAccessor; _ioHelper = ioHelper; @@ -64,7 +66,7 @@ namespace Umbraco.Web.PropertyEditors /// Overridden to ensure that the value is validated /// /// - protected override IDataValueEditor CreateValueEditor() => new GridPropertyValueEditor(Attribute, _backOfficeSecurityAccessor, DataTypeService, LocalizationService, LocalizedTextService, _imageSourceParser, _pastedImages, _localLinkParser, ShortStringHelper, _imageUrlGenerator); + protected override IDataValueEditor CreateValueEditor() => new GridPropertyValueEditor(Attribute, _backOfficeSecurityAccessor, DataTypeService, LocalizationService, LocalizedTextService, _imageSourceParser, _pastedImages, _localLinkParser, ShortStringHelper, _imageUrlGenerator, JsonSerializer); protected override IConfigurationEditor CreateConfigurationEditor() => new GridConfigurationEditor(_ioHelper); @@ -87,14 +89,15 @@ namespace Umbraco.Web.PropertyEditors RichTextEditorPastedImages pastedImages, HtmlLocalLinkParser localLinkParser, IShortStringHelper shortStringHelper, - IImageUrlGenerator imageUrlGenerator) - : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, attribute) + IImageUrlGenerator imageUrlGenerator, + IJsonSerializer jsonSerializer) + : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer, attribute) { _backOfficeSecurityAccessor = backOfficeSecurityAccessor; _imageSourceParser = imageSourceParser; _pastedImages = pastedImages; - _richTextPropertyValueEditor = new RichTextPropertyEditor.RichTextPropertyValueEditor(attribute, backOfficeSecurityAccessor, dataTypeService, localizationService, localizedTextService, shortStringHelper, imageSourceParser, localLinkParser, pastedImages, imageUrlGenerator); - _mediaPickerPropertyValueEditor = new MediaPickerPropertyEditor.MediaPickerPropertyValueEditor(dataTypeService, localizationService, localizedTextService, shortStringHelper, attribute); + _richTextPropertyValueEditor = new RichTextPropertyEditor.RichTextPropertyValueEditor(attribute, backOfficeSecurityAccessor, dataTypeService, localizationService, localizedTextService, shortStringHelper, imageSourceParser, localLinkParser, pastedImages, imageUrlGenerator, jsonSerializer); + _mediaPickerPropertyValueEditor = new MediaPickerPropertyEditor.MediaPickerPropertyValueEditor(dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer, attribute); _imageUrlGenerator = imageUrlGenerator; } diff --git a/src/Umbraco.Core/PropertyEditors/ImageCropperConfiguration.cs b/src/Umbraco.Infrastructure/PropertyEditors/ImageCropperConfiguration.cs similarity index 100% rename from src/Umbraco.Core/PropertyEditors/ImageCropperConfiguration.cs rename to src/Umbraco.Infrastructure/PropertyEditors/ImageCropperConfiguration.cs diff --git a/src/Umbraco.Infrastructure/PropertyEditors/ImageCropperPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/ImageCropperPropertyEditor.cs index 3434ee5bcb..1f35b9d88a 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/ImageCropperPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/ImageCropperPropertyEditor.cs @@ -1,17 +1,17 @@ using System; using System.Collections.Generic; using System.Linq; -using Microsoft.Extensions.Options; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Umbraco.Core; using Umbraco.Core.Configuration; using Umbraco.Core.Configuration.Models; using Umbraco.Core.IO; -using Umbraco.Core.Media; using Umbraco.Core.Models; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; using Umbraco.Web.Media; @@ -50,8 +50,9 @@ namespace Umbraco.Web.PropertyEditors IIOHelper ioHelper, IShortStringHelper shortStringHelper, ILocalizedTextService localizedTextService, - UploadAutoFillProperties uploadAutoFillProperties) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + UploadAutoFillProperties uploadAutoFillProperties, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { _mediaFileSystem = mediaFileSystem ?? throw new ArgumentNullException(nameof(mediaFileSystem)); _contentSettings = contentSettings.Value ?? throw new ArgumentNullException(nameof(contentSettings)); @@ -76,7 +77,7 @@ namespace Umbraco.Web.PropertyEditors /// Creates the corresponding property value editor. /// /// The corresponding property value editor. - protected override IDataValueEditor CreateValueEditor() => new ImageCropperPropertyValueEditor(Attribute, LoggerFactory.CreateLogger(), _mediaFileSystem, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, _contentSettings); + protected override IDataValueEditor CreateValueEditor() => new ImageCropperPropertyValueEditor(Attribute, LoggerFactory.CreateLogger(), _mediaFileSystem, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, _contentSettings, JsonSerializer); /// /// Creates the corresponding preValue editor. diff --git a/src/Umbraco.Infrastructure/PropertyEditors/ImageCropperPropertyValueEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/ImageCropperPropertyValueEditor.cs index 6a1f3072d4..c058856ebd 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/ImageCropperPropertyValueEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/ImageCropperPropertyValueEditor.cs @@ -9,6 +9,7 @@ using Umbraco.Core.Models; using Umbraco.Core.Models.Editors; using Umbraco.Core.PropertyEditors; using Umbraco.Core.PropertyEditors.ValueConverters; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; using File = System.IO.File; @@ -32,8 +33,9 @@ namespace Umbraco.Web.PropertyEditors ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, - ContentSettings contentSettings) - : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, attribute) + ContentSettings contentSettings, + IJsonSerializer jsonSerializer) + : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer, attribute) { _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _mediaFileSystem = mediaFileSystem ?? throw new ArgumentNullException(nameof(mediaFileSystem)); diff --git a/src/Umbraco.Infrastructure/PropertyEditors/LabelPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/LabelPropertyEditor.cs index 639a9c928d..78c5087c66 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/LabelPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/LabelPropertyEditor.cs @@ -1,5 +1,6 @@ using Microsoft.Extensions.Logging; using Umbraco.Core.IO; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -21,14 +22,14 @@ namespace Umbraco.Core.PropertyEditors /// /// Initializes a new instance of the class. /// - public LabelPropertyEditor(ILoggerFactory loggerFactory, IIOHelper ioHelper, IDataTypeService dataTypeService, ILocalizedTextService localizedTextService, ILocalizationService localizationService, IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + public LabelPropertyEditor(ILoggerFactory loggerFactory, IIOHelper ioHelper, IDataTypeService dataTypeService, ILocalizedTextService localizedTextService, ILocalizationService localizationService, IShortStringHelper shortStringHelper, IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { _ioHelper = ioHelper; } /// - protected override IDataValueEditor CreateValueEditor() => new LabelPropertyValueEditor(DataTypeService, LocalizationService,LocalizedTextService, ShortStringHelper, Attribute); + protected override IDataValueEditor CreateValueEditor() => new LabelPropertyValueEditor(DataTypeService, LocalizationService,LocalizedTextService, ShortStringHelper, Attribute, JsonSerializer); /// protected override IConfigurationEditor CreateConfigurationEditor() => new LabelConfigurationEditor(_ioHelper); @@ -36,8 +37,8 @@ namespace Umbraco.Core.PropertyEditors // provides the property value editor internal class LabelPropertyValueEditor : DataValueEditor { - public LabelPropertyValueEditor(IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, DataEditorAttribute attribute) - : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, attribute) + public LabelPropertyValueEditor(IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, DataEditorAttribute attribute, IJsonSerializer jsonSerializer) + : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer, attribute) { } /// diff --git a/src/Umbraco.Infrastructure/PropertyEditors/ListViewPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/ListViewPropertyEditor.cs index e01258eb80..d7fd2d9340 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/ListViewPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/ListViewPropertyEditor.cs @@ -2,6 +2,7 @@ using Umbraco.Core; using Umbraco.Core.IO; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -24,15 +25,21 @@ namespace Umbraco.Web.PropertyEditors /// /// Initializes a new instance of the class. /// - /// public ListViewPropertyEditor( ILoggerFactory loggerFactory, IIOHelper iioHelper, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, - IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base( + loggerFactory, + dataTypeService, + localizationService, + localizedTextService, + shortStringHelper, + jsonSerializer) { _iioHelper = iioHelper; } diff --git a/src/Umbraco.Infrastructure/PropertyEditors/MarkdownPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/MarkdownPropertyEditor.cs index ab4e6f3d97..97386de326 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/MarkdownPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/MarkdownPropertyEditor.cs @@ -2,6 +2,7 @@ using Umbraco.Core; using Umbraco.Core.IO; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -30,8 +31,9 @@ namespace Umbraco.Web.PropertyEditors IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, - IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { _ioHelper = ioHelper; } diff --git a/src/Umbraco.Infrastructure/PropertyEditors/MediaPickerPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/MediaPickerPropertyEditor.cs index 476674b1ff..e69ff5be9d 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/MediaPickerPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/MediaPickerPropertyEditor.cs @@ -4,6 +4,7 @@ using Umbraco.Core; using Umbraco.Core.IO; using Umbraco.Core.Models.Editors; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -33,8 +34,9 @@ namespace Umbraco.Web.PropertyEditors ILocalizationService localizationService, IIOHelper ioHelper, IShortStringHelper shortStringHelper, - ILocalizedTextService localizedTextService) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + ILocalizedTextService localizedTextService, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { _ioHelper = ioHelper; } @@ -42,12 +44,18 @@ namespace Umbraco.Web.PropertyEditors /// protected override IConfigurationEditor CreateConfigurationEditor() => new MediaPickerConfigurationEditor(_ioHelper); - protected override IDataValueEditor CreateValueEditor() => new MediaPickerPropertyValueEditor(DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, Attribute); + protected override IDataValueEditor CreateValueEditor() => new MediaPickerPropertyValueEditor(DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, JsonSerializer, Attribute); public class MediaPickerPropertyValueEditor : DataValueEditor, IDataValueReference { - public MediaPickerPropertyValueEditor(IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, DataEditorAttribute attribute) - : base(dataTypeService,localizationService, localizedTextService, shortStringHelper,attribute) + public MediaPickerPropertyValueEditor( + IDataTypeService dataTypeService, + ILocalizationService localizationService, + ILocalizedTextService localizedTextService, + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer, + DataEditorAttribute attribute) + : base(dataTypeService,localizationService, localizedTextService, shortStringHelper, jsonSerializer, attribute) { } diff --git a/src/Umbraco.Infrastructure/PropertyEditors/MultiNodeTreePickerPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/MultiNodeTreePickerPropertyEditor.cs index fc80aabdd9..b7ec4813b2 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/MultiNodeTreePickerPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/MultiNodeTreePickerPropertyEditor.cs @@ -4,6 +4,7 @@ using Umbraco.Core; using Umbraco.Core.IO; using Umbraco.Core.Models.Editors; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -20,20 +21,33 @@ namespace Umbraco.Web.PropertyEditors { private readonly IIOHelper _ioHelper; - public MultiNodeTreePickerPropertyEditor(ILoggerFactory loggerFactory, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IIOHelper ioHelper, IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + public MultiNodeTreePickerPropertyEditor( + ILoggerFactory loggerFactory, + IDataTypeService dataTypeService, + ILocalizationService localizationService, + ILocalizedTextService localizedTextService, + IIOHelper ioHelper, + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { _ioHelper = ioHelper; } protected override IConfigurationEditor CreateConfigurationEditor() => new MultiNodePickerConfigurationEditor(_ioHelper); - protected override IDataValueEditor CreateValueEditor() => new MultiNodeTreePickerPropertyValueEditor(DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, Attribute); + protected override IDataValueEditor CreateValueEditor() => new MultiNodeTreePickerPropertyValueEditor(DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, JsonSerializer, Attribute); public class MultiNodeTreePickerPropertyValueEditor : DataValueEditor, IDataValueReference { - public MultiNodeTreePickerPropertyValueEditor(IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, DataEditorAttribute attribute) - : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, attribute) + public MultiNodeTreePickerPropertyValueEditor( + IDataTypeService dataTypeService, + ILocalizationService localizationService, + ILocalizedTextService localizedTextService, + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer, + DataEditorAttribute attribute) + : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer, attribute) { } diff --git a/src/Umbraco.Infrastructure/PropertyEditors/MultiUrlPickerPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/MultiUrlPickerPropertyEditor.cs index afd749eed3..fdb908e2be 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/MultiUrlPickerPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/MultiUrlPickerPropertyEditor.cs @@ -3,6 +3,7 @@ using Microsoft.Extensions.Logging; using Umbraco.Core; using Umbraco.Core.IO; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; using Umbraco.Web.PublishedCache; @@ -26,8 +27,19 @@ namespace Umbraco.Web.PropertyEditors private readonly IUmbracoContextAccessor _umbracoContextAccessor; private readonly IPublishedUrlProvider _publishedUrlProvider; - public MultiUrlPickerPropertyEditor(ILoggerFactory loggerFactory, Lazy entityService, IPublishedSnapshotAccessor publishedSnapshotAccessor, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IIOHelper ioHelper, IShortStringHelper shortStringHelper, IUmbracoContextAccessor umbracoContextAccessor, IPublishedUrlProvider publishedUrlProvider) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, EditorType.PropertyValue) + public MultiUrlPickerPropertyEditor( + ILoggerFactory loggerFactory, + Lazy entityService, + IPublishedSnapshotAccessor publishedSnapshotAccessor, + IDataTypeService dataTypeService, + ILocalizationService localizationService, + ILocalizedTextService localizedTextService, + IIOHelper ioHelper, + IShortStringHelper shortStringHelper, + IUmbracoContextAccessor umbracoContextAccessor, + IPublishedUrlProvider publishedUrlProvider, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer, EditorType.PropertyValue) { _entityService = entityService ?? throw new ArgumentNullException(nameof(entityService)); _publishedSnapshotAccessor = publishedSnapshotAccessor ?? throw new ArgumentNullException(nameof(publishedSnapshotAccessor)); @@ -38,6 +50,6 @@ namespace Umbraco.Web.PropertyEditors protected override IConfigurationEditor CreateConfigurationEditor() => new MultiUrlPickerConfigurationEditor(_ioHelper); - protected override IDataValueEditor CreateValueEditor() => new MultiUrlPickerValueEditor(_entityService.Value, _publishedSnapshotAccessor, LoggerFactory.CreateLogger(), DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, Attribute, _umbracoContextAccessor, _publishedUrlProvider); + protected override IDataValueEditor CreateValueEditor() => new MultiUrlPickerValueEditor(_entityService.Value, _publishedSnapshotAccessor, LoggerFactory.CreateLogger(), DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, Attribute, _umbracoContextAccessor, _publishedUrlProvider, JsonSerializer); } } diff --git a/src/Umbraco.Infrastructure/PropertyEditors/MultiUrlPickerValueEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/MultiUrlPickerValueEditor.cs index 380408c2b1..a4427cd26d 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/MultiUrlPickerValueEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/MultiUrlPickerValueEditor.cs @@ -1,14 +1,15 @@ -using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; using Microsoft.Extensions.Logging; +using Newtonsoft.Json; using Umbraco.Core; using Umbraco.Core.Models; using Umbraco.Core.Models.Editors; using Umbraco.Core.Models.Entities; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; using Umbraco.Web.Models.ContentEditing; @@ -25,8 +26,19 @@ namespace Umbraco.Web.PropertyEditors private readonly IPublishedUrlProvider _publishedUrlProvider; private readonly IPublishedSnapshotAccessor _publishedSnapshotAccessor; - public MultiUrlPickerValueEditor(IEntityService entityService, IPublishedSnapshotAccessor publishedSnapshotAccessor, ILogger logger, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, DataEditorAttribute attribute, IUmbracoContextAccessor umbracoContextAccessor, IPublishedUrlProvider publishedUrlProvider) - : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, attribute) + public MultiUrlPickerValueEditor( + IEntityService entityService, + IPublishedSnapshotAccessor publishedSnapshotAccessor, + ILogger logger, + IDataTypeService dataTypeService, + ILocalizationService localizationService, + ILocalizedTextService localizedTextService, + IShortStringHelper shortStringHelper, + DataEditorAttribute attribute, + IUmbracoContextAccessor umbracoContextAccessor, + IPublishedUrlProvider publishedUrlProvider, + IJsonSerializer jsonSerializer) + : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer, attribute) { _entityService = entityService ?? throw new ArgumentNullException(nameof(entityService)); _publishedSnapshotAccessor = publishedSnapshotAccessor ?? throw new ArgumentNullException(nameof(publishedSnapshotAccessor)); diff --git a/src/Umbraco.Infrastructure/PropertyEditors/MultipleTextStringPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/MultipleTextStringPropertyEditor.cs index b4e1287315..c9aeb0e59a 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/MultipleTextStringPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/MultipleTextStringPropertyEditor.cs @@ -11,6 +11,7 @@ using Umbraco.Core.Models; using Umbraco.Core.Models.Editors; using Umbraco.Core.PropertyEditors; using Umbraco.Core.PropertyEditors.Validators; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -36,8 +37,15 @@ namespace Umbraco.Web.PropertyEditors /// /// Initializes a new instance of the class. /// - public MultipleTextStringPropertyEditor(ILoggerFactory loggerFactory, IIOHelper ioHelper, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + public MultipleTextStringPropertyEditor( + ILoggerFactory loggerFactory, + IIOHelper ioHelper, + IDataTypeService dataTypeService, + ILocalizationService localizationService, + ILocalizedTextService localizedTextService, + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { _ioHelper = ioHelper; _dataTypeService = dataTypeService; @@ -46,7 +54,7 @@ namespace Umbraco.Web.PropertyEditors } /// - protected override IDataValueEditor CreateValueEditor() => new MultipleTextStringPropertyValueEditor(_dataTypeService, _localizationService, _localizedTextService, ShortStringHelper, Attribute); + protected override IDataValueEditor CreateValueEditor() => new MultipleTextStringPropertyValueEditor(_dataTypeService, _localizationService, _localizedTextService, ShortStringHelper, JsonSerializer, Attribute); /// protected override IConfigurationEditor CreateConfigurationEditor() => new MultipleTextStringConfigurationEditor(_ioHelper); @@ -58,8 +66,14 @@ namespace Umbraco.Web.PropertyEditors { private readonly ILocalizedTextService _localizedTextService; - public MultipleTextStringPropertyValueEditor(IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, DataEditorAttribute attribute) - : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, attribute) + public MultipleTextStringPropertyValueEditor( + IDataTypeService dataTypeService, + ILocalizationService localizationService, + ILocalizedTextService localizedTextService, + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer, + DataEditorAttribute attribute) + : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer, attribute) { _localizedTextService = localizedTextService; } diff --git a/src/Umbraco.Infrastructure/PropertyEditors/MultipleValueEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/MultipleValueEditor.cs index a960ac51ad..5f82ed940f 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/MultipleValueEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/MultipleValueEditor.cs @@ -5,6 +5,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Umbraco.Core.Models; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -20,8 +21,16 @@ namespace Umbraco.Web.PropertyEditors { private readonly ILogger _logger; - public MultipleValueEditor(ILogger logger, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, DataEditorAttribute attribute) - : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, attribute) + public MultipleValueEditor( + ILogger logger, + IDataTypeService dataTypeService, + ILocalizationService localizationService, + ILocalizedTextService localizedTextService, + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer, + DataEditorAttribute attribute + ) + : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer, attribute) { _logger = logger; } diff --git a/src/Umbraco.Infrastructure/PropertyEditors/NestedContentPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/NestedContentPropertyEditor.cs index 98f8771699..8afc08c423 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/NestedContentPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/NestedContentPropertyEditor.cs @@ -9,6 +9,7 @@ using Umbraco.Core.IO; using Umbraco.Core.Models; using Umbraco.Core.Models.Editors; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -42,8 +43,9 @@ namespace Umbraco.Web.PropertyEditors IContentTypeService contentTypeService, IIOHelper ioHelper, IShortStringHelper shortStringHelper, - ILocalizedTextService localizedTextService) - : base (loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + ILocalizedTextService localizedTextService, + IJsonSerializer jsonSerializer) + : base (loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { _propertyEditors = propertyEditors; _contentTypeService = contentTypeService; @@ -62,7 +64,7 @@ namespace Umbraco.Web.PropertyEditors #region Value Editor - protected override IDataValueEditor CreateValueEditor() => new NestedContentPropertyValueEditor(DataTypeService, LocalizationService, LocalizedTextService, _contentTypeService, ShortStringHelper, Attribute, PropertyEditors, LoggerFactory.CreateLogger()); + protected override IDataValueEditor CreateValueEditor() => new NestedContentPropertyValueEditor(DataTypeService, LocalizationService, LocalizedTextService, _contentTypeService, ShortStringHelper, Attribute, PropertyEditors, LoggerFactory.CreateLogger(), JsonSerializer); internal class NestedContentPropertyValueEditor : DataValueEditor, IDataValueReference { @@ -82,8 +84,9 @@ namespace Umbraco.Web.PropertyEditors IShortStringHelper shortStringHelper, DataEditorAttribute attribute, PropertyEditorCollection propertyEditors, - ILogger logger) - : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, attribute) + ILogger logger, + IJsonSerializer jsonSerializer) + : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer, attribute) { _propertyEditors = propertyEditors; _contentTypeService = contentTypeService; diff --git a/src/Umbraco.Infrastructure/PropertyEditors/RadioButtonsPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/RadioButtonsPropertyEditor.cs index 6a863b1dd1..444e99bd23 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/RadioButtonsPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/RadioButtonsPropertyEditor.cs @@ -2,6 +2,7 @@ using Umbraco.Core; using Umbraco.Core.IO; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -30,8 +31,9 @@ namespace Umbraco.Web.PropertyEditors IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, - IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService, localizationService,localizedTextService, shortStringHelper) + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService,localizedTextService, shortStringHelper, jsonSerializer) { _ioHelper = ioHelper; } diff --git a/src/Umbraco.Infrastructure/PropertyEditors/RichTextPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/RichTextPropertyEditor.cs index 049f020db4..e97b8c0520 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/RichTextPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/RichTextPropertyEditor.cs @@ -8,6 +8,7 @@ using Umbraco.Core.Models; using Umbraco.Core.Models.Editors; using Umbraco.Core.PropertyEditors; using Umbraco.Core.Security; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; using Umbraco.Examine; @@ -50,8 +51,9 @@ namespace Umbraco.Web.PropertyEditors IShortStringHelper shortStringHelper, IIOHelper ioHelper, ILocalizedTextService localizedTextService, - IImageUrlGenerator imageUrlGenerator) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + IImageUrlGenerator imageUrlGenerator, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { _backOfficeSecurityAccessor = backOfficeSecurityAccessor; _imageSourceParser = imageSourceParser; @@ -65,7 +67,7 @@ namespace Umbraco.Web.PropertyEditors /// Create a custom value editor /// /// - protected override IDataValueEditor CreateValueEditor() => new RichTextPropertyValueEditor(Attribute, _backOfficeSecurityAccessor, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, _imageSourceParser, _localLinkParser, _pastedImages, _imageUrlGenerator); + protected override IDataValueEditor CreateValueEditor() => new RichTextPropertyValueEditor(Attribute, _backOfficeSecurityAccessor, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, _imageSourceParser, _localLinkParser, _pastedImages, _imageUrlGenerator, JsonSerializer); protected override IConfigurationEditor CreateConfigurationEditor() => new RichTextConfigurationEditor(_ioHelper); @@ -92,8 +94,9 @@ namespace Umbraco.Web.PropertyEditors HtmlImageSourceParser imageSourceParser, HtmlLocalLinkParser localLinkParser, RichTextEditorPastedImages pastedImages, - IImageUrlGenerator imageUrlGenerator) - : base(dataTypeService, localizationService,localizedTextService, shortStringHelper, attribute) + IImageUrlGenerator imageUrlGenerator, + IJsonSerializer jsonSerializer) + : base(dataTypeService, localizationService,localizedTextService, shortStringHelper, jsonSerializer, attribute) { _backOfficeSecurityAccessor = backOfficeSecurityAccessor; _imageSourceParser = imageSourceParser; diff --git a/src/Umbraco.Infrastructure/PropertyEditors/SliderPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/SliderPropertyEditor.cs index bb62c3461d..48197691a2 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/SliderPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/SliderPropertyEditor.cs @@ -2,6 +2,7 @@ using Umbraco.Core; using Umbraco.Core.IO; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -28,8 +29,9 @@ namespace Umbraco.Web.PropertyEditors IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, - IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { _ioHelper = ioHelper; } diff --git a/src/Umbraco.Infrastructure/PropertyEditors/TagsPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/TagsPropertyEditor.cs index 708f4d8c9f..a2fb340d14 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/TagsPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/TagsPropertyEditor.cs @@ -8,6 +8,7 @@ using Umbraco.Core; using Umbraco.Core.IO; using Umbraco.Core.Models.Editors; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -34,21 +35,22 @@ namespace Umbraco.Web.PropertyEditors IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, - IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { _validators = validators; _ioHelper = ioHelper; } - protected override IDataValueEditor CreateValueEditor() => new TagPropertyValueEditor(DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, Attribute); + protected override IDataValueEditor CreateValueEditor() => new TagPropertyValueEditor(DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, JsonSerializer, Attribute); protected override IConfigurationEditor CreateConfigurationEditor() => new TagConfigurationEditor(_validators, _ioHelper, LocalizedTextService); internal class TagPropertyValueEditor : DataValueEditor { - public TagPropertyValueEditor(IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, DataEditorAttribute attribute) - : base(dataTypeService, localizationService,localizedTextService, shortStringHelper, attribute) + public TagPropertyValueEditor(IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, IJsonSerializer jsonSerializer, DataEditorAttribute attribute) + : base(dataTypeService, localizationService,localizedTextService, shortStringHelper, jsonSerializer, attribute) { } /// diff --git a/src/Umbraco.Infrastructure/PropertyEditors/TextAreaPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/TextAreaPropertyEditor.cs index 8d173e58bc..d65f6f3a1d 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/TextAreaPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/TextAreaPropertyEditor.cs @@ -2,6 +2,7 @@ using Umbraco.Core; using Umbraco.Core.IO; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -28,8 +29,15 @@ namespace Umbraco.Web.PropertyEditors /// /// Initializes a new instance of the class. /// - public TextAreaPropertyEditor(ILoggerFactory loggerFactory, IDataTypeService dataTypeService, ILocalizationService localizationService, IIOHelper ioHelper, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService,shortStringHelper) + public TextAreaPropertyEditor( + ILoggerFactory loggerFactory, + IDataTypeService dataTypeService, + ILocalizationService localizationService, + IIOHelper ioHelper, + ILocalizedTextService localizedTextService, + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { _dataTypeService = dataTypeService; _localizationService = localizationService; @@ -39,7 +47,7 @@ namespace Umbraco.Web.PropertyEditors } /// - protected override IDataValueEditor CreateValueEditor() => new TextOnlyValueEditor(_dataTypeService, _localizationService, Attribute, _localizedTextService, _shortStringHelper); + protected override IDataValueEditor CreateValueEditor() => new TextOnlyValueEditor(_dataTypeService, _localizationService, Attribute, _localizedTextService, _shortStringHelper, JsonSerializer); /// protected override IConfigurationEditor CreateConfigurationEditor() => new TextAreaConfigurationEditor(_ioHelper); diff --git a/src/Umbraco.Infrastructure/PropertyEditors/TextboxPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/TextboxPropertyEditor.cs index 1ec87abe9b..350dd4a1ff 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/TextboxPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/TextboxPropertyEditor.cs @@ -2,6 +2,7 @@ using Umbraco.Core; using Umbraco.Core.IO; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -27,8 +28,15 @@ namespace Umbraco.Web.PropertyEditors /// /// Initializes a new instance of the class. /// - public TextboxPropertyEditor(ILoggerFactory loggerFactory, IDataTypeService dataTypeService, ILocalizationService localizationService, IIOHelper ioHelper, IShortStringHelper shortStringHelper, ILocalizedTextService localizedTextService) - : base(loggerFactory, dataTypeService, localizationService,localizedTextService, shortStringHelper) + public TextboxPropertyEditor( + ILoggerFactory loggerFactory, + IDataTypeService dataTypeService, + ILocalizationService localizationService, + IIOHelper ioHelper, + IShortStringHelper shortStringHelper, + ILocalizedTextService localizedTextService, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService,localizedTextService, shortStringHelper, jsonSerializer) { _dataTypeService = dataTypeService; _localizationService = localizationService; @@ -38,7 +46,7 @@ namespace Umbraco.Web.PropertyEditors } /// - protected override IDataValueEditor CreateValueEditor() => new TextOnlyValueEditor(_dataTypeService, _localizationService, Attribute, _localizedTextService, _shortStringHelper); + protected override IDataValueEditor CreateValueEditor() => new TextOnlyValueEditor(DataTypeService, LocalizationService, Attribute, LocalizedTextService, ShortStringHelper, JsonSerializer); /// protected override IConfigurationEditor CreateConfigurationEditor() => new TextboxConfigurationEditor(_ioHelper); diff --git a/src/Umbraco.Infrastructure/PropertyEditors/TrueFalsePropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/TrueFalsePropertyEditor.cs index db72887fff..3c9599c643 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/TrueFalsePropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/TrueFalsePropertyEditor.cs @@ -2,6 +2,7 @@ using Umbraco.Core; using Umbraco.Core.IO; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -25,8 +26,15 @@ namespace Umbraco.Web.PropertyEditors /// /// Initializes a new instance of the class. /// - public TrueFalsePropertyEditor(ILoggerFactory loggerFactory, IDataTypeService dataTypeService, ILocalizationService localizationService, IIOHelper ioHelper, IShortStringHelper shortStringHelper, ILocalizedTextService localizedTextService) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + public TrueFalsePropertyEditor( + ILoggerFactory loggerFactory, + IDataTypeService dataTypeService, + ILocalizationService localizationService, + IIOHelper ioHelper, + IShortStringHelper shortStringHelper, + ILocalizedTextService localizedTextService, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { _ioHelper = ioHelper; } diff --git a/src/Umbraco.Infrastructure/Services/Implement/DataTypeService.cs b/src/Umbraco.Infrastructure/Services/Implement/DataTypeService.cs index eb6a94c4ee..042128558b 100644 --- a/src/Umbraco.Infrastructure/Services/Implement/DataTypeService.cs +++ b/src/Umbraco.Infrastructure/Services/Implement/DataTypeService.cs @@ -6,11 +6,11 @@ using Umbraco.Core.Events; using Umbraco.Core.Exceptions; using Umbraco.Core.IO; using Umbraco.Core.Models; -using Umbraco.Core.Persistence.Dtos; using Umbraco.Core.Persistence.Repositories; using Umbraco.Core.Persistence.Repositories.Implement; using Umbraco.Core.PropertyEditors; using Umbraco.Core.Scoping; +using Umbraco.Core.Serialization; using Umbraco.Core.Strings; namespace Umbraco.Core.Services.Implement @@ -29,11 +29,14 @@ namespace Umbraco.Core.Services.Implement private readonly ILocalizedTextService _localizedTextService; private readonly ILocalizationService _localizationService; private readonly IShortStringHelper _shortStringHelper; + private readonly IJsonSerializer _jsonSerializer; public DataTypeService(IScopeProvider provider, ILoggerFactory loggerFactory, IEventMessagesFactory eventMessagesFactory, IDataTypeRepository dataTypeRepository, IDataTypeContainerRepository dataTypeContainerRepository, IAuditRepository auditRepository, IEntityRepository entityRepository, IContentTypeRepository contentTypeRepository, - IIOHelper ioHelper, ILocalizedTextService localizedTextService, ILocalizationService localizationService, IShortStringHelper shortStringHelper) + IIOHelper ioHelper, ILocalizedTextService localizedTextService, ILocalizationService localizationService, + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) : base(provider, loggerFactory, eventMessagesFactory) { _dataTypeRepository = dataTypeRepository; @@ -45,6 +48,7 @@ namespace Umbraco.Core.Services.Implement _localizedTextService = localizedTextService; _localizationService = localizationService; _shortStringHelper = shortStringHelper; + _jsonSerializer = jsonSerializer; } #region Containers @@ -324,7 +328,7 @@ namespace Umbraco.Core.Services.Implement .Where(x => x.Editor is MissingPropertyEditor); foreach (var dataType in dataTypesWithMissingEditors) { - dataType.Editor = new LabelPropertyEditor(LoggerFactory, _ioHelper, this, _localizedTextService, _localizationService, _shortStringHelper); + dataType.Editor = new LabelPropertyEditor(LoggerFactory, _ioHelper, this, _localizedTextService, _localizationService, _shortStringHelper, _jsonSerializer); } } diff --git a/src/Umbraco.Tests.Common/Builders/DataEditorBuilder.cs b/src/Umbraco.Tests.Common/Builders/DataEditorBuilder.cs index f7185d1620..4cc7b3ad8e 100644 --- a/src/Umbraco.Tests.Common/Builders/DataEditorBuilder.cs +++ b/src/Umbraco.Tests.Common/Builders/DataEditorBuilder.cs @@ -1,8 +1,8 @@ using System.Collections.Generic; using Microsoft.Extensions.Logging.Abstractions; using Moq; -using Umbraco.Core.Logging; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -43,7 +43,8 @@ namespace Umbraco.Tests.Common.Builders Mock.Of(), Mock.Of(), Mock.Of(), - Mock.Of() + Mock.Of(), + Mock.Of() ) { DefaultConfiguration = defaultConfiguration, diff --git a/src/Umbraco.Tests.Common/Builders/DataValueEditorBuilder.cs b/src/Umbraco.Tests.Common/Builders/DataValueEditorBuilder.cs index ecc2649c02..bd6966bbeb 100644 --- a/src/Umbraco.Tests.Common/Builders/DataValueEditorBuilder.cs +++ b/src/Umbraco.Tests.Common/Builders/DataValueEditorBuilder.cs @@ -1,6 +1,7 @@ using System; using Moq; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -52,7 +53,8 @@ namespace Umbraco.Tests.Common.Builders Mock.Of(), Mock.Of(), Mock.Of(), - Mock.Of() + Mock.Of(), + Mock.Of() ) { Configuration = configuration, diff --git a/src/Umbraco.Tests.Common/TestHelpers/MockedValueEditors.cs b/src/Umbraco.Tests.Common/TestHelpers/MockedValueEditors.cs index 78aa0c7bc6..b80a2996ca 100644 --- a/src/Umbraco.Tests.Common/TestHelpers/MockedValueEditors.cs +++ b/src/Umbraco.Tests.Common/TestHelpers/MockedValueEditors.cs @@ -1,5 +1,6 @@ using Moq; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -16,6 +17,7 @@ namespace Umbraco.Tests.TestHelpers.Entities Mock.Of(), Mock.Of(), Mock.Of(), + new JsonNetSerializer(), new DataEditorAttribute(name, name, name) { ValueType = valueType diff --git a/src/Umbraco.Tests.Common/TestHelpers/SolidPublishedSnapshot.cs b/src/Umbraco.Tests.Common/TestHelpers/SolidPublishedSnapshot.cs index 958b7e558b..e7f6cc4442 100644 --- a/src/Umbraco.Tests.Common/TestHelpers/SolidPublishedSnapshot.cs +++ b/src/Umbraco.Tests.Common/TestHelpers/SolidPublishedSnapshot.cs @@ -5,7 +5,6 @@ using Microsoft.Extensions.Logging; using Moq; using Umbraco.Core; using Umbraco.Core.Cache; -using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Models.PublishedContent; using Umbraco.Core.PropertyEditors; @@ -412,11 +411,12 @@ namespace Umbraco.Tests.Common.PublishedContent static AutoPublishedContentType() { - var serializer = new ConfigurationEditorJsonSerializer(); + var configurationEditorJsonSerializer = new ConfigurationEditorJsonSerializer(); + var jsonSerializer = new JsonNetSerializer(); var dataTypeServiceMock = new Mock(); var dataType = new DataType(new VoidEditor(Mock.Of(), dataTypeServiceMock.Object, - Mock.Of(), Mock.Of(), Mock.Of()), serializer) + Mock.Of(), Mock.Of(), Mock.Of(), jsonSerializer), configurationEditorJsonSerializer) { Id = 666 }; dataTypeServiceMock.Setup(x => x.GetAll()).Returns(dataType.Yield); diff --git a/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/DataTypeDefinitionRepositoryTest.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/DataTypeDefinitionRepositoryTest.cs index ebfcd3e7de..c94b708ff9 100644 --- a/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/DataTypeDefinitionRepositoryTest.cs +++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/DataTypeDefinitionRepositoryTest.cs @@ -3,11 +3,11 @@ using NUnit.Framework; using Umbraco.Core; using Umbraco.Core.Models; using Umbraco.Core.Persistence.Repositories; -using Umbraco.Tests.Testing; using Umbraco.Core.PropertyEditors; using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Tests.Integration.Testing; +using Umbraco.Tests.Testing; using Umbraco.Web.PropertyEditors; namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositories @@ -23,15 +23,16 @@ namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositor private IDataTypeContainerRepository DataTypeContainerRepository => GetRequiredService(); private IDataTypeRepository DataTypeRepository => GetRequiredService(); private IConfigurationEditorJsonSerializer ConfigurationEditorJsonSerializer => GetRequiredService(); + private IJsonSerializer JsonSerializer => GetRequiredService(); [Test] public void Can_Find_Usages() { using (ScopeProvider.CreateScope()) { - IDataType dataType1 = new DataType(new RadioButtonsPropertyEditor(LoggerFactory, IOHelper, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper), ConfigurationEditorJsonSerializer) { Name = "dt1" }; + IDataType dataType1 = new DataType(new RadioButtonsPropertyEditor(LoggerFactory, IOHelper, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, JsonSerializer), ConfigurationEditorJsonSerializer) { Name = "dt1" }; DataTypeRepository.Save(dataType1); - IDataType dataType2 = new DataType(new RadioButtonsPropertyEditor(LoggerFactory, IOHelper, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper), ConfigurationEditorJsonSerializer) { Name = "dt2" }; + IDataType dataType2 = new DataType(new RadioButtonsPropertyEditor(LoggerFactory, IOHelper, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, JsonSerializer), ConfigurationEditorJsonSerializer) { Name = "dt2" }; DataTypeRepository.Save(dataType2); IContentType ct = new ContentType(ShortStringHelper, -1) @@ -94,14 +95,14 @@ namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositor var container2 = new EntityContainer(Constants.ObjectTypes.DataType) { Name = "blah2", ParentId = container1.Id }; DataTypeContainerRepository.Save(container2); - var dataType = (IDataType) new DataType(new RadioButtonsPropertyEditor(LoggerFactory, IOHelper, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper), ConfigurationEditorJsonSerializer, container2.Id) + var dataType = (IDataType) new DataType(new RadioButtonsPropertyEditor(LoggerFactory, IOHelper, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, JsonSerializer), ConfigurationEditorJsonSerializer, container2.Id) { Name = "dt1" }; DataTypeRepository.Save(dataType); //create a - var dataType2 = (IDataType)new DataType(new RadioButtonsPropertyEditor(LoggerFactory, IOHelper, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper), ConfigurationEditorJsonSerializer, dataType.Id) + var dataType2 = (IDataType)new DataType(new RadioButtonsPropertyEditor(LoggerFactory, IOHelper, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, JsonSerializer), ConfigurationEditorJsonSerializer, dataType.Id) { Name = "dt2" }; @@ -160,7 +161,7 @@ namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositor var container = new EntityContainer(Constants.ObjectTypes.DataType) { Name = "blah" }; DataTypeContainerRepository.Save(container); - var dataTypeDefinition = new DataType(new RadioButtonsPropertyEditor(LoggerFactory, IOHelper, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper), ConfigurationEditorJsonSerializer, container.Id) { Name = "test" }; + var dataTypeDefinition = new DataType(new RadioButtonsPropertyEditor(LoggerFactory, IOHelper, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, JsonSerializer), ConfigurationEditorJsonSerializer, container.Id) { Name = "test" }; DataTypeRepository.Save(dataTypeDefinition); Assert.AreEqual(container.Id, dataTypeDefinition.ParentId); @@ -175,7 +176,7 @@ namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositor var container = new EntityContainer(Constants.ObjectTypes.DataType) { Name = "blah" }; DataTypeContainerRepository.Save(container); - IDataType dataType = new DataType(new RadioButtonsPropertyEditor(LoggerFactory, IOHelper, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper), ConfigurationEditorJsonSerializer, container.Id) { Name = "test" }; + IDataType dataType = new DataType(new RadioButtonsPropertyEditor(LoggerFactory, IOHelper, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, JsonSerializer), ConfigurationEditorJsonSerializer, container.Id) { Name = "test" }; DataTypeRepository.Save(dataType); // Act @@ -195,7 +196,7 @@ namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositor { using (ScopeProvider.CreateScope()) { - IDataType dataType = new DataType(new RadioButtonsPropertyEditor(LoggerFactory, IOHelper, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper), ConfigurationEditorJsonSerializer) {Name = "test"}; + IDataType dataType = new DataType(new RadioButtonsPropertyEditor(LoggerFactory, IOHelper, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, JsonSerializer), ConfigurationEditorJsonSerializer) {Name = "test"}; DataTypeRepository.Save(dataType); @@ -295,7 +296,7 @@ namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositor { using (ScopeProvider.CreateScope()) { - var dataTypeDefinition = new DataType(new LabelPropertyEditor(LoggerFactory, IOHelper, DataTypeService, LocalizedTextService, LocalizationService, ShortStringHelper), ConfigurationEditorJsonSerializer) + var dataTypeDefinition = new DataType(new LabelPropertyEditor(LoggerFactory, IOHelper, DataTypeService, LocalizedTextService, LocalizationService, ShortStringHelper, JsonSerializer), ConfigurationEditorJsonSerializer) { DatabaseType = ValueStorageType.Integer, Name = "AgeDataType", @@ -330,7 +331,7 @@ namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositor { using (ScopeProvider.CreateScope()) { - var dataTypeDefinition = new DataType(new IntegerPropertyEditor(LoggerFactory, DataTypeService, LocalizationService, ShortStringHelper, LocalizedTextService), ConfigurationEditorJsonSerializer) + var dataTypeDefinition = new DataType(new IntegerPropertyEditor(LoggerFactory, DataTypeService, LocalizationService, ShortStringHelper, LocalizedTextService, JsonSerializer), ConfigurationEditorJsonSerializer) { DatabaseType = ValueStorageType.Integer, Name = "AgeDataType", @@ -341,7 +342,7 @@ namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositor // Act var definition = DataTypeRepository.Get(dataTypeDefinition.Id); definition.Name = "AgeDataType Updated"; - definition.Editor = new LabelPropertyEditor(LoggerFactory, IOHelper, DataTypeService, LocalizedTextService, LocalizationService, ShortStringHelper); //change + definition.Editor = new LabelPropertyEditor(LoggerFactory, IOHelper, DataTypeService, LocalizedTextService, LocalizationService, ShortStringHelper, JsonSerializer); //change DataTypeRepository.Save(definition); var definitionUpdated = DataTypeRepository.Get(dataTypeDefinition.Id); @@ -358,7 +359,7 @@ namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositor { using (ScopeProvider.CreateScope()) { - var dataTypeDefinition = new DataType(new LabelPropertyEditor(LoggerFactory, IOHelper, DataTypeService,LocalizedTextService, LocalizationService, ShortStringHelper), ConfigurationEditorJsonSerializer) + var dataTypeDefinition = new DataType(new LabelPropertyEditor(LoggerFactory, IOHelper, DataTypeService,LocalizedTextService, LocalizationService, ShortStringHelper, JsonSerializer), ConfigurationEditorJsonSerializer) { DatabaseType = ValueStorageType.Integer, Name = "AgeDataType", diff --git a/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/CachedDataTypeServiceTests.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/CachedDataTypeServiceTests.cs index 4dbc7b3efc..3c03be2a95 100644 --- a/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/CachedDataTypeServiceTests.cs +++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/CachedDataTypeServiceTests.cs @@ -21,6 +21,7 @@ namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Services private ILocalizedTextService LocalizedTextService => GetRequiredService(); private ILocalizationService LocalizationService => GetRequiredService(); private IConfigurationEditorJsonSerializer ConfigurationEditorJsonSerializer => GetRequiredService(); + private IJsonSerializer JsonSerializer => GetRequiredService(); /// /// This tests validates that with the new scope changes that the underlying cache policies work - in this case it tests that the cache policy @@ -29,7 +30,7 @@ namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Services [Test] public void DataTypeService_Can_Get_All() { - IDataType dataType = new DataType(new LabelPropertyEditor(LoggerFactory, IOHelper, DataTypeService, LocalizedTextService, LocalizationService, ShortStringHelper), ConfigurationEditorJsonSerializer) { Name = "Testing Textfield", DatabaseType = ValueStorageType.Ntext }; + IDataType dataType = new DataType(new LabelPropertyEditor(LoggerFactory, IOHelper, DataTypeService, LocalizedTextService, LocalizationService, ShortStringHelper, JsonSerializer), ConfigurationEditorJsonSerializer) { Name = "Testing Textfield", DatabaseType = ValueStorageType.Ntext }; DataTypeService.Save(dataType); //Get all the first time (no cache) diff --git a/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/DataTypeServiceTests.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/DataTypeServiceTests.cs index 0af3ae6fb5..2de7fb6b2a 100644 --- a/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/DataTypeServiceTests.cs +++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/DataTypeServiceTests.cs @@ -26,12 +26,13 @@ namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Services private ILocalizedTextService LocalizedTextService => GetRequiredService(); private ILocalizationService LocalizationService => GetRequiredService(); private IConfigurationEditorJsonSerializer ConfigurationEditorJsonSerializer => GetRequiredService(); + private IJsonSerializer JsonSerializer => GetRequiredService(); [Test] public void DataTypeService_Can_Persist_New_DataTypeDefinition() { // Act - IDataType dataType = new DataType(new LabelPropertyEditor(LoggerFactory, IOHelper, DataTypeService, LocalizedTextService, LocalizationService, ShortStringHelper), ConfigurationEditorJsonSerializer) { Name = "Testing Textfield", DatabaseType = ValueStorageType.Ntext }; + IDataType dataType = new DataType(new LabelPropertyEditor(LoggerFactory, IOHelper, DataTypeService, LocalizedTextService, LocalizationService, ShortStringHelper, JsonSerializer), ConfigurationEditorJsonSerializer) { Name = "Testing Textfield", DatabaseType = ValueStorageType.Ntext }; DataTypeService.Save(dataType); // Assert @@ -74,7 +75,7 @@ namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Services public void Cannot_Save_DataType_With_Empty_Name() { // Act - var dataTypeDefinition = new DataType(new LabelPropertyEditor(LoggerFactory, IOHelper, DataTypeService, LocalizedTextService,LocalizationService, ShortStringHelper), ConfigurationEditorJsonSerializer) { Name = string.Empty, DatabaseType = ValueStorageType.Ntext }; + var dataTypeDefinition = new DataType(new LabelPropertyEditor(LoggerFactory, IOHelper, DataTypeService, LocalizedTextService,LocalizationService, ShortStringHelper, JsonSerializer), ConfigurationEditorJsonSerializer) { Name = string.Empty, DatabaseType = ValueStorageType.Ntext }; // Act & Assert Assert.Throws(() => DataTypeService.Save(dataTypeDefinition)); diff --git a/src/Umbraco.Tests.Integration/Umbraco.Web.BackOffice/Filters/ContentModelValidatorTests.cs b/src/Umbraco.Tests.Integration/Umbraco.Web.BackOffice/Filters/ContentModelValidatorTests.cs index 2960455a70..dc88455d68 100644 --- a/src/Umbraco.Tests.Integration/Umbraco.Web.BackOffice/Filters/ContentModelValidatorTests.cs +++ b/src/Umbraco.Tests.Integration/Umbraco.Web.BackOffice/Filters/ContentModelValidatorTests.cs @@ -13,7 +13,6 @@ using Umbraco.Core.IO; using Umbraco.Core.Mapping; using Umbraco.Core.Models; using Umbraco.Core.PropertyEditors; -using Umbraco.Core.Security; using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -273,8 +272,8 @@ namespace Umbraco.Tests.Integration.Umbraco.Web.Backoffice.Filters public class ComplexTestEditor : NestedContentPropertyEditor { public ComplexTestEditor(ILoggerFactory loggerFactory, Lazy propertyEditors, IDataTypeService dataTypeService, IContentTypeService contentTypeService, ILocalizationService localizationService, - IIOHelper ioHelper, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper) - : base(loggerFactory, propertyEditors, dataTypeService, localizationService, contentTypeService, ioHelper, shortStringHelper, localizedTextService) + IIOHelper ioHelper, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, IJsonSerializer jsonSerializer) + : base(loggerFactory, propertyEditors, dataTypeService, localizationService, contentTypeService, ioHelper, shortStringHelper, localizedTextService, jsonSerializer) { } @@ -290,17 +289,19 @@ namespace Umbraco.Tests.Integration.Umbraco.Web.Backoffice.Filters [DataEditor("test", "test", "test")] // This alias aligns with the prop editor alias for all properties created from MockedContentTypes.CreateTextPageContentType public class TestEditor : DataEditor { - public TestEditor(ILoggerFactory loggerFactory, - IDataTypeService dataTypeService, - ILocalizationService localizationService, - ILocalizedTextService localizedTextService, - IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + public TestEditor( + ILoggerFactory loggerFactory, + IDataTypeService dataTypeService, + ILocalizationService localizationService, + ILocalizedTextService localizedTextService, + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { } - protected override IDataValueEditor CreateValueEditor() => new TestValueEditor(DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, Attribute); + protected override IDataValueEditor CreateValueEditor() => new TestValueEditor(DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, JsonSerializer, Attribute); private class TestValueEditor : DataValueEditor { @@ -309,8 +310,9 @@ namespace Umbraco.Tests.Integration.Umbraco.Web.Backoffice.Filters ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer, DataEditorAttribute attribute) - : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, attribute) + : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer, attribute) { Validators.Add(new NeverValidateValidator()); } diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Models/VariationTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Models/VariationTests.cs index 81c868656e..cab26fd7d2 100644 --- a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Models/VariationTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Models/VariationTests.cs @@ -585,6 +585,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.Models var localizedTextService = Mock.Of(); var localizationService = Mock.Of(); var shortStringHelper = Mock.Of(); + var jsonSerializer = Mock.Of(); var textBoxEditor = new TextboxPropertyEditor( NullLoggerFactory.Instance, @@ -592,7 +593,8 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.Models localizationService, ioHelper, shortStringHelper, - localizedTextService + localizedTextService, + jsonSerializer ); var serializer = new ConfigurationEditorJsonSerializer(); diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/ColorListValidatorTest.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/ColorListValidatorTest.cs index 14aa628f88..98820ccac9 100644 --- a/src/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/ColorListValidatorTest.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/ColorListValidatorTest.cs @@ -2,13 +2,12 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using Moq; -using NUnit.Framework; using Newtonsoft.Json.Linq; +using NUnit.Framework; using Umbraco.Core.IO; -using NUnit.Framework.Internal; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; -using Umbraco.Tests.TestHelpers; using Umbraco.Web.PropertyEditors; namespace Umbraco.Tests.UnitTests.Umbraco.Core.PropertyEditors @@ -22,7 +21,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.PropertyEditors public void Only_Tests_On_JArray() { var validator = new ColorPickerConfigurationEditor.ColorListValidator(); - var result = validator.Validate("hello", null, new ColorPickerPropertyEditor(_loggerFactory, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of())); + var result = validator.Validate("hello", null, new ColorPickerPropertyEditor(_loggerFactory, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), new JsonNetSerializer())); Assert.AreEqual(0, result.Count()); } @@ -30,7 +29,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.PropertyEditors public void Only_Tests_On_JArray_Of_Item_JObject() { var validator = new ColorPickerConfigurationEditor.ColorListValidator(); - var result = validator.Validate(new JArray("hello", "world"), null, new ColorPickerPropertyEditor(_loggerFactory, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of())); + var result = validator.Validate(new JArray("hello", "world"), null, new ColorPickerPropertyEditor(_loggerFactory, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), new JsonNetSerializer())); Assert.AreEqual(0, result.Count()); } @@ -43,7 +42,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.PropertyEditors JObject.FromObject(new { value = "zxcvzxcvxzcv" }), JObject.FromObject(new { value = "ABC" }), JObject.FromObject(new { value = "1234567" })), - null, new ColorPickerPropertyEditor(_loggerFactory, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of())); + null, new ColorPickerPropertyEditor(_loggerFactory, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), new JsonNetSerializer())); Assert.AreEqual(2, result.Count()); } } diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/DataValueReferenceFactoryCollectionTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/DataValueReferenceFactoryCollectionTests.cs index 0fa864ae06..3229c3652c 100644 --- a/src/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/DataValueReferenceFactoryCollectionTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/DataValueReferenceFactoryCollectionTests.cs @@ -1,21 +1,19 @@ -using Moq; -using NUnit.Framework; -using System; +using System; using System.Collections.Generic; using System.Linq; using Microsoft.Extensions.Logging.Abstractions; +using Moq; +using NUnit.Framework; using Umbraco.Core; using Umbraco.Core.IO; -using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Models.Editors; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; -using Umbraco.Tests.TestHelpers; using Umbraco.Web.PropertyEditors; using static Umbraco.Core.Models.Property; -using Umbraco.Core.Serialization; namespace Umbraco.Tests.UnitTests.Umbraco.Core.PropertyEditors { @@ -27,6 +25,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.PropertyEditors ILocalizedTextService LocalizedTextService { get; } = Mock.Of(); ILocalizationService LocalizationService { get; } = Mock.Of(); IShortStringHelper ShortStringHelper { get; } = Mock.Of(); + IJsonSerializer JsonSerializer { get; } = new JsonNetSerializer(); [Test] public void GetAllReferences_All_Variants_With_IDataValueReferenceFactory() @@ -41,7 +40,8 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.PropertyEditors DataTypeService, LocalizedTextService, LocalizationService, - ShortStringHelper + ShortStringHelper, + JsonSerializer ); var propertyEditors = new PropertyEditorCollection(new DataEditorCollection(labelEditor.Yield())); var trackedUdi1 = Udi.Create(Constants.UdiEntityType.Media, Guid.NewGuid()).ToString(); @@ -110,7 +110,8 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.PropertyEditors LocalizationService, IOHelper, ShortStringHelper, - LocalizedTextService + LocalizedTextService, + JsonSerializer ); var propertyEditors = new PropertyEditorCollection(new DataEditorCollection(mediaPicker.Yield())); var trackedUdi1 = Udi.Create(Constants.UdiEntityType.Media, Guid.NewGuid()).ToString(); @@ -179,7 +180,8 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.PropertyEditors LocalizationService, IOHelper, ShortStringHelper, - LocalizedTextService + LocalizedTextService, + JsonSerializer ); var propertyEditors = new PropertyEditorCollection(new DataEditorCollection(mediaPicker.Yield())); var trackedUdi1 = Udi.Create(Constants.UdiEntityType.Media, Guid.NewGuid()).ToString(); diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/EnsureUniqueValuesValidatorTest.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/EnsureUniqueValuesValidatorTest.cs index 44c53382d9..2b81620b27 100644 --- a/src/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/EnsureUniqueValuesValidatorTest.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/EnsureUniqueValuesValidatorTest.cs @@ -2,13 +2,12 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using Moq; -using NUnit.Framework; using Newtonsoft.Json.Linq; +using NUnit.Framework; using Umbraco.Core.IO; -using Umbraco.Core.Logging; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; -using Umbraco.Tests.TestHelpers; using Umbraco.Web.PropertyEditors; namespace Umbraco.Tests.UnitTests.Umbraco.Core.PropertyEditors @@ -21,7 +20,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.PropertyEditors public void Only_Tests_On_JArray() { var validator = new ValueListUniqueValueValidator(); - var result = validator.Validate("hello", null, new ColorPickerPropertyEditor(_loggerFactory, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of())); + var result = validator.Validate("hello", null, new ColorPickerPropertyEditor(_loggerFactory, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), new JsonNetSerializer())); Assert.AreEqual(0, result.Count()); } @@ -29,7 +28,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.PropertyEditors public void Only_Tests_On_JArray_Of_Item_JObject() { var validator = new ValueListUniqueValueValidator(); - var result = validator.Validate(new JArray("hello", "world"), null, new ColorPickerPropertyEditor(_loggerFactory, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of())); + var result = validator.Validate(new JArray("hello", "world"), null, new ColorPickerPropertyEditor(_loggerFactory, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), new JsonNetSerializer())); Assert.AreEqual(0, result.Count()); } @@ -37,7 +36,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.PropertyEditors public void Allows_Unique_Values() { var validator = new ValueListUniqueValueValidator(); - var result = validator.Validate(new JArray(JObject.FromObject(new { value = "hello" }), JObject.FromObject(new { value = "world" })), null, new ColorPickerPropertyEditor(_loggerFactory, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of())); + var result = validator.Validate(new JArray(JObject.FromObject(new { value = "hello" }), JObject.FromObject(new { value = "world" })), null, new ColorPickerPropertyEditor(_loggerFactory, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), new JsonNetSerializer())); Assert.AreEqual(0, result.Count()); } @@ -46,7 +45,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.PropertyEditors { var validator = new ValueListUniqueValueValidator(); var result = validator.Validate(new JArray(JObject.FromObject(new { value = "hello" }), JObject.FromObject(new { value = "hello" })), - null, new ColorPickerPropertyEditor(_loggerFactory, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of())); + null, new ColorPickerPropertyEditor(_loggerFactory, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), new JsonNetSerializer())); Assert.AreEqual(1, result.Count()); } @@ -59,7 +58,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.PropertyEditors JObject.FromObject(new { value = "hello" }), JObject.FromObject(new { value = "world" }), JObject.FromObject(new { value = "world" })), - null, new ColorPickerPropertyEditor(_loggerFactory, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of())); + null, new ColorPickerPropertyEditor(_loggerFactory, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), new JsonNetSerializer())); Assert.AreEqual(2, result.Count()); } } diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/MultiValuePropertyEditorTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/MultiValuePropertyEditorTests.cs index 5b3e3f1ff6..2952ac032d 100644 --- a/src/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/MultiValuePropertyEditorTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/MultiValuePropertyEditorTests.cs @@ -5,7 +5,6 @@ using Moq; using Newtonsoft.Json; using NUnit.Framework; using Umbraco.Core.IO; -using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.PropertyEditors; using Umbraco.Core.Serialization; @@ -30,7 +29,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.PropertyEditors public void DropDownMultipleValueEditor_Format_Data_For_Cache() { var serializer = new ConfigurationEditorJsonSerializer(); - var dataType = new DataType(new CheckBoxListPropertyEditor(NullLoggerFactory.Instance, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of()), serializer) + var dataType = new DataType(new CheckBoxListPropertyEditor(NullLoggerFactory.Instance, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), new JsonNetSerializer()), serializer) { Configuration = new ValueListConfiguration { @@ -63,7 +62,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.PropertyEditors public void DropDownValueEditor_Format_Data_For_Cache() { var serializer = new ConfigurationEditorJsonSerializer(); - var dataType = new DataType(new CheckBoxListPropertyEditor(NullLoggerFactory.Instance, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of()), serializer) + var dataType = new DataType(new CheckBoxListPropertyEditor(NullLoggerFactory.Instance, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), new JsonNetSerializer()), serializer) { Configuration = new ValueListConfiguration { diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Published/ConvertersTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Published/ConvertersTests.cs index a46662c3a1..13c4ae071c 100644 --- a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Published/ConvertersTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Published/ConvertersTests.cs @@ -5,7 +5,6 @@ using Microsoft.Extensions.Logging; using Moq; using NUnit.Framework; using Umbraco.Core; -using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Models.PublishedContent; using Umbraco.Core.PropertyEditors; @@ -33,7 +32,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.Published var serializer = new ConfigurationEditorJsonSerializer(); var dataTypeServiceMock = new Mock(); var dataType = new DataType(new VoidEditor(Mock.Of(), dataTypeServiceMock.Object, - Mock.Of(), Mock.Of(), Mock.Of()), serializer) + Mock.Of(), Mock.Of(), Mock.Of(), new JsonNetSerializer()), serializer) { Id = 1 }; dataTypeServiceMock.Setup(x => x.GetAll()).Returns(dataType.Yield); @@ -117,7 +116,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.Published var serializer = new ConfigurationEditorJsonSerializer(); var dataTypeServiceMock = new Mock(); var dataType = new DataType(new VoidEditor(Mock.Of(), dataTypeServiceMock.Object, - Mock.Of(), Mock.Of(), Mock.Of()), serializer) + Mock.Of(), Mock.Of(), Mock.Of(), new JsonNetSerializer()), serializer) { Id = 1 }; dataTypeServiceMock.Setup(x => x.GetAll()).Returns(dataType.Yield); diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Published/NestedContentTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Published/NestedContentTests.cs index 67c294f5a9..7493d59d72 100644 --- a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Published/NestedContentTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Published/NestedContentTests.cs @@ -34,7 +34,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.Published var localizationService = Mock.Of(); PropertyEditorCollection editors = null; - var editor = new NestedContentPropertyEditor(loggerFactory, new Lazy(() => editors), Mock.Of(),localizationService, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of()); + var editor = new NestedContentPropertyEditor(loggerFactory, new Lazy(() => editors), Mock.Of(),localizationService, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), new JsonNetSerializer()); editors = new PropertyEditorCollection(new DataEditorCollection(new DataEditor[] { editor })); var serializer = new ConfigurationEditorJsonSerializer(); @@ -67,7 +67,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.Published } }; - var dataType3 = new DataType(new TextboxPropertyEditor(loggerFactory, Mock.Of(), localizationService, Mock.Of(), Mock.Of(), Mock.Of()), serializer) + var dataType3 = new DataType(new TextboxPropertyEditor(loggerFactory, Mock.Of(), localizationService, Mock.Of(), Mock.Of(), Mock.Of(), new JsonNetSerializer()), serializer) { Id = 3 }; diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Published/PropertyCacheLevelTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Published/PropertyCacheLevelTests.cs index b412ab1153..163020b6f6 100644 --- a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Published/PropertyCacheLevelTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Published/PropertyCacheLevelTests.cs @@ -5,7 +5,6 @@ using Moq; using NUnit.Framework; using Umbraco.Core; using Umbraco.Core.Cache; -using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Models.PublishedContent; using Umbraco.Core.PropertyEditors; @@ -32,10 +31,11 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.Published converter, }); - var serializer = new ConfigurationEditorJsonSerializer(); + var configurationEditorJsonSerializer = new ConfigurationEditorJsonSerializer(); + var jsonSerializer = new JsonNetSerializer(); var dataTypeServiceMock = new Mock(); var dataType = new DataType(new VoidEditor(NullLoggerFactory.Instance, dataTypeServiceMock.Object, - Mock.Of(), Mock.Of(), Mock.Of()), serializer) + Mock.Of(), Mock.Of(), Mock.Of(), jsonSerializer), configurationEditorJsonSerializer) { Id = 1 }; dataTypeServiceMock.Setup(x => x.GetAll()).Returns(dataType.Yield); @@ -118,10 +118,9 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.Published converter, }); - var serializer = new ConfigurationEditorJsonSerializer(); var dataTypeServiceMock = new Mock(); var dataType = new DataType(new VoidEditor(NullLoggerFactory.Instance, dataTypeServiceMock.Object, - Mock.Of(), Mock.Of(), Mock.Of()), serializer) + Mock.Of(), Mock.Of(), Mock.Of(), new JsonNetSerializer()), new ConfigurationEditorJsonSerializer()) { Id = 1 }; dataTypeServiceMock.Setup(x => x.GetAll()).Returns(dataType.Yield); @@ -199,10 +198,16 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.Published converter, }); - var serializer = new ConfigurationEditorJsonSerializer(); var dataTypeServiceMock = new Mock(); - var dataType = new DataType(new VoidEditor(NullLoggerFactory.Instance, dataTypeServiceMock.Object, - Mock.Of(), Mock.Of(), Mock.Of()), serializer) + var dataType = new DataType( + new VoidEditor( + NullLoggerFactory.Instance, + dataTypeServiceMock.Object, + Mock.Of(), + Mock.Of(), + Mock.Of(), + new JsonNetSerializer()), + new ConfigurationEditorJsonSerializer()) { Id = 1 }; dataTypeServiceMock.Setup(x => x.GetAll()).Returns(dataType.Yield); diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Persistence/Querying/ExpressionTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Persistence/Querying/ExpressionTests.cs index 436c202398..5d90d85f81 100644 --- a/src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Persistence/Querying/ExpressionTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Persistence/Querying/ExpressionTests.cs @@ -1,21 +1,21 @@ using System; using System.Diagnostics; +using System.Linq; using System.Linq.Expressions; +using Microsoft.Extensions.Logging.Abstractions; using Moq; using NUnit.Framework; using Umbraco.Core.Models; using Umbraco.Core.Models.Membership; using Umbraco.Core.Persistence; +using Umbraco.Core.Persistence.Dtos; using Umbraco.Core.Persistence.Querying; using Umbraco.Core.Persistence.SqlSyntax; -using Umbraco.Tests.TestHelpers; -using System.Linq; -using Microsoft.Extensions.Logging.Abstractions; -using Umbraco.Core.Persistence.Dtos; using Umbraco.Core.PropertyEditors; using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; +using Umbraco.Tests.TestHelpers; namespace Umbraco.Tests.UnitTests.Umbraco.Infrastructure.Persistence.Querying { @@ -25,8 +25,8 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Infrastructure.Persistence.Querying [Test] public void Equals_Claus_With_Two_Entity_Values() { - var serializer = new ConfigurationEditorJsonSerializer(); - var dataType = new DataType(new VoidEditor(NullLoggerFactory.Instance, Mock.Of(), Mock.Of(),Mock.Of(), Mock.Of()), serializer) + + var dataType = new DataType(new VoidEditor(NullLoggerFactory.Instance, Mock.Of(), Mock.Of(),Mock.Of(), Mock.Of(), new JsonNetSerializer()), new ConfigurationEditorJsonSerializer()) { Id = 12345 }; diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Services/PropertyValidationServiceTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Services/PropertyValidationServiceTests.cs index 3acfce1781..abc1bb0c9d 100644 --- a/src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Services/PropertyValidationServiceTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Services/PropertyValidationServiceTests.cs @@ -5,6 +5,7 @@ using Umbraco.Core; using Umbraco.Core.Models; using Umbraco.Core.PropertyEditors; using Umbraco.Core.PropertyEditors.Validators; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; using Umbraco.Web.PropertyEditors; @@ -34,7 +35,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Infrastructure.Services x => x.Type == EditorType.PropertyValue && x.Alias == Constants.PropertyEditors.Aliases.TextBox); Mock.Get(dataEditor).Setup(x => x.GetValueEditor(It.IsAny())) - .Returns(new CustomTextOnlyValueEditor(Mock.Of(), Mock.Of(), new DataEditorAttribute(Constants.PropertyEditors.Aliases.TextBox, "Test Textbox", "textbox"), textService.Object, Mock.Of())); + .Returns(new CustomTextOnlyValueEditor(Mock.Of(), Mock.Of(), new DataEditorAttribute(Constants.PropertyEditors.Aliases.TextBox, "Test Textbox", "textbox"), textService.Object, Mock.Of(), new JsonNetSerializer())); var propEditors = new PropertyEditorCollection(new DataEditorCollection(new[] { dataEditor })); @@ -166,7 +167,14 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Infrastructure.Services { private readonly ILocalizedTextService _textService; - public CustomTextOnlyValueEditor(IDataTypeService dataTypeService, ILocalizationService localizationService, DataEditorAttribute attribute, ILocalizedTextService textService, IShortStringHelper shortStringHelper) : base(dataTypeService, localizationService, attribute, textService, shortStringHelper) + public CustomTextOnlyValueEditor( + IDataTypeService dataTypeService, + ILocalizationService localizationService, + DataEditorAttribute attribute, + ILocalizedTextService textService, + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(dataTypeService, localizationService, attribute, textService, shortStringHelper, jsonSerializer) { _textService = textService; } diff --git a/src/Umbraco.Tests/Models/MediaXmlTest.cs b/src/Umbraco.Tests/Models/MediaXmlTest.cs index 92fd58d23c..20c86d127f 100644 --- a/src/Umbraco.Tests/Models/MediaXmlTest.cs +++ b/src/Umbraco.Tests/Models/MediaXmlTest.cs @@ -8,7 +8,6 @@ using NUnit.Framework; using Umbraco.Core; using Umbraco.Core.Configuration.Models; using Umbraco.Core.IO; -using Umbraco.Core.Logging; using Umbraco.Core.Services; using Umbraco.Core.Strings; using Umbraco.Tests.TestHelpers; @@ -36,7 +35,7 @@ namespace Umbraco.Tests.Models var contentSettings = new ContentSettings(); var mediaFileSystem = new MediaFileSystem(Mock.Of(), scheme, loggerFactory.CreateLogger(), ShortStringHelper); - var ignored = new FileUploadPropertyEditor(loggerFactory, mediaFileSystem, Microsoft.Extensions.Options.Options.Create(contentSettings), DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, UploadAutoFillProperties); + var ignored = new FileUploadPropertyEditor(loggerFactory, mediaFileSystem, Microsoft.Extensions.Options.Options.Create(contentSettings), DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, UploadAutoFillProperties, JsonNetSerializer); var media = MockedMedia.CreateMediaImage(mediaType, -1); media.WriterId = -1; // else it's zero and that's not a user and it breaks the tests diff --git a/src/Umbraco.Tests/Packaging/PackageDataInstallationTests.cs b/src/Umbraco.Tests/Packaging/PackageDataInstallationTests.cs index b48e3230f6..0383eb6ef8 100644 --- a/src/Umbraco.Tests/Packaging/PackageDataInstallationTests.cs +++ b/src/Umbraco.Tests/Packaging/PackageDataInstallationTests.cs @@ -15,6 +15,7 @@ using Umbraco.Core.Models.Packaging; using Umbraco.Core.Packaging; using Umbraco.Core.Persistence.Dtos; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; using Umbraco.Tests.Services; @@ -34,7 +35,7 @@ namespace Umbraco.Tests.Packaging public class Editor1 : DataEditor { public Editor1(ILoggerFactory loggerFactory) - : base(loggerFactory, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of()) + : base(loggerFactory, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), new JsonNetSerializer()) { } } @@ -44,7 +45,7 @@ namespace Umbraco.Tests.Packaging public class Editor2 : DataEditor { public Editor2(ILoggerFactory loggerFactory) - : base(loggerFactory, Mock.Of(), Mock.Of(), Mock.Of(),Mock.Of()) + : base(loggerFactory, Mock.Of(), Mock.Of(), Mock.Of(),Mock.Of(), new JsonNetSerializer()) { } } diff --git a/src/Umbraco.Tests/Packaging/PackageInstallationTest.cs b/src/Umbraco.Tests/Packaging/PackageInstallationTest.cs index 51d077d89f..2d238c9057 100644 --- a/src/Umbraco.Tests/Packaging/PackageInstallationTest.cs +++ b/src/Umbraco.Tests/Packaging/PackageInstallationTest.cs @@ -7,7 +7,6 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using Moq; using NUnit.Framework; -using Umbraco.Core; using Umbraco.Core.Configuration.Models; using Umbraco.Core.Hosting; using Umbraco.Core.Models.Packaging; @@ -19,7 +18,6 @@ using Umbraco.Core.Services; using Umbraco.Core.Strings; using Umbraco.Tests.TestHelpers; using Umbraco.Tests.Testing; -using File = System.IO.File; namespace Umbraco.Tests.Packaging { @@ -62,7 +60,9 @@ namespace Umbraco.Tests.Packaging Factory.GetRequiredService(), Microsoft.Extensions.Options.Options.Create(new GlobalSettings()), Factory.GetRequiredService(), - Factory.GetRequiredService()); + Factory.GetRequiredService(), + Factory.GetRequiredService() + ); private IPackageInstallation PackageInstallation => new PackageInstallation( PackageDataInstallation, diff --git a/src/Umbraco.Tests/Published/ConvertersTests.cs b/src/Umbraco.Tests/Published/ConvertersTests.cs index 840ec58f13..8a9bdb99ca 100644 --- a/src/Umbraco.Tests/Published/ConvertersTests.cs +++ b/src/Umbraco.Tests/Published/ConvertersTests.cs @@ -62,10 +62,10 @@ namespace Umbraco.Tests.Published var serializer = new ConfigurationEditorJsonSerializer(); var dataTypeServiceMock = new Mock(); var dataType1 = new DataType(new VoidEditor(NullLoggerFactory.Instance, dataTypeServiceMock.Object, - Mock.Of(), Mock.Of(), Mock.Of()), serializer) + Mock.Of(), Mock.Of(), Mock.Of(), new JsonNetSerializer()), serializer) { Id = 1 }; var dataType2 = new DataType(new VoidEditor("2", NullLoggerFactory.Instance, Mock.Of(), - Mock.Of(), Mock.Of(), Mock.Of()), serializer) + Mock.Of(), Mock.Of(), Mock.Of(), new JsonNetSerializer()), serializer) { Id = 2 }; dataTypeServiceMock.Setup(x => x.GetAll()).Returns(new []{dataType1, dataType2 }); diff --git a/src/Umbraco.Tests/PublishedContent/NuCacheChildrenTests.cs b/src/Umbraco.Tests/PublishedContent/NuCacheChildrenTests.cs index a17eb71ab0..f9909408b8 100644 --- a/src/Umbraco.Tests/PublishedContent/NuCacheChildrenTests.cs +++ b/src/Umbraco.Tests/PublishedContent/NuCacheChildrenTests.cs @@ -2,14 +2,11 @@ using System.Collections.Generic; using System.Data; using System.Linq; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Options; -using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; +using Microsoft.Extensions.Options; using Moq; using NUnit.Framework; using Umbraco.Core; -using Umbraco.Core.Composing; using Umbraco.Core.Configuration.Models; using Umbraco.Core.Events; using Umbraco.Core.Hosting; @@ -19,20 +16,20 @@ using Umbraco.Core.Models.PublishedContent; using Umbraco.Core.Persistence.Repositories; using Umbraco.Core.PropertyEditors; using Umbraco.Core.Scoping; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Services.Changes; using Umbraco.Core.Strings; +using Umbraco.Net; using Umbraco.Tests.Common; using Umbraco.Tests.TestHelpers; using Umbraco.Tests.Testing.Objects; using Umbraco.Web; using Umbraco.Web.Cache; +using Umbraco.Web.Composing; using Umbraco.Web.PublishedCache; using Umbraco.Web.PublishedCache.NuCache; using Umbraco.Web.PublishedCache.NuCache.DataSource; -using Current = Umbraco.Web.Composing.Current; -using Umbraco.Core.Serialization; -using Umbraco.Net; namespace Umbraco.Tests.PublishedContent { @@ -70,7 +67,7 @@ namespace Umbraco.Tests.PublishedContent var serializer = new ConfigurationEditorJsonSerializer(); // create data types, property types and content types - var dataType = new DataType(new VoidEditor("Editor", NullLoggerFactory.Instance, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of()), serializer) { Id = 3 }; + var dataType = new DataType(new VoidEditor("Editor", NullLoggerFactory.Instance, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), new JsonNetSerializer()), serializer) { Id = 3 }; var dataTypes = new[] { diff --git a/src/Umbraco.Tests/PublishedContent/NuCacheTests.cs b/src/Umbraco.Tests/PublishedContent/NuCacheTests.cs index d689215081..1d90984d04 100644 --- a/src/Umbraco.Tests/PublishedContent/NuCacheTests.cs +++ b/src/Umbraco.Tests/PublishedContent/NuCacheTests.cs @@ -2,13 +2,10 @@ using System.Collections.Generic; using System.Data; using System.Linq; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using Moq; using NUnit.Framework; using Umbraco.Core; -using Umbraco.Core.Composing; using Umbraco.Core.Configuration.Models; using Umbraco.Core.Events; using Umbraco.Core.Logging; @@ -27,10 +24,10 @@ using Umbraco.Tests.TestHelpers; using Umbraco.Tests.Testing.Objects; using Umbraco.Web; using Umbraco.Web.Cache; +using Umbraco.Web.Composing; using Umbraco.Web.PublishedCache; using Umbraco.Web.PublishedCache.NuCache; using Umbraco.Web.PublishedCache.NuCache.DataSource; -using Current = Umbraco.Web.Composing.Current; namespace Umbraco.Tests.PublishedContent { @@ -120,7 +117,7 @@ namespace Umbraco.Tests.PublishedContent var serializer = new ConfigurationEditorJsonSerializer(); // create data types, property types and content types - var dataType = new DataType(new VoidEditor("Editor", NullLoggerFactory.Instance, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of()), serializer) { Id = 3 }; + var dataType = new DataType(new VoidEditor("Editor", NullLoggerFactory.Instance, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), new JsonNetSerializer()), serializer) { Id = 3 }; var dataTypes = new[] { diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentDataTableTests.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentDataTableTests.cs index 37cc8911b1..7cc5bae403 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedContentDataTableTests.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedContentDataTableTests.cs @@ -5,8 +5,6 @@ using System.Linq; using Microsoft.Extensions.Logging.Abstractions; using Moq; using NUnit.Framework; -using Umbraco.Web.Composing; -using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Models.PublishedContent; using Umbraco.Core.PropertyEditors; @@ -14,9 +12,7 @@ using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; using Umbraco.Tests.TestHelpers; -using Umbraco.Tests.Testing; using Umbraco.Web; -using PublishedContentExtensions = Umbraco.Web.PublishedContentExtensions; namespace Umbraco.Tests.PublishedContent { @@ -130,7 +126,7 @@ namespace Umbraco.Tests.PublishedContent { var serializer = new ConfigurationEditorJsonSerializer(); var dataTypeService = new TestObjects.TestDataTypeService( - new DataType(new VoidEditor(NullLoggerFactory.Instance, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of()), serializer) { Id = 1 }); + new DataType(new VoidEditor(NullLoggerFactory.Instance, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), new JsonNetSerializer()), serializer) { Id = 1 }); var factory = new PublishedContentTypeFactory(Mock.Of(), new PropertyValueConverterCollection(Array.Empty()), dataTypeService); var contentTypeAlias = createChildren ? "Parent" : "Child"; diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentSnapshotTestBase.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentSnapshotTestBase.cs index 75983ba41a..e4b3721892 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedContentSnapshotTestBase.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedContentSnapshotTestBase.cs @@ -7,23 +7,22 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using Moq; using Umbraco.Core; -using Umbraco.Core.Models.PublishedContent; -using Umbraco.Web; -using Umbraco.Web.PublishedCache; using Umbraco.Core.Cache; using Umbraco.Core.Composing; using Umbraco.Core.Hosting; using Umbraco.Core.IO; using Umbraco.Core.Logging; using Umbraco.Core.Models; +using Umbraco.Core.Models.PublishedContent; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Security; using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; -using Umbraco.Tests.TestHelpers; -using Current = Umbraco.Web.Composing.Current; using Umbraco.Tests.Common; -using Umbraco.Core.Security; +using Umbraco.Tests.TestHelpers; +using Umbraco.Web; +using Umbraco.Web.PublishedCache; namespace Umbraco.Tests.PublishedContent { @@ -90,7 +89,7 @@ namespace Umbraco.Tests.PublishedContent { var serializer = new ConfigurationEditorJsonSerializer(); var dataTypeService = new TestObjects.TestDataTypeService( - new DataType(new VoidEditor(NullLoggerFactory.Instance, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of()), serializer) { Id = 1 }); + new DataType(new VoidEditor(NullLoggerFactory.Instance, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), new JsonNetSerializer()), serializer) { Id = 1 }); var factory = new PublishedContentTypeFactory(Mock.Of(), new PropertyValueConverterCollection(Array.Empty()), dataTypeService); var caches = new SolidPublishedSnapshot(); diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentTestBase.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentTestBase.cs index b55609858b..aa8fc26bd8 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedContentTestBase.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedContentTestBase.cs @@ -1,25 +1,23 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; -using Umbraco.Core; +using Moq; +using Umbraco.Core.IO; +using Umbraco.Core.Media; +using Umbraco.Core.Models; using Umbraco.Core.Models.PublishedContent; using Umbraco.Core.PropertyEditors; using Umbraco.Core.PropertyEditors.ValueConverters; -using Umbraco.Tests.TestHelpers; -using Moq; -using Umbraco.Core.IO; -using Umbraco.Core.Logging; -using Umbraco.Core.Models; -using Umbraco.Web.PropertyEditors; -using Umbraco.Core.Services; -using Umbraco.Web; -using Umbraco.Web.Templates; -using Umbraco.Web.Routing; -using Umbraco.Core.Media; -using System; -using Microsoft.Extensions.DependencyInjection; using Umbraco.Core.Security; using Umbraco.Core.Serialization; +using Umbraco.Core.Services; +using Umbraco.Tests.TestHelpers; +using Umbraco.Web; +using Umbraco.Web.PropertyEditors; +using Umbraco.Web.Routing; +using Umbraco.Web.Templates; namespace Umbraco.Tests.PublishedContent { @@ -67,7 +65,8 @@ namespace Umbraco.Tests.PublishedContent ShortStringHelper, IOHelper, LocalizedTextService, - Mock.Of()), + Mock.Of(), + new JsonNetSerializer()), serializer) { Id = 1 }); diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs index 2170da2f75..797b1c2be9 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs @@ -5,31 +5,31 @@ using System.Linq; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; +using Moq; using NUnit.Framework; using Umbraco.Core; -using Umbraco.Core.Models.PublishedContent; -using Umbraco.Core.PropertyEditors; -using Umbraco.Web; -using Umbraco.Web.PublishedCache; -using Moq; using Umbraco.Core.Cache; using Umbraco.Core.Composing; using Umbraco.Core.Hosting; using Umbraco.Core.IO; using Umbraco.Core.Logging; +using Umbraco.Core.Media; using Umbraco.Core.Models; +using Umbraco.Core.Models.PublishedContent; +using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Security; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; using Umbraco.Tests.TestHelpers; using Umbraco.Tests.Testing; +using Umbraco.Web; +using Umbraco.Web.Composing; using Umbraco.Web.Models.PublishedContent; using Umbraco.Web.PropertyEditors; -using Umbraco.Web.Templates; +using Umbraco.Web.PublishedCache; using Umbraco.Web.Routing; -using Current = Umbraco.Web.Composing.Current; -using Umbraco.Core.Media; -using Umbraco.Core.Security; -using Umbraco.Core.Serialization; +using Umbraco.Web.Templates; namespace Umbraco.Tests.PublishedContent { @@ -64,12 +64,12 @@ namespace Umbraco.Tests.PublishedContent var localizationService = Mock.Of(); var dataTypeService = new TestObjects.TestDataTypeService( - new DataType(new VoidEditor(loggerFactory, Mock.Of(), localizationService, LocalizedTextService, ShortStringHelper), serializer) { Id = 1 }, - new DataType(new TrueFalsePropertyEditor(loggerFactory, Mock.Of(), localizationService, IOHelper, ShortStringHelper, LocalizedTextService), serializer) { Id = 1001 }, - new DataType(new RichTextPropertyEditor(loggerFactory,backOfficeSecurityAccessor, Mock.Of(), localizationService, imageSourceParser, linkParser, pastedImages, ShortStringHelper, IOHelper, LocalizedTextService, Mock.Of()), serializer) { Id = 1002 }, - new DataType(new IntegerPropertyEditor(loggerFactory, Mock.Of(), localizationService, ShortStringHelper, LocalizedTextService), serializer) { Id = 1003 }, - new DataType(new TextboxPropertyEditor(loggerFactory, Mock.Of(), localizationService, IOHelper, ShortStringHelper, LocalizedTextService), serializer) { Id = 1004 }, - new DataType(new MediaPickerPropertyEditor(loggerFactory, Mock.Of(), localizationService, IOHelper, ShortStringHelper, LocalizedTextService), serializer) { Id = 1005 }); + new DataType(new VoidEditor(loggerFactory, Mock.Of(), localizationService, LocalizedTextService, ShortStringHelper, JsonNetSerializer), serializer) { Id = 1 }, + new DataType(new TrueFalsePropertyEditor(loggerFactory, Mock.Of(), localizationService, IOHelper, ShortStringHelper, LocalizedTextService, JsonNetSerializer), serializer) { Id = 1001 }, + new DataType(new RichTextPropertyEditor(loggerFactory,backOfficeSecurityAccessor, Mock.Of(), localizationService, imageSourceParser, linkParser, pastedImages, ShortStringHelper, IOHelper, LocalizedTextService, Mock.Of(), JsonNetSerializer), serializer) { Id = 1002 }, + new DataType(new IntegerPropertyEditor(loggerFactory, Mock.Of(), localizationService, ShortStringHelper, LocalizedTextService, JsonNetSerializer), serializer) { Id = 1003 }, + new DataType(new TextboxPropertyEditor(loggerFactory, Mock.Of(), localizationService, IOHelper, ShortStringHelper, LocalizedTextService, JsonNetSerializer), serializer) { Id = 1004 }, + new DataType(new MediaPickerPropertyEditor(loggerFactory, Mock.Of(), localizationService, IOHelper, ShortStringHelper, LocalizedTextService, JsonNetSerializer), serializer) { Id = 1005 }); Builder.Services.AddUnique(f => dataTypeService); } diff --git a/src/Umbraco.Tests/PublishedContent/SolidPublishedSnapshot.cs b/src/Umbraco.Tests/PublishedContent/SolidPublishedSnapshot.cs index 6bdca6f0f6..58b6ea7c4d 100644 --- a/src/Umbraco.Tests/PublishedContent/SolidPublishedSnapshot.cs +++ b/src/Umbraco.Tests/PublishedContent/SolidPublishedSnapshot.cs @@ -5,13 +5,13 @@ using Microsoft.Extensions.Logging.Abstractions; using Moq; using Umbraco.Core; using Umbraco.Core.Cache; -using Umbraco.Web.Composing; using Umbraco.Core.Models; using Umbraco.Core.Models.PublishedContent; using Umbraco.Core.PropertyEditors; using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; +using Umbraco.Web.Composing; using Umbraco.Web.PublishedCache; namespace Umbraco.Tests.PublishedContent @@ -415,7 +415,7 @@ namespace Umbraco.Tests.PublishedContent var serializer = new ConfigurationEditorJsonSerializer(); var dataTypeServiceMock = new Mock(); var dataType = new DataType(new VoidEditor(NullLoggerFactory.Instance, dataTypeServiceMock.Object, - Mock.Of(), Mock.Of(), Mock.Of()), serializer) + Mock.Of(), Mock.Of(), Mock.Of(), new JsonNetSerializer()), serializer) { Id = 666 }; dataTypeServiceMock.Setup(x => x.GetAll()).Returns(dataType.Yield); diff --git a/src/Umbraco.Tests/Routing/MediaUrlProviderTests.cs b/src/Umbraco.Tests/Routing/MediaUrlProviderTests.cs index 84d0ea17f6..047b7205bf 100644 --- a/src/Umbraco.Tests/Routing/MediaUrlProviderTests.cs +++ b/src/Umbraco.Tests/Routing/MediaUrlProviderTests.cs @@ -39,8 +39,8 @@ namespace Umbraco.Tests.Routing var dataTypeService = Mock.Of(); var propertyEditors = new MediaUrlGeneratorCollection(new IMediaUrlGenerator[] { - new FileUploadPropertyEditor(loggerFactory, mediaFileSystemMock, Microsoft.Extensions.Options.Options.Create(contentSettings), dataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, UploadAutoFillProperties), - new ImageCropperPropertyEditor(loggerFactory, mediaFileSystemMock, Microsoft.Extensions.Options.Options.Create(contentSettings), dataTypeService, LocalizationService, IOHelper, ShortStringHelper, LocalizedTextService, UploadAutoFillProperties), + new FileUploadPropertyEditor(loggerFactory, mediaFileSystemMock, Microsoft.Extensions.Options.Options.Create(contentSettings), dataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, UploadAutoFillProperties, JsonNetSerializer), + new ImageCropperPropertyEditor(loggerFactory, mediaFileSystemMock, Microsoft.Extensions.Options.Options.Create(contentSettings), dataTypeService, LocalizationService, IOHelper, ShortStringHelper, LocalizedTextService, UploadAutoFillProperties, JsonNetSerializer), }); _mediaUrlProvider = new DefaultMediaUrlProvider(propertyEditors, UriUtility); } diff --git a/src/Umbraco.Tests/TestHelpers/BaseWebTest.cs b/src/Umbraco.Tests/TestHelpers/BaseWebTest.cs index c6587f6ad8..cab74e22e4 100644 --- a/src/Umbraco.Tests/TestHelpers/BaseWebTest.cs +++ b/src/Umbraco.Tests/TestHelpers/BaseWebTest.cs @@ -7,9 +7,7 @@ using Microsoft.Extensions.Logging.Abstractions; using Moq; using NUnit.Framework; using Umbraco.Core; -using Umbraco.Core.Composing; using Umbraco.Core.Configuration.Models; -using Umbraco.Core.Configuration.UmbracoSettings; using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Models.PublishedContent; @@ -18,7 +16,6 @@ using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; using Umbraco.Tests.Common; -using Umbraco.Tests.Common.Builders; using Umbraco.Tests.PublishedContent; using Umbraco.Tests.TestHelpers.Stubs; using Umbraco.Web; @@ -50,7 +47,7 @@ namespace Umbraco.Tests.TestHelpers var serializer = new ConfigurationEditorJsonSerializer(); var dataTypeService = new TestObjects.TestDataTypeService( - new DataType(new VoidEditor(NullLoggerFactory.Instance, Mock.Of(), Mock.Of(),Mock.Of(), Mock.Of()), serializer) { Id = 1 }); + new DataType(new VoidEditor(NullLoggerFactory.Instance, Mock.Of(), Mock.Of(),Mock.Of(), Mock.Of(), JsonNetSerializer), serializer) { Id = 1 }); var factory = new PublishedContentTypeFactory(Mock.Of(), new PropertyValueConverterCollection(Array.Empty()), dataTypeService); var type = new AutoPublishedContentType(Guid.NewGuid(), 0, "anything", new PublishedPropertyType[] { }); diff --git a/src/Umbraco.Tests/Testing/UmbracoTestBase.cs b/src/Umbraco.Tests/Testing/UmbracoTestBase.cs index 533966f5a9..bc697b9346 100644 --- a/src/Umbraco.Tests/Testing/UmbracoTestBase.cs +++ b/src/Umbraco.Tests/Testing/UmbracoTestBase.cs @@ -1,12 +1,4 @@ -using Examine; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Logging.Abstractions; -using Moq; -using NUnit.Framework; -using Serilog; -using System; +using System; using System.Collections.Generic; using System.Globalization; using System.IO; @@ -15,6 +7,14 @@ using System.Reflection; using System.Web.Routing; using System.Web.Security; using System.Xml.Linq; +using Examine; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; +using Moq; +using NUnit.Framework; +using Serilog; using Umbraco.Core; using Umbraco.Core.Cache; using Umbraco.Core.Composing; @@ -50,6 +50,7 @@ using Umbraco.Tests.TestHelpers.Stubs; using Umbraco.Web; using Umbraco.Web.Actions; using Umbraco.Web.AspNet; +using Umbraco.Web.Composing; using Umbraco.Web.ContentApps; using Umbraco.Web.Hosting; using Umbraco.Web.Install; @@ -63,7 +64,6 @@ using Umbraco.Web.Security.Providers; using Umbraco.Web.Services; using Umbraco.Web.Templates; using Umbraco.Web.Trees; -using Current = Umbraco.Web.Composing.Current; using FileSystems = Umbraco.Core.IO.FileSystems; using ILogger = Microsoft.Extensions.Logging.ILogger; @@ -315,6 +315,8 @@ namespace Umbraco.Tests.Testing Builder.Services.AddUnique(); Builder.Services.AddUnique(); Builder.Services.AddUnique(); + Builder.Services.AddUnique(); + Builder.Services.AddUnique(); Builder.SetCultureDictionaryFactory(); Builder.Services.AddSingleton(f => f.GetRequiredService().CreateDictionary()); // register back office sections in the order we want them rendered diff --git a/src/Umbraco.Web.BackOffice/Controllers/ContentTypeController.cs b/src/Umbraco.Web.BackOffice/Controllers/ContentTypeController.cs index 8d6adee475..aa2a57b123 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/ContentTypeController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/ContentTypeController.cs @@ -7,40 +7,38 @@ using System.Net.Mime; using System.Text; using System.Xml; using System.Xml.Linq; -using Microsoft.Extensions.Logging; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; using Umbraco.Core; +using Umbraco.Core.Configuration.Models; using Umbraco.Core.Dictionary; using Umbraco.Core.Hosting; +using Umbraco.Core.Mapping; using Umbraco.Core.Models; using Umbraco.Core.Packaging; using Umbraco.Core.PropertyEditors; using Umbraco.Core.Scoping; +using Umbraco.Core.Security; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; -using Umbraco.Web.Models; -using Umbraco.Web.Models.ContentEditing; -using Constants = Umbraco.Core.Constants; -using Umbraco.Core.Mapping; -using Umbraco.Core.Security; -using Umbraco.Web.BackOffice.Filters; using Umbraco.Web.Common.Attributes; +using Umbraco.Web.Common.Authorization; using Umbraco.Web.Common.Exceptions; using Umbraco.Web.Editors; +using Umbraco.Web.Models; +using Umbraco.Web.Models.ContentEditing; using ContentType = Umbraco.Core.Models.ContentType; -using Umbraco.Core.Configuration.Models; -using Microsoft.Extensions.Options; -using Umbraco.Core.Serialization; -using Microsoft.AspNetCore.Authorization; -using Umbraco.Web.Common.Authorization; namespace Umbraco.Web.BackOffice.Controllers { /// /// An API controller used for dealing with content types /// - [PluginController(Constants.Web.Mvc.BackOfficeApiArea)] + [PluginController(Constants.Web.Mvc.BackOfficeApiArea)] public class ContentTypeController : ContentTypeControllerBase { // TODO: Split this controller apart so that authz is consistent, currently we need to authz each action individually. @@ -65,7 +63,8 @@ namespace Umbraco.Web.BackOffice.Controllers private readonly IMacroService _macroService; private readonly IEntityService _entityService; private readonly IHostingEnvironment _hostingEnvironment; - private readonly IConfigurationEditorJsonSerializer _jsonSerializer; + private readonly IConfigurationEditorJsonSerializer _configurationEditorJsonSerializer; + private readonly IJsonSerializer _jsonSerializer; public ContentTypeController( ICultureDictionary cultureDictionary, @@ -91,7 +90,8 @@ namespace Umbraco.Web.BackOffice.Controllers IEntityService entityService, IHostingEnvironment hostingEnvironment, EditorValidatorCollection editorValidatorCollection, - IConfigurationEditorJsonSerializer jsonSerializer) + IConfigurationEditorJsonSerializer configurationEditorJsonSerializer, + IJsonSerializer jsonSerializer) : base(cultureDictionary, editorValidatorCollection, contentTypeService, @@ -119,6 +119,7 @@ namespace Umbraco.Web.BackOffice.Controllers _macroService = macroService; _entityService = entityService; _hostingEnvironment = hostingEnvironment; + _configurationEditorJsonSerializer = configurationEditorJsonSerializer; _jsonSerializer = jsonSerializer; } @@ -220,7 +221,7 @@ namespace Umbraco.Web.BackOffice.Controllers /// Gets all user defined properties. /// /// - [Authorize(Policy = AuthorizationPolicies.TreeAccessAnyContentOrTypes)] + [Authorize(Policy = AuthorizationPolicies.TreeAccessAnyContentOrTypes)] public IEnumerable GetAllPropertyTypeAliases() { return _contentTypeService.GetAllPropertyTypeAliases(); @@ -626,8 +627,23 @@ namespace Umbraco.Web.BackOffice.Controllers return NotFound(); } - var dataInstaller = new PackageDataInstallation(_loggerFactory.CreateLogger(), _loggerFactory, _fileService, _macroService, _LocalizationService, - _dataTypeService, _entityService, _contentTypeService, _contentService, _propertyEditors, _scopeProvider, _shortStringHelper, Options.Create(_globalSettings), _localizedTextService, _jsonSerializer); + var dataInstaller = new PackageDataInstallation( + _loggerFactory.CreateLogger(), + _loggerFactory, + _fileService, + _macroService, + _LocalizationService, + _dataTypeService, + _entityService, + _contentTypeService, + _contentService, + _propertyEditors, + _scopeProvider, + _shortStringHelper, + Options.Create(_globalSettings), + _localizedTextService, + _configurationEditorJsonSerializer, + _jsonSerializer); var xd = new XmlDocument {XmlResolver = null}; xd.Load(filePath);