diff --git a/.gitattributes b/.gitattributes
index c8987ade67..3241b6511c 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -43,6 +43,7 @@
*.hs text=auto
*.json text=auto
*.xml text=auto
+*.resx text=auto
*.csproj text=auto merge=union
*.vbproj text=auto merge=union
diff --git a/.gitignore b/.gitignore
index b87d1df346..022acb5db7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -196,3 +196,4 @@ src/Umbraco.Tests.Integration/umbraco/logs/
src/Umbraco.Tests.Integration/Views/
src/Umbraco.Tests/TEMP/
+/src/Umbraco.Web.UI.NetCore/Umbraco/Data/*
diff --git a/build/azure-pipelines.yml b/build/azure-pipelines.yml
index 8a99f941b0..c545d6884e 100644
--- a/build/azure-pipelines.yml
+++ b/build/azure-pipelines.yml
@@ -8,6 +8,19 @@
# Variables & their default values
variables:
buildConfiguration: 'Release'
+ SA_PASSWORD: UmbracoIntegration123!
+
+resources:
+ containers:
+ - container: mssql
+ image: mcr.microsoft.com/mssql/server:2017-latest
+ env:
+ ACCEPT_EULA: Y
+ SA_PASSWORD: $(SA_PASSWORD)
+ MSSQL_PID: Developer
+ ports:
+ - 1433:1433
+ options: --name mssql
stages:
- stage: Linux
@@ -31,27 +44,48 @@ stages:
command: test
projects: '**/*.Tests.UnitTests.csproj'
-- stage: macOS_X
+ - job: Integration_Tests
+ services:
+ mssql: mssql
+ timeoutInMinutes: 120
+ displayName: 'Integration Tests'
+ pool:
+ vmImage: 'ubuntu-latest'
+ steps:
+
+ - task: UseDotNet@2
+ displayName: 'Use .Net Core sdk 3.1.x'
+ inputs:
+ version: 3.1.x
+
+ - task: DotNetCoreCLI@2
+ displayName: 'dotnet test'
+ inputs:
+ command: test
+ projects: '**/Umbraco.Tests.Integration.csproj'
+ env:
+ UmbracoIntegrationTestConnectionString: 'Server=localhost,1433;User Id=sa;Password=$(SA_PASSWORD);'
+
+- stage: MacOS
dependsOn: [] # this removes the implicit dependency on previous stage and causes this to run in parallel
jobs:
- - job: Unit_Tests
- displayName: 'Unit Tests'
- pool:
- vmImage: 'macOS-latest'
- steps:
+ - job: Unit_Tests
+ displayName: 'Unit Tests'
+ pool:
+ vmImage: 'macOS-latest'
+ steps:
- - task: UseDotNet@2
- displayName: 'Use .Net Core sdk 3.1.x'
- inputs:
- version: 3.1.x
-
- - task: DotNetCoreCLI@2
- displayName: 'dotnet test'
- inputs:
- command: test
- projects: '**/*.Tests.UnitTests.csproj'
+ - task: UseDotNet@2
+ displayName: 'Use .Net Core sdk 3.1.x'
+ inputs:
+ version: 3.1.x
+ - task: DotNetCoreCLI@2
+ displayName: 'dotnet test'
+ inputs:
+ command: test
+ projects: '**/*.Tests.UnitTests.csproj'
- stage: Windows
dependsOn: [] # this removes the implicit dependency on previous stage and causes this to run in parallel
@@ -74,7 +108,6 @@ stages:
command: test
projects: '**\*.Tests.UnitTests.csproj'
-
- job: Integration_Tests
timeoutInMinutes: 120
displayName: 'Integration Tests'
@@ -87,11 +120,6 @@ stages:
inputs:
version: 3.1.x
- - task: DotNetCoreCLI@2
- displayName: 'dotnet build'
- inputs:
- projects: '**\Umbraco.Tests.Integration.csproj'
-
- powershell: 'sqllocaldb start mssqllocaldb'
displayName: 'Start MSSQL LocalDb'
@@ -100,8 +128,6 @@ stages:
inputs:
command: test
projects: '**\Umbraco.Tests.Integration.csproj'
- arguments: '--no-build'
-
- job: Build_Artifacts
displayName: 'Build Artifacts'
diff --git a/src/Umbraco.Infrastructure/Configuration/Extensions/HealthCheckSettingsExtensions.cs b/src/Umbraco.Core/Configuration/Extensions/HealthCheckSettingsExtensions.cs
similarity index 90%
rename from src/Umbraco.Infrastructure/Configuration/Extensions/HealthCheckSettingsExtensions.cs
rename to src/Umbraco.Core/Configuration/Extensions/HealthCheckSettingsExtensions.cs
index 92c3608ac1..ae842cb040 100644
--- a/src/Umbraco.Infrastructure/Configuration/Extensions/HealthCheckSettingsExtensions.cs
+++ b/src/Umbraco.Core/Configuration/Extensions/HealthCheckSettingsExtensions.cs
@@ -1,9 +1,7 @@
using System;
-using NCrontab;
-using Umbraco.Core.Configuration;
using Umbraco.Core.Configuration.Models;
-namespace Umbraco.Infrastructure.Configuration.Extensions
+namespace Umbraco.Core.Configuration.Extensions
{
public static class HealthCheckSettingsExtensions
{
diff --git a/src/Umbraco.Core/Configuration/LocalTempStorage.cs b/src/Umbraco.Core/Configuration/LocalTempStorage.cs
index 0013fb68e4..50eab639d0 100644
--- a/src/Umbraco.Core/Configuration/LocalTempStorage.cs
+++ b/src/Umbraco.Core/Configuration/LocalTempStorage.cs
@@ -4,7 +4,6 @@ namespace Umbraco.Core.Configuration
{
Unknown = 0,
Default,
- AspNetTemp,
EnvironmentTemp
}
}
diff --git a/src/Umbraco.Core/Configuration/Models/UmbracoPluginSettings.cs b/src/Umbraco.Core/Configuration/Models/UmbracoPluginSettings.cs
new file mode 100644
index 0000000000..907b29490d
--- /dev/null
+++ b/src/Umbraco.Core/Configuration/Models/UmbracoPluginSettings.cs
@@ -0,0 +1,27 @@
+// Copyright (c) Umbraco.
+// See LICENSE for more details.
+
+using System.Collections.Generic;
+
+namespace Umbraco.Core.Configuration.Models
+{
+ ///
+ /// Typed configuration options for the plugins.
+ ///
+ public class UmbracoPluginSettings
+ {
+ ///
+ /// Gets or sets the allowed file extensions (including the period ".") that should be accessible from the browser.
+ ///
+ public ISet BrowsableFileExtensions { get; set; } = new HashSet(new[]
+ {
+ ".html", // markup
+ ".css", // styles
+ ".js", // scripts
+ ".jpg", ".jpeg", ".gif", ".png", ".svg", // images
+ ".eot", ".ttf", ".woff", // fonts
+ ".xml", ".json", ".config", // configurations
+ ".lic" // license
+ });
+ }
+}
diff --git a/src/Umbraco.Core/Constants-Configuration.cs b/src/Umbraco.Core/Constants-Configuration.cs
index 2c9fe3caee..a60f29c39d 100644
--- a/src/Umbraco.Core/Constants-Configuration.cs
+++ b/src/Umbraco.Core/Constants-Configuration.cs
@@ -39,6 +39,7 @@
public const string ConfigMemberPassword = ConfigPrefix + "Security:MemberPassword";
public const string ConfigModelsBuilder = ConfigPrefix + "ModelsBuilder";
public const string ConfigNuCache = ConfigPrefix + "NuCache";
+ public const string ConfigPlugins = ConfigPrefix + "Plugins";
public const string ConfigRequestHandler = ConfigPrefix + "RequestHandler";
public const string ConfigRuntime = ConfigPrefix + "Runtime";
public const string ConfigRuntimeMinification = ConfigPrefix + "RuntimeMinification";
diff --git a/src/Umbraco.Core/Constants-SystemDirectories.cs b/src/Umbraco.Core/Constants-SystemDirectories.cs
index d4ca2a3c57..6145f4190b 100644
--- a/src/Umbraco.Core/Constants-SystemDirectories.cs
+++ b/src/Umbraco.Core/Constants-SystemDirectories.cs
@@ -1,15 +1,33 @@
-namespace Umbraco.Core
+namespace Umbraco.Core
{
public static partial class Constants
{
public static class SystemDirectories
{
+ ///
+ /// The aspnet bin folder
+ ///
public const string Bin = "~/bin";
+ // TODO: Shouldn't this exist underneath /Umbraco in the content root?
public const string Config = "~/config";
- public const string Data = "~/App_Data";
+ ///
+ /// The Umbraco folder that exists at the content root.
+ ///
+ ///
+ /// This is not the same as the Umbraco web folder which is configurable for serving front-end files.
+ ///
+ public const string Umbraco = "~/Umbraco";
+ ///
+ /// The Umbraco data folder in the content root
+ ///
+ public const string Data = Umbraco + "/Data";
+
+ ///
+ /// The Umbraco temp data folder in the content root
+ ///
public const string TempData = Data + "/TEMP";
public const string TempFileUploads = TempData + "/FileUploads";
@@ -18,8 +36,6 @@
public const string Install = "~/install";
- public const string AppCode = "~/App_Code";
-
public const string AppPlugins = "/App_Plugins";
public const string MvcViews = "~/Views";
@@ -32,7 +48,10 @@
public const string Preview = Data + "/preview";
- public const string LogFiles= "~/Logs";
+ ///
+ /// The default folder where Umbraco log files are stored
+ ///
+ public const string LogFiles = Umbraco + "/Logs";
}
}
}
diff --git a/src/Umbraco.Infrastructure/Diagnostics/IMarchal.cs b/src/Umbraco.Core/Diagnostics/IMarchal.cs
similarity index 58%
rename from src/Umbraco.Infrastructure/Diagnostics/IMarchal.cs
rename to src/Umbraco.Core/Diagnostics/IMarchal.cs
index 30e6a9e619..cde4592b1b 100644
--- a/src/Umbraco.Infrastructure/Diagnostics/IMarchal.cs
+++ b/src/Umbraco.Core/Diagnostics/IMarchal.cs
@@ -7,6 +7,10 @@ namespace Umbraco.Core.Diagnostics
///
public interface IMarchal
{
+ ///
+ /// Retrieves a computer-independent description of an exception, and information about the state that existed for the thread when the exception occurred.
+ ///
+ /// A pointer to an EXCEPTION_POINTERS structure.
IntPtr GetExceptionPointers();
}
}
diff --git a/src/Umbraco.Infrastructure/Diagnostics/MiniDump.cs b/src/Umbraco.Core/Diagnostics/MiniDump.cs
similarity index 87%
rename from src/Umbraco.Infrastructure/Diagnostics/MiniDump.cs
rename to src/Umbraco.Core/Diagnostics/MiniDump.cs
index 57e9b5204b..51f595bfb2 100644
--- a/src/Umbraco.Infrastructure/Diagnostics/MiniDump.cs
+++ b/src/Umbraco.Core/Diagnostics/MiniDump.cs
@@ -1,10 +1,8 @@
-using System;
+using System;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
-using Umbraco.Core.Composing;
using Umbraco.Core.Hosting;
-using Umbraco.Core.IO;
namespace Umbraco.Core.Diagnostics
{
@@ -12,7 +10,7 @@ namespace Umbraco.Core.Diagnostics
// and https://blogs.msdn.microsoft.com/dondu/2010/10/31/writing-minidumps-from-exceptions-in-c/
// which itself got it from http://blog.kalmbach-software.de/2008/12/13/writing-minidumps-in-c/
- internal static class MiniDump
+ public static class MiniDump
{
private static readonly object LockO = new object();
@@ -92,7 +90,9 @@ namespace Umbraco.Core.Diagnostics
exp.ExceptionPointers = IntPtr.Zero;
if (withException)
+ {
exp.ExceptionPointers = marchal.GetExceptionPointers();
+ }
var bRet = exp.ExceptionPointers == IntPtr.Zero
? MiniDumpWriteDump(currentProcessHandle, currentProcessId, fileHandle, (uint) options, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero)
@@ -111,11 +111,14 @@ namespace Umbraco.Core.Diagnostics
// filter everywhere in our code = not!
var stacktrace = withException ? Environment.StackTrace : string.Empty;
- var filepath = Path.Combine(hostingEnvironment.ApplicationPhysicalPath, "App_Data/MiniDump");
- if (Directory.Exists(filepath) == false)
- Directory.CreateDirectory(filepath);
+ var directory = hostingEnvironment.MapPathContentRoot(Constants.SystemDirectories.Data + "/MiniDump");
- var filename = Path.Combine(filepath, $"{DateTime.UtcNow:yyyyMMddTHHmmss}.{Guid.NewGuid().ToString("N").Substring(0, 4)}.dmp");
+ if (Directory.Exists(directory) == false)
+ {
+ Directory.CreateDirectory(directory);
+ }
+
+ var filename = Path.Combine(directory, $"{DateTime.UtcNow:yyyyMMddTHHmmss}.{Guid.NewGuid().ToString("N").Substring(0, 4)}.dmp");
using (var stream = new FileStream(filename, FileMode.Create, FileAccess.ReadWrite, FileShare.Write))
{
return Write(marchal, stream.SafeFileHandle, options, withException);
@@ -127,9 +130,12 @@ namespace Umbraco.Core.Diagnostics
{
lock (LockO)
{
- var filepath = Path.Combine(hostingEnvironment.ApplicationPhysicalPath, "App_Data/MiniDump");
- if (Directory.Exists(filepath) == false) return true;
- var count = Directory.GetFiles(filepath, "*.dmp").Length;
+ var directory = hostingEnvironment.MapPathContentRoot(Constants.SystemDirectories.Data + "/MiniDump");
+ if (Directory.Exists(directory) == false)
+ {
+ return true;
+ }
+ var count = Directory.GetFiles(directory, "*.dmp").Length;
return count < 8;
}
}
diff --git a/src/Umbraco.Infrastructure/Dictionary/UmbracoCultureDictionary.cs b/src/Umbraco.Core/Dictionary/UmbracoCultureDictionary.cs
similarity index 98%
rename from src/Umbraco.Infrastructure/Dictionary/UmbracoCultureDictionary.cs
rename to src/Umbraco.Core/Dictionary/UmbracoCultureDictionary.cs
index b0690c944b..1f23ec645c 100644
--- a/src/Umbraco.Infrastructure/Dictionary/UmbracoCultureDictionary.cs
+++ b/src/Umbraco.Core/Dictionary/UmbracoCultureDictionary.cs
@@ -17,7 +17,7 @@ namespace Umbraco.Core.Dictionary
/// The ILocalizationService is the service used for interacting with this data from the database which isn't all that fast
/// (even though there is caching involved, if there's lots of dictionary items the caching is not great)
///
- public class DefaultCultureDictionary : ICultureDictionary
+ internal class DefaultCultureDictionary : ICultureDictionary
{
private readonly ILocalizationService _localizationService;
private readonly IAppCache _requestCache;
diff --git a/src/Umbraco.Infrastructure/Dictionary/UmbracoCultureDictionaryFactory.cs b/src/Umbraco.Core/Dictionary/UmbracoCultureDictionaryFactory.cs
similarity index 92%
rename from src/Umbraco.Infrastructure/Dictionary/UmbracoCultureDictionaryFactory.cs
rename to src/Umbraco.Core/Dictionary/UmbracoCultureDictionaryFactory.cs
index a2d1fa12d3..e2e30f3d76 100644
--- a/src/Umbraco.Infrastructure/Dictionary/UmbracoCultureDictionaryFactory.cs
+++ b/src/Umbraco.Core/Dictionary/UmbracoCultureDictionaryFactory.cs
@@ -9,7 +9,7 @@ namespace Umbraco.Core.Dictionary
///
/// In the future this will allow use to potentially store dictionary items elsewhere and allows for maximum flexibility.
///
- internal class DefaultCultureDictionaryFactory : ICultureDictionaryFactory
+ public class DefaultCultureDictionaryFactory : ICultureDictionaryFactory
{
private readonly ILocalizationService _localizationService;
private readonly AppCaches _appCaches;
diff --git a/src/Umbraco.Infrastructure/Editors/UserEditorAuthorizationHelper.cs b/src/Umbraco.Core/Editors/UserEditorAuthorizationHelper.cs
similarity index 100%
rename from src/Umbraco.Infrastructure/Editors/UserEditorAuthorizationHelper.cs
rename to src/Umbraco.Core/Editors/UserEditorAuthorizationHelper.cs
diff --git a/src/Umbraco.Core/HealthCheck/Checks/Permissions/FolderAndFilePermissionsCheck.cs b/src/Umbraco.Core/HealthCheck/Checks/Permissions/FolderAndFilePermissionsCheck.cs
index 9e279c98e2..a22748094a 100644
--- a/src/Umbraco.Core/HealthCheck/Checks/Permissions/FolderAndFilePermissionsCheck.cs
+++ b/src/Umbraco.Core/HealthCheck/Checks/Permissions/FolderAndFilePermissionsCheck.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Extensions.Options;
@@ -71,7 +71,6 @@ namespace Umbraco.Core.HealthCheck.Checks.Permissions
//so these need to be tested differently
var pathsToCheckWithRestarts = new Dictionary
{
- { Constants.SystemDirectories.AppCode, PermissionCheckRequirement.Optional },
{ Constants.SystemDirectories.Bin, PermissionCheckRequirement.Optional }
};
diff --git a/src/Umbraco.Infrastructure/HealthCheck/HealthCheckNotificationMethodCollection.cs b/src/Umbraco.Core/HealthCheck/HealthCheckNotificationMethodCollection.cs
similarity index 100%
rename from src/Umbraco.Infrastructure/HealthCheck/HealthCheckNotificationMethodCollection.cs
rename to src/Umbraco.Core/HealthCheck/HealthCheckNotificationMethodCollection.cs
diff --git a/src/Umbraco.Infrastructure/HealthCheck/HealthCheckNotificationMethodCollectionBuilder.cs b/src/Umbraco.Core/HealthCheck/HealthCheckNotificationMethodCollectionBuilder.cs
similarity index 100%
rename from src/Umbraco.Infrastructure/HealthCheck/HealthCheckNotificationMethodCollectionBuilder.cs
rename to src/Umbraco.Core/HealthCheck/HealthCheckNotificationMethodCollectionBuilder.cs
diff --git a/src/Umbraco.Infrastructure/HealthCheck/HealthCheckResults.cs b/src/Umbraco.Core/HealthCheck/HealthCheckResults.cs
similarity index 85%
rename from src/Umbraco.Infrastructure/HealthCheck/HealthCheckResults.cs
rename to src/Umbraco.Core/HealthCheck/HealthCheckResults.cs
index 37159b4a49..44955bfaae 100644
--- a/src/Umbraco.Infrastructure/HealthCheck/HealthCheckResults.cs
+++ b/src/Umbraco.Core/HealthCheck/HealthCheckResults.cs
@@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
-using HeyRed.MarkdownSharp;
using Microsoft.Extensions.Logging;
using Umbraco.Core;
using Umbraco.Core.HealthCheck;
@@ -120,33 +119,9 @@ namespace Umbraco.Infrastructure.HealthCheck
return sb.ToString();
}
- public string ResultsAsHtml(HealthCheckNotificationVerbosity verbosity)
- {
- var mark = new Markdown();
- var html = mark.Transform(ResultsAsMarkDown(verbosity));
- html = ApplyHtmlHighlighting(html);
- return html;
- }
internal Dictionary> ResultsAsDictionary => _results;
- private string ApplyHtmlHighlighting(string html)
- {
- const string SuccessHexColor = "5cb85c";
- const string WarningHexColor = "f0ad4e";
- const string ErrorHexColor = "d9534f";
-
- html = ApplyHtmlHighlightingForStatus(html, StatusResultType.Success, SuccessHexColor);
- html = ApplyHtmlHighlightingForStatus(html, StatusResultType.Warning, WarningHexColor);
- return ApplyHtmlHighlightingForStatus(html, StatusResultType.Error, ErrorHexColor);
- }
-
- private string ApplyHtmlHighlightingForStatus(string html, StatusResultType status, string color)
- {
- return html
- .Replace("Result: '" + status + "'", "Result: " + status + "");
- }
-
private string SimpleHtmlToMarkDown(string html)
{
return html.Replace("", "**")
diff --git a/src/Umbraco.Infrastructure/HealthCheck/NotificationMethods/EmailNotificationMethod.cs b/src/Umbraco.Core/HealthCheck/NotificationMethods/EmailNotificationMethod.cs
similarity index 90%
rename from src/Umbraco.Infrastructure/HealthCheck/NotificationMethods/EmailNotificationMethod.cs
rename to src/Umbraco.Core/HealthCheck/NotificationMethods/EmailNotificationMethod.cs
index 4d7444447f..d29f3ccb0b 100644
--- a/src/Umbraco.Infrastructure/HealthCheck/NotificationMethods/EmailNotificationMethod.cs
+++ b/src/Umbraco.Core/HealthCheck/NotificationMethods/EmailNotificationMethod.cs
@@ -17,6 +17,7 @@ namespace Umbraco.Web.HealthCheck.NotificationMethods
private readonly ILocalizedTextService _textService;
private readonly IRequestAccessor _requestAccessor;
private readonly IEmailSender _emailSender;
+ private readonly IMarkdownToHtmlConverter _markdownToHtmlConverter;
private readonly ContentSettings _contentSettings;
@@ -25,7 +26,8 @@ namespace Umbraco.Web.HealthCheck.NotificationMethods
IRequestAccessor requestAccessor,
IEmailSender emailSender,
IOptions healthChecksSettings,
- IOptions contentSettings)
+ IOptions contentSettings,
+ IMarkdownToHtmlConverter markdownToHtmlConverter)
: base(healthChecksSettings)
{
var recipientEmail = Settings?["RecipientEmail"];
@@ -40,6 +42,7 @@ namespace Umbraco.Web.HealthCheck.NotificationMethods
_textService = textService ?? throw new ArgumentNullException(nameof(textService));
_requestAccessor = requestAccessor;
_emailSender = emailSender;
+ _markdownToHtmlConverter = markdownToHtmlConverter;
_contentSettings = contentSettings.Value ?? throw new ArgumentNullException(nameof(contentSettings));
}
@@ -61,7 +64,7 @@ namespace Umbraco.Web.HealthCheck.NotificationMethods
{
DateTime.Now.ToShortDateString(),
DateTime.Now.ToShortTimeString(),
- results.ResultsAsHtml(Verbosity)
+ _markdownToHtmlConverter.ToHtml(results, Verbosity)
});
// Include the umbraco Application URL host in the message subject so that
diff --git a/src/Umbraco.Infrastructure/HealthCheck/NotificationMethods/IHealthCheckNotificationMethod.cs b/src/Umbraco.Core/HealthCheck/NotificationMethods/IHealthCheckNotificationMethod.cs
similarity index 100%
rename from src/Umbraco.Infrastructure/HealthCheck/NotificationMethods/IHealthCheckNotificationMethod.cs
rename to src/Umbraco.Core/HealthCheck/NotificationMethods/IHealthCheckNotificationMethod.cs
diff --git a/src/Umbraco.Core/HealthCheck/NotificationMethods/IMarkdownToHtmlConverter.cs b/src/Umbraco.Core/HealthCheck/NotificationMethods/IMarkdownToHtmlConverter.cs
new file mode 100644
index 0000000000..20d8f0f07e
--- /dev/null
+++ b/src/Umbraco.Core/HealthCheck/NotificationMethods/IMarkdownToHtmlConverter.cs
@@ -0,0 +1,10 @@
+using Umbraco.Core.HealthCheck;
+using Umbraco.Infrastructure.HealthCheck;
+
+namespace Umbraco.Web.HealthCheck.NotificationMethods
+{
+ public interface IMarkdownToHtmlConverter
+ {
+ string ToHtml(HealthCheckResults results, HealthCheckNotificationVerbosity verbosity);
+ }
+}
diff --git a/src/Umbraco.Infrastructure/HealthCheck/NotificationMethods/NotificationMethodBase.cs b/src/Umbraco.Core/HealthCheck/NotificationMethods/NotificationMethodBase.cs
similarity index 100%
rename from src/Umbraco.Infrastructure/HealthCheck/NotificationMethods/NotificationMethodBase.cs
rename to src/Umbraco.Core/HealthCheck/NotificationMethods/NotificationMethodBase.cs
diff --git a/src/Umbraco.Core/Hosting/IHostingEnvironment.cs b/src/Umbraco.Core/Hosting/IHostingEnvironment.cs
index 188fb87b55..60d582c6c9 100644
--- a/src/Umbraco.Core/Hosting/IHostingEnvironment.cs
+++ b/src/Umbraco.Core/Hosting/IHostingEnvironment.cs
@@ -5,6 +5,7 @@ namespace Umbraco.Core.Hosting
public interface IHostingEnvironment
{
string SiteName { get; }
+
string ApplicationId { get; }
///
@@ -35,8 +36,6 @@ namespace Umbraco.Core.Hosting
///
/// Maps a virtual path to a physical path to the application's web root
///
- ///
- ///
///
/// Depending on the runtime 'web root', this result can vary. For example in Net Framework the web root and the content root are the same, however
/// in netcore the web root is /www therefore this will Map to a physical path within www.
@@ -46,8 +45,6 @@ namespace Umbraco.Core.Hosting
///
/// Maps a virtual path to a physical path to the application's root (not always equal to the web root)
///
- ///
- ///
///
/// Depending on the runtime 'web root', this result can vary. For example in Net Framework the web root and the content root are the same, however
/// in netcore the web root is /www therefore this will Map to a physical path within www.
@@ -58,7 +55,6 @@ namespace Umbraco.Core.Hosting
/// Converts a virtual path to an absolute URL path based on the application's web root
///
/// The virtual path. Must start with either ~/ or / else an exception is thrown.
- ///
///
/// This maps the virtual path syntax to the web root. For example when hosting in a virtual directory called "site" and the value "~/pages/test" is passed in, it will
/// map to "/site/pages/test" where "/site" is the value of .
diff --git a/src/Umbraco.Infrastructure/Install/InstallSteps/StarterKitInstallStep.cs b/src/Umbraco.Core/Install/InstallSteps/StarterKitInstallStep.cs
similarity index 98%
rename from src/Umbraco.Infrastructure/Install/InstallSteps/StarterKitInstallStep.cs
rename to src/Umbraco.Core/Install/InstallSteps/StarterKitInstallStep.cs
index 4cd25c16bb..e3cd56c5c1 100644
--- a/src/Umbraco.Infrastructure/Install/InstallSteps/StarterKitInstallStep.cs
+++ b/src/Umbraco.Core/Install/InstallSteps/StarterKitInstallStep.cs
@@ -3,10 +3,9 @@ using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Umbraco.Core.Security;
-using Umbraco.Net;
using Umbraco.Core.Services;
+using Umbraco.Net;
using Umbraco.Web.Install.Models;
-using Umbraco.Web.Security;
namespace Umbraco.Web.Install.InstallSteps
{
diff --git a/src/Umbraco.Infrastructure/Install/Models/InstallInstructions.cs b/src/Umbraco.Core/Install/Models/InstallInstructions.cs
similarity index 100%
rename from src/Umbraco.Infrastructure/Install/Models/InstallInstructions.cs
rename to src/Umbraco.Core/Install/Models/InstallInstructions.cs
diff --git a/src/Umbraco.Core/Logging/ILoggingConfiguration.cs b/src/Umbraco.Core/Logging/ILoggingConfiguration.cs
index d21a08e688..6590f9fc65 100644
--- a/src/Umbraco.Core/Logging/ILoggingConfiguration.cs
+++ b/src/Umbraco.Core/Logging/ILoggingConfiguration.cs
@@ -1,10 +1,10 @@
-namespace Umbraco.Core.Logging
+namespace Umbraco.Core.Logging
{
public interface ILoggingConfiguration
{
///
- /// The physical path where logs are stored
+ /// Gets the physical path where logs are stored
///
string LogDirectory { get; }
}
diff --git a/src/Umbraco.Infrastructure/Media/EmbedProviders/DailyMotion.cs b/src/Umbraco.Core/Media/EmbedProviders/DailyMotion.cs
similarity index 86%
rename from src/Umbraco.Infrastructure/Media/EmbedProviders/DailyMotion.cs
rename to src/Umbraco.Core/Media/EmbedProviders/DailyMotion.cs
index 78ea0b8662..f56a29c2d5 100644
--- a/src/Umbraco.Infrastructure/Media/EmbedProviders/DailyMotion.cs
+++ b/src/Umbraco.Core/Media/EmbedProviders/DailyMotion.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using Umbraco.Core.Serialization;
namespace Umbraco.Web.Media.EmbedProviders
{
@@ -10,7 +11,7 @@ namespace Umbraco.Web.Media.EmbedProviders
{
@"dailymotion.com/video/.*"
};
-
+
public override Dictionary RequestParams => new Dictionary()
{
//ApiUrl/?format=xml
@@ -24,5 +25,9 @@ namespace Umbraco.Web.Media.EmbedProviders
return GetXmlProperty(xmlDocument, "/oembed/html");
}
+
+ public DailyMotion(IJsonSerializer jsonSerializer) : base(jsonSerializer)
+ {
+ }
}
}
diff --git a/src/Umbraco.Infrastructure/Media/EmbedProviders/EmbedProviderBase.cs b/src/Umbraco.Core/Media/EmbedProviders/EmbedProviderBase.cs
similarity index 88%
rename from src/Umbraco.Infrastructure/Media/EmbedProviders/EmbedProviderBase.cs
rename to src/Umbraco.Core/Media/EmbedProviders/EmbedProviderBase.cs
index 539c01f69b..cc7f5d2349 100644
--- a/src/Umbraco.Infrastructure/Media/EmbedProviders/EmbedProviderBase.cs
+++ b/src/Umbraco.Core/Media/EmbedProviders/EmbedProviderBase.cs
@@ -1,16 +1,23 @@
-using Newtonsoft.Json;
-using System;
+using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Xml;
using Umbraco.Core.Media;
+using Umbraco.Core.Serialization;
namespace Umbraco.Web.Media.EmbedProviders
{
public abstract class EmbedProviderBase : IEmbedProvider
{
+ private readonly IJsonSerializer _jsonSerializer;
+
+ protected EmbedProviderBase(IJsonSerializer jsonSerializer)
+ {
+ _jsonSerializer = jsonSerializer;
+ }
+
private static HttpClient _httpClient;
public abstract string ApiEndpoint { get; }
@@ -58,7 +65,7 @@ namespace Umbraco.Web.Media.EmbedProviders
public virtual T GetJsonResponse(string url) where T : class
{
var response = DownloadResponse(url);
- return JsonConvert.DeserializeObject(response);
+ return _jsonSerializer.Deserialize(response);
}
public virtual XmlDocument GetXmlResponse(string url)
diff --git a/src/Umbraco.Infrastructure/Media/EmbedProviders/EmbedProvidersCollection.cs b/src/Umbraco.Core/Media/EmbedProviders/EmbedProvidersCollection.cs
similarity index 100%
rename from src/Umbraco.Infrastructure/Media/EmbedProviders/EmbedProvidersCollection.cs
rename to src/Umbraco.Core/Media/EmbedProviders/EmbedProvidersCollection.cs
diff --git a/src/Umbraco.Infrastructure/Media/EmbedProviders/EmbedProvidersCollectionBuilder.cs b/src/Umbraco.Core/Media/EmbedProviders/EmbedProvidersCollectionBuilder.cs
similarity index 100%
rename from src/Umbraco.Infrastructure/Media/EmbedProviders/EmbedProvidersCollectionBuilder.cs
rename to src/Umbraco.Core/Media/EmbedProviders/EmbedProvidersCollectionBuilder.cs
diff --git a/src/Umbraco.Infrastructure/Media/EmbedProviders/Flickr.cs b/src/Umbraco.Core/Media/EmbedProviders/Flickr.cs
similarity index 90%
rename from src/Umbraco.Infrastructure/Media/EmbedProviders/Flickr.cs
rename to src/Umbraco.Core/Media/EmbedProviders/Flickr.cs
index d067060014..a6ead2df3a 100644
--- a/src/Umbraco.Infrastructure/Media/EmbedProviders/Flickr.cs
+++ b/src/Umbraco.Core/Media/EmbedProviders/Flickr.cs
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Net;
+using Umbraco.Core.Serialization;
namespace Umbraco.Web.Media.EmbedProviders
{
@@ -27,5 +28,9 @@ namespace Umbraco.Web.Media.EmbedProviders
return string.Format("
", imageUrl, imageWidth, imageHeight, WebUtility.HtmlEncode(imageTitle));
}
+
+ public Flickr(IJsonSerializer jsonSerializer) : base(jsonSerializer)
+ {
+ }
}
}
diff --git a/src/Umbraco.Infrastructure/Media/EmbedProviders/GettyImages.cs b/src/Umbraco.Core/Media/EmbedProviders/GettyImages.cs
similarity index 86%
rename from src/Umbraco.Infrastructure/Media/EmbedProviders/GettyImages.cs
rename to src/Umbraco.Core/Media/EmbedProviders/GettyImages.cs
index 34b383614d..0db0a97b8e 100644
--- a/src/Umbraco.Infrastructure/Media/EmbedProviders/GettyImages.cs
+++ b/src/Umbraco.Core/Media/EmbedProviders/GettyImages.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using Umbraco.Core.Serialization;
namespace Umbraco.Web.Media.EmbedProviders
{
@@ -23,5 +24,9 @@ namespace Umbraco.Web.Media.EmbedProviders
return oembed.GetHtml();
}
+
+ public GettyImages(IJsonSerializer jsonSerializer) : base(jsonSerializer)
+ {
+ }
}
}
diff --git a/src/Umbraco.Infrastructure/Media/EmbedProviders/Giphy.cs b/src/Umbraco.Core/Media/EmbedProviders/Giphy.cs
similarity index 83%
rename from src/Umbraco.Infrastructure/Media/EmbedProviders/Giphy.cs
rename to src/Umbraco.Core/Media/EmbedProviders/Giphy.cs
index 1069de749c..319afda5b6 100644
--- a/src/Umbraco.Infrastructure/Media/EmbedProviders/Giphy.cs
+++ b/src/Umbraco.Core/Media/EmbedProviders/Giphy.cs
@@ -1,8 +1,5 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using System.Collections.Generic;
+using Umbraco.Core.Serialization;
namespace Umbraco.Web.Media.EmbedProviders
{
@@ -28,5 +25,9 @@ namespace Umbraco.Web.Media.EmbedProviders
return oembed.GetHtml();
}
+
+ public Giphy(IJsonSerializer jsonSerializer) : base(jsonSerializer)
+ {
+ }
}
}
diff --git a/src/Umbraco.Infrastructure/Media/EmbedProviders/Hulu.cs b/src/Umbraco.Core/Media/EmbedProviders/Hulu.cs
similarity index 85%
rename from src/Umbraco.Infrastructure/Media/EmbedProviders/Hulu.cs
rename to src/Umbraco.Core/Media/EmbedProviders/Hulu.cs
index 150439832a..4deea8c23d 100644
--- a/src/Umbraco.Infrastructure/Media/EmbedProviders/Hulu.cs
+++ b/src/Umbraco.Core/Media/EmbedProviders/Hulu.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using Umbraco.Core.Serialization;
namespace Umbraco.Web.Media.EmbedProviders
{
@@ -10,7 +11,7 @@ namespace Umbraco.Web.Media.EmbedProviders
{
@"hulu.com/watch/.*"
};
-
+
public override Dictionary RequestParams => new Dictionary();
public override string GetMarkup(string url, int maxWidth = 0, int maxHeight = 0)
@@ -20,5 +21,9 @@ namespace Umbraco.Web.Media.EmbedProviders
return oembed.GetHtml();
}
+
+ public Hulu(IJsonSerializer jsonSerializer) : base(jsonSerializer)
+ {
+ }
}
}
diff --git a/src/Umbraco.Infrastructure/Media/EmbedProviders/Issuu.cs b/src/Umbraco.Core/Media/EmbedProviders/Issuu.cs
similarity index 86%
rename from src/Umbraco.Infrastructure/Media/EmbedProviders/Issuu.cs
rename to src/Umbraco.Core/Media/EmbedProviders/Issuu.cs
index 2b33473453..3baaf7ea35 100644
--- a/src/Umbraco.Infrastructure/Media/EmbedProviders/Issuu.cs
+++ b/src/Umbraco.Core/Media/EmbedProviders/Issuu.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using Umbraco.Core.Serialization;
namespace Umbraco.Web.Media.EmbedProviders
{
@@ -10,7 +11,7 @@ namespace Umbraco.Web.Media.EmbedProviders
{
@"issuu.com/.*/docs/.*"
};
-
+
public override Dictionary RequestParams => new Dictionary()
{
//ApiUrl/?format=xml
@@ -24,5 +25,9 @@ namespace Umbraco.Web.Media.EmbedProviders
return GetXmlProperty(xmlDocument, "/oembed/html");
}
+
+ public Issuu(IJsonSerializer jsonSerializer) : base(jsonSerializer)
+ {
+ }
}
}
diff --git a/src/Umbraco.Infrastructure/Media/EmbedProviders/Kickstarter.cs b/src/Umbraco.Core/Media/EmbedProviders/Kickstarter.cs
similarity index 84%
rename from src/Umbraco.Infrastructure/Media/EmbedProviders/Kickstarter.cs
rename to src/Umbraco.Core/Media/EmbedProviders/Kickstarter.cs
index 4de45ae2e3..ef75b6ebe8 100644
--- a/src/Umbraco.Infrastructure/Media/EmbedProviders/Kickstarter.cs
+++ b/src/Umbraco.Core/Media/EmbedProviders/Kickstarter.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using Umbraco.Core.Serialization;
namespace Umbraco.Web.Media.EmbedProviders
{
@@ -20,5 +21,9 @@ namespace Umbraco.Web.Media.EmbedProviders
return oembed.GetHtml();
}
+
+ public Kickstarter(IJsonSerializer jsonSerializer) : base(jsonSerializer)
+ {
+ }
}
}
diff --git a/src/Umbraco.Infrastructure/Media/EmbedProviders/OEmbedResponse.cs b/src/Umbraco.Core/Media/EmbedProviders/OEmbedResponse.cs
similarity index 78%
rename from src/Umbraco.Infrastructure/Media/EmbedProviders/OEmbedResponse.cs
rename to src/Umbraco.Core/Media/EmbedProviders/OEmbedResponse.cs
index cc3e34931e..8178a97742 100644
--- a/src/Umbraco.Infrastructure/Media/EmbedProviders/OEmbedResponse.cs
+++ b/src/Umbraco.Core/Media/EmbedProviders/OEmbedResponse.cs
@@ -1,11 +1,12 @@
using System.Net;
-using Newtonsoft.Json;
+using System.Runtime.Serialization;
namespace Umbraco.Web.Media.EmbedProviders
{
///
/// Wrapper class for OEmbed response
///
+ [DataContract]
public class OEmbedResponse
{
public string Type { get; set; }
@@ -14,25 +15,25 @@ namespace Umbraco.Web.Media.EmbedProviders
public string Title { get; set; }
- [JsonProperty("author_name")]
+ [DataMember(Name ="author_name")]
public string AuthorName { get; set; }
- [JsonProperty("author_url")]
+ [DataMember(Name ="author_url")]
public string AuthorUrl { get; set; }
- [JsonProperty("provider_name")]
+ [DataMember(Name ="provider_name")]
public string ProviderName { get; set; }
- [JsonProperty("provider_url")]
+ [DataMember(Name ="provider_url")]
public string ProviderUrl { get; set; }
- [JsonProperty("thumbnail_url")]
+ [DataMember(Name ="thumbnail_url")]
public string ThumbnailUrl { get; set; }
- [JsonProperty("thumbnail_height")]
+ [DataMember(Name ="thumbnail_height")]
public double? ThumbnailHeight { get; set; }
- [JsonProperty("thumbnail_width")]
+ [DataMember(Name ="thumbnail_width")]
public double? ThumbnailWidth { get; set; }
public string Html { get; set; }
diff --git a/src/Umbraco.Infrastructure/Media/EmbedProviders/Slideshare.cs b/src/Umbraco.Core/Media/EmbedProviders/Slideshare.cs
similarity index 85%
rename from src/Umbraco.Infrastructure/Media/EmbedProviders/Slideshare.cs
rename to src/Umbraco.Core/Media/EmbedProviders/Slideshare.cs
index 6d3a010c7a..7fa149d145 100644
--- a/src/Umbraco.Infrastructure/Media/EmbedProviders/Slideshare.cs
+++ b/src/Umbraco.Core/Media/EmbedProviders/Slideshare.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using Umbraco.Core.Serialization;
namespace Umbraco.Web.Media.EmbedProviders
{
@@ -20,5 +21,9 @@ namespace Umbraco.Web.Media.EmbedProviders
return GetXmlProperty(xmlDocument, "/oembed/html");
}
+
+ public Slideshare(IJsonSerializer jsonSerializer) : base(jsonSerializer)
+ {
+ }
}
}
diff --git a/src/Umbraco.Infrastructure/Media/EmbedProviders/SoundCloud.cs b/src/Umbraco.Core/Media/EmbedProviders/SoundCloud.cs
similarity index 84%
rename from src/Umbraco.Infrastructure/Media/EmbedProviders/SoundCloud.cs
rename to src/Umbraco.Core/Media/EmbedProviders/SoundCloud.cs
index 080437a246..43cc92b0b4 100644
--- a/src/Umbraco.Infrastructure/Media/EmbedProviders/SoundCloud.cs
+++ b/src/Umbraco.Core/Media/EmbedProviders/SoundCloud.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using Umbraco.Core.Serialization;
namespace Umbraco.Web.Media.EmbedProviders
{
@@ -10,7 +11,7 @@ namespace Umbraco.Web.Media.EmbedProviders
{
@"soundcloud.com\/*"
};
-
+
public override Dictionary RequestParams => new Dictionary();
public override string GetMarkup(string url, int maxWidth = 0, int maxHeight = 0)
@@ -20,5 +21,9 @@ namespace Umbraco.Web.Media.EmbedProviders
return GetXmlProperty(xmlDocument, "/oembed/html");
}
+
+ public Soundcloud(IJsonSerializer jsonSerializer) : base(jsonSerializer)
+ {
+ }
}
}
diff --git a/src/Umbraco.Infrastructure/Media/EmbedProviders/Ted.cs b/src/Umbraco.Core/Media/EmbedProviders/Ted.cs
similarity index 85%
rename from src/Umbraco.Infrastructure/Media/EmbedProviders/Ted.cs
rename to src/Umbraco.Core/Media/EmbedProviders/Ted.cs
index aa14423349..cd4b78d065 100644
--- a/src/Umbraco.Infrastructure/Media/EmbedProviders/Ted.cs
+++ b/src/Umbraco.Core/Media/EmbedProviders/Ted.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using Umbraco.Core.Serialization;
namespace Umbraco.Web.Media.EmbedProviders
{
@@ -10,7 +11,7 @@ namespace Umbraco.Web.Media.EmbedProviders
{
@"ted.com\/talks\/*"
};
-
+
public override Dictionary RequestParams => new Dictionary();
public override string GetMarkup(string url, int maxWidth = 0, int maxHeight = 0)
@@ -20,5 +21,9 @@ namespace Umbraco.Web.Media.EmbedProviders
return GetXmlProperty(xmlDocument, "/oembed/html");
}
+
+ public Ted(IJsonSerializer jsonSerializer) : base(jsonSerializer)
+ {
+ }
}
}
diff --git a/src/Umbraco.Infrastructure/Media/EmbedProviders/Twitter.cs b/src/Umbraco.Core/Media/EmbedProviders/Twitter.cs
similarity index 85%
rename from src/Umbraco.Infrastructure/Media/EmbedProviders/Twitter.cs
rename to src/Umbraco.Core/Media/EmbedProviders/Twitter.cs
index 9286934a4d..2bb4203411 100644
--- a/src/Umbraco.Infrastructure/Media/EmbedProviders/Twitter.cs
+++ b/src/Umbraco.Core/Media/EmbedProviders/Twitter.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using Umbraco.Core.Serialization;
namespace Umbraco.Web.Media.EmbedProviders
{
@@ -20,5 +21,9 @@ namespace Umbraco.Web.Media.EmbedProviders
return oembed.GetHtml();
}
+
+ public Twitter(IJsonSerializer jsonSerializer) : base(jsonSerializer)
+ {
+ }
}
}
diff --git a/src/Umbraco.Infrastructure/Media/EmbedProviders/Vimeo.cs b/src/Umbraco.Core/Media/EmbedProviders/Vimeo.cs
similarity index 85%
rename from src/Umbraco.Infrastructure/Media/EmbedProviders/Vimeo.cs
rename to src/Umbraco.Core/Media/EmbedProviders/Vimeo.cs
index 806f40a10c..709ba61b3b 100644
--- a/src/Umbraco.Infrastructure/Media/EmbedProviders/Vimeo.cs
+++ b/src/Umbraco.Core/Media/EmbedProviders/Vimeo.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using Umbraco.Core.Serialization;
namespace Umbraco.Web.Media.EmbedProviders
{
@@ -10,7 +11,7 @@ namespace Umbraco.Web.Media.EmbedProviders
{
@"vimeo\.com/"
};
-
+
public override Dictionary RequestParams => new Dictionary();
public override string GetMarkup(string url, int maxWidth = 0, int maxHeight = 0)
@@ -20,5 +21,9 @@ namespace Umbraco.Web.Media.EmbedProviders
return GetXmlProperty(xmlDocument, "/oembed/html");
}
+
+ public Vimeo(IJsonSerializer jsonSerializer) : base(jsonSerializer)
+ {
+ }
}
}
diff --git a/src/Umbraco.Infrastructure/Media/EmbedProviders/Youtube.cs b/src/Umbraco.Core/Media/EmbedProviders/Youtube.cs
similarity index 86%
rename from src/Umbraco.Infrastructure/Media/EmbedProviders/Youtube.cs
rename to src/Umbraco.Core/Media/EmbedProviders/Youtube.cs
index 4e6f437047..30b83caa88 100644
--- a/src/Umbraco.Infrastructure/Media/EmbedProviders/Youtube.cs
+++ b/src/Umbraco.Core/Media/EmbedProviders/Youtube.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using Umbraco.Core.Serialization;
namespace Umbraco.Web.Media.EmbedProviders
{
@@ -11,7 +12,7 @@ namespace Umbraco.Web.Media.EmbedProviders
@"youtu.be/.*",
@"youtube.com/watch.*"
};
-
+
public override Dictionary RequestParams => new Dictionary()
{
//ApiUrl/?format=json
@@ -25,5 +26,9 @@ namespace Umbraco.Web.Media.EmbedProviders
return oembed.GetHtml();
}
+
+ public YouTube(IJsonSerializer jsonSerializer) : base(jsonSerializer)
+ {
+ }
}
}
diff --git a/src/Umbraco.Infrastructure/Media/Exif/BitConverterEx.cs b/src/Umbraco.Core/Media/Exif/BitConverterEx.cs
similarity index 100%
rename from src/Umbraco.Infrastructure/Media/Exif/BitConverterEx.cs
rename to src/Umbraco.Core/Media/Exif/BitConverterEx.cs
diff --git a/src/Umbraco.Infrastructure/Media/Exif/ExifBitConverter.cs b/src/Umbraco.Core/Media/Exif/ExifBitConverter.cs
similarity index 100%
rename from src/Umbraco.Infrastructure/Media/Exif/ExifBitConverter.cs
rename to src/Umbraco.Core/Media/Exif/ExifBitConverter.cs
diff --git a/src/Umbraco.Infrastructure/Media/Exif/ExifEnums.cs b/src/Umbraco.Core/Media/Exif/ExifEnums.cs
similarity index 100%
rename from src/Umbraco.Infrastructure/Media/Exif/ExifEnums.cs
rename to src/Umbraco.Core/Media/Exif/ExifEnums.cs
diff --git a/src/Umbraco.Infrastructure/Media/Exif/ExifExceptions.cs b/src/Umbraco.Core/Media/Exif/ExifExceptions.cs
similarity index 100%
rename from src/Umbraco.Infrastructure/Media/Exif/ExifExceptions.cs
rename to src/Umbraco.Core/Media/Exif/ExifExceptions.cs
diff --git a/src/Umbraco.Infrastructure/Media/Exif/ExifExtendedProperty.cs b/src/Umbraco.Core/Media/Exif/ExifExtendedProperty.cs
similarity index 100%
rename from src/Umbraco.Infrastructure/Media/Exif/ExifExtendedProperty.cs
rename to src/Umbraco.Core/Media/Exif/ExifExtendedProperty.cs
diff --git a/src/Umbraco.Infrastructure/Media/Exif/ExifFileTypeDescriptor.cs b/src/Umbraco.Core/Media/Exif/ExifFileTypeDescriptor.cs
similarity index 100%
rename from src/Umbraco.Infrastructure/Media/Exif/ExifFileTypeDescriptor.cs
rename to src/Umbraco.Core/Media/Exif/ExifFileTypeDescriptor.cs
diff --git a/src/Umbraco.Infrastructure/Media/Exif/ExifInterOperability.cs b/src/Umbraco.Core/Media/Exif/ExifInterOperability.cs
similarity index 100%
rename from src/Umbraco.Infrastructure/Media/Exif/ExifInterOperability.cs
rename to src/Umbraco.Core/Media/Exif/ExifInterOperability.cs
diff --git a/src/Umbraco.Infrastructure/Media/Exif/ExifProperty.cs b/src/Umbraco.Core/Media/Exif/ExifProperty.cs
similarity index 100%
rename from src/Umbraco.Infrastructure/Media/Exif/ExifProperty.cs
rename to src/Umbraco.Core/Media/Exif/ExifProperty.cs
diff --git a/src/Umbraco.Infrastructure/Media/Exif/ExifPropertyCollection.cs b/src/Umbraco.Core/Media/Exif/ExifPropertyCollection.cs
similarity index 100%
rename from src/Umbraco.Infrastructure/Media/Exif/ExifPropertyCollection.cs
rename to src/Umbraco.Core/Media/Exif/ExifPropertyCollection.cs
diff --git a/src/Umbraco.Infrastructure/Media/Exif/ExifPropertyFactory.cs b/src/Umbraco.Core/Media/Exif/ExifPropertyFactory.cs
similarity index 100%
rename from src/Umbraco.Infrastructure/Media/Exif/ExifPropertyFactory.cs
rename to src/Umbraco.Core/Media/Exif/ExifPropertyFactory.cs
diff --git a/src/Umbraco.Infrastructure/Media/Exif/ExifTag.cs b/src/Umbraco.Core/Media/Exif/ExifTag.cs
similarity index 100%
rename from src/Umbraco.Infrastructure/Media/Exif/ExifTag.cs
rename to src/Umbraco.Core/Media/Exif/ExifTag.cs
diff --git a/src/Umbraco.Infrastructure/Media/Exif/ExifTagFactory.cs b/src/Umbraco.Core/Media/Exif/ExifTagFactory.cs
similarity index 100%
rename from src/Umbraco.Infrastructure/Media/Exif/ExifTagFactory.cs
rename to src/Umbraco.Core/Media/Exif/ExifTagFactory.cs
diff --git a/src/Umbraco.Infrastructure/Media/Exif/IFD.cs b/src/Umbraco.Core/Media/Exif/IFD.cs
similarity index 100%
rename from src/Umbraco.Infrastructure/Media/Exif/IFD.cs
rename to src/Umbraco.Core/Media/Exif/IFD.cs
diff --git a/src/Umbraco.Infrastructure/Media/Exif/ImageFile.cs b/src/Umbraco.Core/Media/Exif/ImageFile.cs
similarity index 94%
rename from src/Umbraco.Infrastructure/Media/Exif/ImageFile.cs
rename to src/Umbraco.Core/Media/Exif/ImageFile.cs
index acd8ce8eec..f59f9dc73f 100644
--- a/src/Umbraco.Infrastructure/Media/Exif/ImageFile.cs
+++ b/src/Umbraco.Core/Media/Exif/ImageFile.cs
@@ -1,5 +1,4 @@
using System.ComponentModel;
-using System.Drawing;
using System.IO;
using System.Text;
using Umbraco.Web.Media.TypeDetector;
@@ -52,11 +51,6 @@ namespace Umbraco.Web.Media.Exif
#endregion
#region Instance Methods
- ///
- /// Converts the to a .
- ///
- /// Returns a containing image data.
- public abstract Image ToImage ();
///
/// Saves the to the specified file.
diff --git a/src/Umbraco.Infrastructure/Media/Exif/ImageFileDirectory.cs b/src/Umbraco.Core/Media/Exif/ImageFileDirectory.cs
similarity index 100%
rename from src/Umbraco.Infrastructure/Media/Exif/ImageFileDirectory.cs
rename to src/Umbraco.Core/Media/Exif/ImageFileDirectory.cs
diff --git a/src/Umbraco.Infrastructure/Media/Exif/ImageFileDirectoryEntry.cs b/src/Umbraco.Core/Media/Exif/ImageFileDirectoryEntry.cs
similarity index 100%
rename from src/Umbraco.Infrastructure/Media/Exif/ImageFileDirectoryEntry.cs
rename to src/Umbraco.Core/Media/Exif/ImageFileDirectoryEntry.cs
diff --git a/src/Umbraco.Infrastructure/Media/Exif/ImageFileFormat.cs b/src/Umbraco.Core/Media/Exif/ImageFileFormat.cs
similarity index 100%
rename from src/Umbraco.Infrastructure/Media/Exif/ImageFileFormat.cs
rename to src/Umbraco.Core/Media/Exif/ImageFileFormat.cs
diff --git a/src/Umbraco.Infrastructure/Media/Exif/JFIFEnums.cs b/src/Umbraco.Core/Media/Exif/JFIFEnums.cs
similarity index 100%
rename from src/Umbraco.Infrastructure/Media/Exif/JFIFEnums.cs
rename to src/Umbraco.Core/Media/Exif/JFIFEnums.cs
diff --git a/src/Umbraco.Infrastructure/Media/Exif/JFIFExtendedProperty.cs b/src/Umbraco.Core/Media/Exif/JFIFExtendedProperty.cs
similarity index 100%
rename from src/Umbraco.Infrastructure/Media/Exif/JFIFExtendedProperty.cs
rename to src/Umbraco.Core/Media/Exif/JFIFExtendedProperty.cs
diff --git a/src/Umbraco.Infrastructure/Media/Exif/JFIFThumbnail.cs b/src/Umbraco.Core/Media/Exif/JFIFThumbnail.cs
similarity index 100%
rename from src/Umbraco.Infrastructure/Media/Exif/JFIFThumbnail.cs
rename to src/Umbraco.Core/Media/Exif/JFIFThumbnail.cs
diff --git a/src/Umbraco.Infrastructure/Media/Exif/JPEGExceptions.cs b/src/Umbraco.Core/Media/Exif/JPEGExceptions.cs
similarity index 100%
rename from src/Umbraco.Infrastructure/Media/Exif/JPEGExceptions.cs
rename to src/Umbraco.Core/Media/Exif/JPEGExceptions.cs
diff --git a/src/Umbraco.Infrastructure/Media/Exif/JPEGFile.cs b/src/Umbraco.Core/Media/Exif/JPEGFile.cs
similarity index 99%
rename from src/Umbraco.Infrastructure/Media/Exif/JPEGFile.cs
rename to src/Umbraco.Core/Media/Exif/JPEGFile.cs
index 35c3788abd..83e6a81eec 100644
--- a/src/Umbraco.Infrastructure/Media/Exif/JPEGFile.cs
+++ b/src/Umbraco.Core/Media/Exif/JPEGFile.cs
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using System.Drawing;
using System.IO;
using System.Text;
@@ -260,15 +259,6 @@ namespace Umbraco.Web.Media.Exif
Save(stream, true);
}
- ///
- /// Returns a System.Drawing.Image created with image data.
- ///
- public override Image ToImage()
- {
- MemoryStream stream = new MemoryStream();
- Save(stream);
- return Image.FromStream(stream);
- }
#endregion
#region Private Helper Methods
diff --git a/src/Umbraco.Infrastructure/Media/Exif/JPEGMarker.cs b/src/Umbraco.Core/Media/Exif/JPEGMarker.cs
similarity index 100%
rename from src/Umbraco.Infrastructure/Media/Exif/JPEGMarker.cs
rename to src/Umbraco.Core/Media/Exif/JPEGMarker.cs
diff --git a/src/Umbraco.Infrastructure/Media/Exif/JPEGSection.cs b/src/Umbraco.Core/Media/Exif/JPEGSection.cs
similarity index 100%
rename from src/Umbraco.Infrastructure/Media/Exif/JPEGSection.cs
rename to src/Umbraco.Core/Media/Exif/JPEGSection.cs
diff --git a/src/Umbraco.Infrastructure/Media/Exif/MathEx.cs b/src/Umbraco.Core/Media/Exif/MathEx.cs
similarity index 100%
rename from src/Umbraco.Infrastructure/Media/Exif/MathEx.cs
rename to src/Umbraco.Core/Media/Exif/MathEx.cs
diff --git a/src/Umbraco.Infrastructure/Media/Exif/SvgFile.cs b/src/Umbraco.Core/Media/Exif/SvgFile.cs
similarity index 86%
rename from src/Umbraco.Infrastructure/Media/Exif/SvgFile.cs
rename to src/Umbraco.Core/Media/Exif/SvgFile.cs
index 8916ac0801..1213bb513f 100644
--- a/src/Umbraco.Infrastructure/Media/Exif/SvgFile.cs
+++ b/src/Umbraco.Core/Media/Exif/SvgFile.cs
@@ -1,6 +1,4 @@
-using System;
-using System.Drawing;
-using System.IO;
+using System.IO;
using System.Linq;
using System.Xml.Linq;
@@ -29,9 +27,5 @@ namespace Umbraco.Web.Media.Exif
{
}
- public override Image ToImage()
- {
- throw new NotImplementedException();
- }
}
}
diff --git a/src/Umbraco.Infrastructure/Media/Exif/TIFFFile.cs b/src/Umbraco.Core/Media/Exif/TIFFFile.cs
similarity index 93%
rename from src/Umbraco.Infrastructure/Media/Exif/TIFFFile.cs
rename to src/Umbraco.Core/Media/Exif/TIFFFile.cs
index 4f5301d526..19575eaff2 100644
--- a/src/Umbraco.Infrastructure/Media/Exif/TIFFFile.cs
+++ b/src/Umbraco.Core/Media/Exif/TIFFFile.cs
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using System.Drawing;
using System.IO;
namespace Umbraco.Web.Media.Exif
@@ -162,16 +161,6 @@ namespace Umbraco.Web.Media.Exif
}
}
- ///
- /// Converts the to a .
- ///
- /// Returns a containing image data.
- public override Image ToImage()
- {
- MemoryStream stream = new MemoryStream();
- Save(stream);
- return Image.FromStream(stream);
- }
#endregion
}
}
diff --git a/src/Umbraco.Infrastructure/Media/Exif/TIFFHeader.cs b/src/Umbraco.Core/Media/Exif/TIFFHeader.cs
similarity index 100%
rename from src/Umbraco.Infrastructure/Media/Exif/TIFFHeader.cs
rename to src/Umbraco.Core/Media/Exif/TIFFHeader.cs
diff --git a/src/Umbraco.Infrastructure/Media/Exif/TIFFStrip.cs b/src/Umbraco.Core/Media/Exif/TIFFStrip.cs
similarity index 100%
rename from src/Umbraco.Infrastructure/Media/Exif/TIFFStrip.cs
rename to src/Umbraco.Core/Media/Exif/TIFFStrip.cs
diff --git a/src/Umbraco.Infrastructure/Media/Exif/Utility.cs b/src/Umbraco.Core/Media/Exif/Utility.cs
similarity index 100%
rename from src/Umbraco.Infrastructure/Media/Exif/Utility.cs
rename to src/Umbraco.Core/Media/Exif/Utility.cs
diff --git a/src/Umbraco.Core/Media/ExifImageDimensionExtractor.cs b/src/Umbraco.Core/Media/ExifImageDimensionExtractor.cs
new file mode 100644
index 0000000000..441d2d6170
--- /dev/null
+++ b/src/Umbraco.Core/Media/ExifImageDimensionExtractor.cs
@@ -0,0 +1,26 @@
+using System;
+using System.IO;
+using Umbraco.Web.Media.Exif;
+
+namespace Umbraco.Core.Media
+{
+ public static class ExifImageDimensionExtractor
+ {
+ public static bool TryGetDimensions(Stream stream, out int width, out int height)
+ {
+ var jpgInfo = ImageFile.FromStream(stream);
+ height = -1;
+ width = -1;
+ if (jpgInfo != null
+ && jpgInfo.Format != ImageFileFormat.Unknown
+ && jpgInfo.Properties.ContainsKey(ExifTag.PixelYDimension)
+ && jpgInfo.Properties.ContainsKey(ExifTag.PixelXDimension))
+ {
+ height = Convert.ToInt32(jpgInfo.Properties[ExifTag.PixelYDimension].Value);
+ width = Convert.ToInt32(jpgInfo.Properties[ExifTag.PixelXDimension].Value);
+ }
+
+ return height > 0 && width > 0;
+ }
+ }
+}
diff --git a/src/Umbraco.Infrastructure/Media/TypeDetector/JpegDetector.cs b/src/Umbraco.Core/Media/TypeDetector/JpegDetector.cs
similarity index 100%
rename from src/Umbraco.Infrastructure/Media/TypeDetector/JpegDetector.cs
rename to src/Umbraco.Core/Media/TypeDetector/JpegDetector.cs
diff --git a/src/Umbraco.Infrastructure/Media/TypeDetector/RasterizedTypeDetector.cs b/src/Umbraco.Core/Media/TypeDetector/RasterizedTypeDetector.cs
similarity index 100%
rename from src/Umbraco.Infrastructure/Media/TypeDetector/RasterizedTypeDetector.cs
rename to src/Umbraco.Core/Media/TypeDetector/RasterizedTypeDetector.cs
diff --git a/src/Umbraco.Infrastructure/Media/TypeDetector/SvgDetector.cs b/src/Umbraco.Core/Media/TypeDetector/SvgDetector.cs
similarity index 100%
rename from src/Umbraco.Infrastructure/Media/TypeDetector/SvgDetector.cs
rename to src/Umbraco.Core/Media/TypeDetector/SvgDetector.cs
diff --git a/src/Umbraco.Infrastructure/Media/TypeDetector/TIFFDetector.cs b/src/Umbraco.Core/Media/TypeDetector/TIFFDetector.cs
similarity index 100%
rename from src/Umbraco.Infrastructure/Media/TypeDetector/TIFFDetector.cs
rename to src/Umbraco.Core/Media/TypeDetector/TIFFDetector.cs
diff --git a/src/Umbraco.Core/Models/ContentEditing/ContentItemBasic.cs b/src/Umbraco.Core/Models/ContentEditing/ContentItemBasic.cs
index 6689e133fc..5f5bc3cebd 100644
--- a/src/Umbraco.Core/Models/ContentEditing/ContentItemBasic.cs
+++ b/src/Umbraco.Core/Models/ContentEditing/ContentItemBasic.cs
@@ -91,6 +91,7 @@ namespace Umbraco.Web.Models.ContentEditing
private IEnumerable _properties;
+ [DataMember(Name = "properties")]
public virtual IEnumerable Properties
{
get => _properties;
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
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.Core/Runtime/MainDom.cs b/src/Umbraco.Core/Runtime/MainDom.cs
index c413557a27..f1f6ee3afc 100644
--- a/src/Umbraco.Core/Runtime/MainDom.cs
+++ b/src/Umbraco.Core/Runtime/MainDom.cs
@@ -157,7 +157,15 @@ namespace Umbraco.Core.Runtime
_logger.LogInformation("Acquiring.");
// Get the lock
- var acquired = _mainDomLock.AcquireLockAsync(LockTimeoutMilliseconds).GetAwaiter().GetResult();
+ var acquired = false;
+ try
+ {
+ acquired = _mainDomLock.AcquireLockAsync(LockTimeoutMilliseconds).GetAwaiter().GetResult();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Error while acquiring");
+ }
if (!acquired)
{
diff --git a/src/Umbraco.Infrastructure/Services/Implement/IInstallationService.cs b/src/Umbraco.Core/Services/IInstallationService.cs
similarity index 100%
rename from src/Umbraco.Infrastructure/Services/Implement/IInstallationService.cs
rename to src/Umbraco.Core/Services/IInstallationService.cs
diff --git a/src/Umbraco.Infrastructure/HealthCheck/MarkdownToHtmlConverter.cs b/src/Umbraco.Infrastructure/HealthCheck/MarkdownToHtmlConverter.cs
new file mode 100644
index 0000000000..39c5fe0bf2
--- /dev/null
+++ b/src/Umbraco.Infrastructure/HealthCheck/MarkdownToHtmlConverter.cs
@@ -0,0 +1,35 @@
+using HeyRed.MarkdownSharp;
+using Umbraco.Core.HealthCheck;
+using Umbraco.Infrastructure.HealthCheck;
+using Umbraco.Web.HealthCheck.NotificationMethods;
+
+namespace Umbraco.Web.HealthCheck
+{
+ public class MarkdownToHtmlConverter : IMarkdownToHtmlConverter
+ {
+ public string ToHtml(HealthCheckResults results, HealthCheckNotificationVerbosity verbosity)
+ {
+ var mark = new Markdown();
+ var html = mark.Transform(results.ResultsAsMarkDown(verbosity));
+ html = ApplyHtmlHighlighting(html);
+ return html;
+ }
+
+ private string ApplyHtmlHighlighting(string html)
+ {
+ const string SuccessHexColor = "5cb85c";
+ const string WarningHexColor = "f0ad4e";
+ const string ErrorHexColor = "d9534f";
+
+ html = ApplyHtmlHighlightingForStatus(html, StatusResultType.Success, SuccessHexColor);
+ html = ApplyHtmlHighlightingForStatus(html, StatusResultType.Warning, WarningHexColor);
+ return ApplyHtmlHighlightingForStatus(html, StatusResultType.Error, ErrorHexColor);
+ }
+
+ private string ApplyHtmlHighlightingForStatus(string html, StatusResultType status, string color)
+ {
+ return html
+ .Replace("Result: '" + status + "'", "Result: " + status + "");
+ }
+ }
+}
diff --git a/src/Umbraco.Infrastructure/HostedServices/HealthCheckNotifier.cs b/src/Umbraco.Infrastructure/HostedServices/HealthCheckNotifier.cs
index 5c8bd0bc2f..cd89ebc046 100644
--- a/src/Umbraco.Infrastructure/HostedServices/HealthCheckNotifier.cs
+++ b/src/Umbraco.Infrastructure/HostedServices/HealthCheckNotifier.cs
@@ -9,12 +9,12 @@ using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Umbraco.Core;
using Umbraco.Core.Configuration;
+using Umbraco.Core.Configuration.Extensions;
using Umbraco.Core.Configuration.Models;
using Umbraco.Core.HealthCheck;
using Umbraco.Core.Logging;
using Umbraco.Core.Scoping;
using Umbraco.Core.Sync;
-using Umbraco.Infrastructure.Configuration.Extensions;
using Umbraco.Infrastructure.HealthCheck;
using Umbraco.Web.HealthCheck;
using Umbraco.Web.HealthCheck.NotificationMethods;
diff --git a/src/Umbraco.Infrastructure/Install/InstallSteps/NewInstallStep.cs b/src/Umbraco.Infrastructure/Install/InstallSteps/NewInstallStep.cs
index 80570ae5de..b7699b7d0e 100644
--- a/src/Umbraco.Infrastructure/Install/InstallSteps/NewInstallStep.cs
+++ b/src/Umbraco.Infrastructure/Install/InstallSteps/NewInstallStep.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Specialized;
using System.Net.Http;
using System.Text;
@@ -24,7 +24,7 @@ namespace Umbraco.Web.Install.InstallSteps
/// display a simple continue installation view.
///
[InstallSetupStep(InstallationType.NewInstall, "User", 20, "")]
- internal class NewInstallStep : InstallSetupStep
+ public class NewInstallStep : InstallSetupStep
{
private readonly IUserService _userService;
private readonly DatabaseBuilder _databaseBuilder;
diff --git a/src/Umbraco.Infrastructure/Logging/Serilog/LoggerConfigExtensions.cs b/src/Umbraco.Infrastructure/Logging/Serilog/LoggerConfigExtensions.cs
index 84270b95bf..5481f22cb6 100644
--- a/src/Umbraco.Infrastructure/Logging/Serilog/LoggerConfigExtensions.cs
+++ b/src/Umbraco.Infrastructure/Logging/Serilog/LoggerConfigExtensions.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.IO;
using System.Text;
using Serilog;
@@ -127,7 +127,7 @@ namespace Umbraco.Core.Logging.Serilog
/// Outputs a CLEF format JSON log at /App_Data/Logs/
///
/// A Serilog LoggerConfiguration
- ///
+ /// The logging configuration
/// The log level you wish the JSON file to collect - default is Verbose (highest)
/// The number of days to keep log files. Default is set to null which means all logs are kept
public static LoggerConfiguration OutputDefaultJsonFile(
@@ -135,13 +135,13 @@ namespace Umbraco.Core.Logging.Serilog
IHostingEnvironment hostingEnvironment,
ILoggingConfiguration loggingConfiguration, LogEventLevel minimumLevel = LogEventLevel.Verbose, int? retainedFileCount = null)
{
- //.clef format (Compact log event format, that can be imported into local SEQ & will make searching/filtering logs easier)
- //Ends with ..txt as Date is inserted before file extension substring
+ // .clef format (Compact log event format, that can be imported into local SEQ & will make searching/filtering logs easier)
+ // Ends with ..txt as Date is inserted before file extension substring
logConfig.WriteTo.File(new CompactJsonFormatter(),
Path.Combine(hostingEnvironment.MapPathContentRoot(Constants.SystemDirectories.LogFiles) ,$"UmbracoTraceLog.{Environment.MachineName}..json"),
shared: true,
- rollingInterval: RollingInterval.Day, //Create a new JSON file every day
- retainedFileCountLimit: retainedFileCount, //Setting to null means we keep all files - default is 31 days
+ rollingInterval: RollingInterval.Day, // Create a new JSON file every day
+ retainedFileCountLimit: retainedFileCount, // Setting to null means we keep all files - default is 31 days
restrictedToMinimumLevel: minimumLevel);
return logConfig;
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/Media/IImageDimensionExtractor.cs b/src/Umbraco.Infrastructure/Media/IImageDimensionExtractor.cs
new file mode 100644
index 0000000000..3da7f37393
--- /dev/null
+++ b/src/Umbraco.Infrastructure/Media/IImageDimensionExtractor.cs
@@ -0,0 +1,9 @@
+using System.IO;
+
+namespace Umbraco.Web.Media
+{
+ public interface IImageDimensionExtractor
+ {
+ public ImageSize GetDimensions(Stream stream);
+ }
+}
diff --git a/src/Umbraco.Infrastructure/Media/ImageHelper.cs b/src/Umbraco.Infrastructure/Media/ImageDimensionExtractor.cs
similarity index 58%
rename from src/Umbraco.Infrastructure/Media/ImageHelper.cs
rename to src/Umbraco.Infrastructure/Media/ImageDimensionExtractor.cs
index ee01ec4a1c..538c559cf6 100644
--- a/src/Umbraco.Infrastructure/Media/ImageHelper.cs
+++ b/src/Umbraco.Infrastructure/Media/ImageDimensionExtractor.cs
@@ -2,11 +2,11 @@
using System.Drawing;
using System.IO;
using Umbraco.Core;
-using Umbraco.Web.Media.Exif;
+using Umbraco.Core.Media;
namespace Umbraco.Web.Media
{
- public static class ImageHelper
+ internal class ImageDimensionExtractor : IImageDimensionExtractor
{
///
/// Gets the dimensions of an image.
@@ -16,24 +16,14 @@ namespace Umbraco.Web.Media
/// First try with EXIF as it is faster and does not load the entire image
/// in memory. Fallback to GDI which means loading the image in memory and thus
/// use potentially large amounts of memory.
- public static Size GetDimensions(Stream stream)
+ public ImageSize GetDimensions(Stream stream)
{
//Try to load with exif
try
{
- var jpgInfo = ImageFile.FromStream(stream);
-
- if (jpgInfo != null
- && jpgInfo.Format != ImageFileFormat.Unknown
- && jpgInfo.Properties.ContainsKey(ExifTag.PixelYDimension)
- && jpgInfo.Properties.ContainsKey(ExifTag.PixelXDimension))
+ if (ExifImageDimensionExtractor.TryGetDimensions(stream, out var width, out var height))
{
- var height = Convert.ToInt32(jpgInfo.Properties[ExifTag.PixelYDimension].Value);
- var width = Convert.ToInt32(jpgInfo.Properties[ExifTag.PixelXDimension].Value);
- if (height > 0 && width > 0)
- {
- return new Size(width, height);
- }
+ return new ImageSize(width, height);
}
}
catch
@@ -48,7 +38,7 @@ namespace Umbraco.Web.Media
{
var fileWidth = image.Width;
var fileHeight = image.Height;
- return new Size(fileWidth, fileHeight);
+ return new ImageSize(fileWidth, fileHeight);
}
}
catch (Exception)
@@ -56,7 +46,7 @@ namespace Umbraco.Web.Media
//We will just swallow, just means we can't read via GDI, we don't want to log an error either
}
- return new Size(Constants.Conventions.Media.DefaultSize, Constants.Conventions.Media.DefaultSize);
+ return new ImageSize(Constants.Conventions.Media.DefaultSize, Constants.Conventions.Media.DefaultSize);
}
}
}
diff --git a/src/Umbraco.Infrastructure/Media/ImageSize.cs b/src/Umbraco.Infrastructure/Media/ImageSize.cs
new file mode 100644
index 0000000000..6d073ac196
--- /dev/null
+++ b/src/Umbraco.Infrastructure/Media/ImageSize.cs
@@ -0,0 +1,15 @@
+namespace Umbraco.Web.Media
+{
+ public struct ImageSize
+ {
+ public int Width { get; }
+ public int Height { get; }
+
+
+ public ImageSize(int width, int height)
+ {
+ Width = width;
+ Height = height;
+ }
+ }
+}
diff --git a/src/Umbraco.Infrastructure/Media/UploadAutoFillProperties.cs b/src/Umbraco.Infrastructure/Media/UploadAutoFillProperties.cs
index deeed7a07c..44d5f5c8c3 100644
--- a/src/Umbraco.Infrastructure/Media/UploadAutoFillProperties.cs
+++ b/src/Umbraco.Infrastructure/Media/UploadAutoFillProperties.cs
@@ -1,5 +1,4 @@
using System;
-using System.Drawing;
using System.IO;
using Microsoft.Extensions.Logging;
using Umbraco.Core;
@@ -18,15 +17,18 @@ namespace Umbraco.Web.Media
private readonly IMediaFileSystem _mediaFileSystem;
private readonly ILogger _logger;
private readonly IImageUrlGenerator _imageUrlGenerator;
+ private readonly IImageDimensionExtractor _imageDimensionExtractor;
public UploadAutoFillProperties(
IMediaFileSystem mediaFileSystem,
ILogger logger,
- IImageUrlGenerator imageUrlGenerator)
+ IImageUrlGenerator imageUrlGenerator,
+ IImageDimensionExtractor imageDimensionExtractor)
{
_mediaFileSystem = mediaFileSystem ?? throw new ArgumentNullException(nameof(mediaFileSystem));
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
_imageUrlGenerator = imageUrlGenerator ?? throw new ArgumentNullException(nameof(imageUrlGenerator));
+ _imageDimensionExtractor = imageDimensionExtractor ?? throw new ArgumentNullException(nameof(imageDimensionExtractor));
}
///
@@ -71,7 +73,7 @@ namespace Umbraco.Web.Media
using (var filestream = _mediaFileSystem.OpenFile(filepath))
{
var extension = (Path.GetExtension(filepath) ?? "").TrimStart('.');
- var size = _imageUrlGenerator.IsSupportedImageFormat(extension) ? (Size?)ImageHelper.GetDimensions(filestream) : null;
+ var size = _imageUrlGenerator.IsSupportedImageFormat(extension) ? (ImageSize?)_imageDimensionExtractor.GetDimensions(filestream) : null;
SetProperties(content, autoFillConfig, size, filestream.Length, extension, culture, segment);
}
}
@@ -105,12 +107,12 @@ namespace Umbraco.Web.Media
else
{
var extension = (Path.GetExtension(filepath) ?? "").TrimStart('.');
- var size = _imageUrlGenerator.IsSupportedImageFormat(extension) ? (Size?)ImageHelper.GetDimensions(filestream) : null;
+ var size = _imageUrlGenerator.IsSupportedImageFormat(extension) ? (ImageSize?)_imageDimensionExtractor.GetDimensions(filestream) : null;
SetProperties(content, autoFillConfig, size, filestream.Length, extension, culture, segment);
}
}
- private static void SetProperties(IContentBase content, ImagingAutoFillUploadField autoFillConfig, Size? size, long length, string extension, string culture, string segment)
+ private static void SetProperties(IContentBase content, ImagingAutoFillUploadField autoFillConfig, ImageSize? size, long length, string extension, string culture, string segment)
{
if (content == null) throw new ArgumentNullException(nameof(content));
if (autoFillConfig == null) throw new ArgumentNullException(nameof(autoFillConfig));
diff --git a/src/Umbraco.Infrastructure/Migrations/Install/DatabaseBuilder.cs b/src/Umbraco.Infrastructure/Migrations/Install/DatabaseBuilder.cs
index b27bc48c8e..98e9bcb4bb 100644
--- a/src/Umbraco.Infrastructure/Migrations/Install/DatabaseBuilder.cs
+++ b/src/Umbraco.Infrastructure/Migrations/Install/DatabaseBuilder.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.IO;
using System.Linq;
using System.Xml.Linq;
@@ -462,7 +462,7 @@ namespace Umbraco.Core.Migrations.Install
{
Message =
"The database configuration failed with the following message: " + ex.Message +
- "\n Please check log file for additional information (can be found in '/App_Data/Logs/')",
+ $"\n Please check log file for additional information (can be found in '{Constants.SystemDirectories.LogFiles}')",
Success = false,
Percentage = "90"
};
diff --git a/src/Umbraco.Infrastructure/Packaging/PackageDataInstallation.cs b/src/Umbraco.Infrastructure/Packaging/PackageDataInstallation.cs
index 483529036b..0b9572cb20 100644
--- a/src/Umbraco.Infrastructure/Packaging/PackageDataInstallation.cs
+++ b/src/Umbraco.Infrastructure/Packaging/PackageDataInstallation.cs
@@ -8,7 +8,6 @@ using System.Xml.XPath;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Umbraco.Core.Collections;
-using Umbraco.Core.Configuration;
using Umbraco.Core.Configuration.Models;
using Umbraco.Core.Models;
using Umbraco.Core.Models.Entities;
@@ -17,7 +16,6 @@ using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Scoping;
using Umbraco.Core.Serialization;
using Umbraco.Core.Services;
-using Umbraco.Core.Services.Implement;
using Umbraco.Core.Strings;
namespace Umbraco.Core.Packaging
@@ -36,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;
@@ -43,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;
@@ -57,6 +56,7 @@ namespace Umbraco.Core.Packaging
_globalSettings = globalSettings.Value;
_localizedTextService = localizedTextService;
_serializer = serializer;
+ _jsonSerializer = jsonSerializer;
_entityService = entityService;
_contentTypeService = contentTypeService;
_contentService = contentService;
@@ -916,7 +916,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/Persistence/LocalDb.cs b/src/Umbraco.Infrastructure/Persistence/LocalDb.cs
index 4ec233e17f..89fce803b2 100644
--- a/src/Umbraco.Infrastructure/Persistence/LocalDb.cs
+++ b/src/Umbraco.Infrastructure/Persistence/LocalDb.cs
@@ -937,7 +937,7 @@ namespace Umbraco.Core.Persistence
/// This is a C# implementation of T-SQL QUOTEDNAME.
/// is optional, it can be '[' (default), ']', '\'' or '"'.
///
- private static string QuotedName(string name, char quote = '[')
+ internal static string QuotedName(string name, char quote = '[')
{
switch (quote)
{
diff --git a/src/Umbraco.Infrastructure/Persistence/UmbracoDatabaseFactory.cs b/src/Umbraco.Infrastructure/Persistence/UmbracoDatabaseFactory.cs
index 7b98bd150e..5c3c984677 100644
--- a/src/Umbraco.Infrastructure/Persistence/UmbracoDatabaseFactory.cs
+++ b/src/Umbraco.Infrastructure/Persistence/UmbracoDatabaseFactory.cs
@@ -327,16 +327,5 @@ namespace Umbraco.Core.Persistence
//db?.Dispose();
Volatile.Write(ref _initialized, false);
}
-
- // during tests, the thread static var can leak between tests
- // this method provides a way to force-reset the variable
- internal void ResetForTests()
- {
- // TODO: remove all this eventually
- //var db = _umbracoDatabaseAccessor.UmbracoDatabase;
- //_umbracoDatabaseAccessor.UmbracoDatabase = null;
- //db?.Dispose();
- //_databaseScopeAccessor.Scope = null;
- }
}
}
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/Runtime/CoreInitialComposer.cs b/src/Umbraco.Infrastructure/Runtime/CoreInitialComposer.cs
index dc71c475d1..c9a67a8543 100644
--- a/src/Umbraco.Infrastructure/Runtime/CoreInitialComposer.cs
+++ b/src/Umbraco.Infrastructure/Runtime/CoreInitialComposer.cs
@@ -1,6 +1,7 @@
using System;
using Examine;
using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Umbraco.Core.Cache;
using Umbraco.Core.Composing;
@@ -9,6 +10,7 @@ using Umbraco.Core.Configuration;
using Umbraco.Core.Configuration.Grid;
using Umbraco.Core.Configuration.Models;
using Umbraco.Core.Dashboards;
+using Umbraco.Core.DependencyInjection;
using Umbraco.Core.Dictionary;
using Umbraco.Core.Events;
using Umbraco.Core.Hosting;
@@ -25,6 +27,7 @@ using Umbraco.Core.PropertyEditors;
using Umbraco.Core.PropertyEditors.Validators;
using Umbraco.Core.PropertyEditors.ValueConverters;
using Umbraco.Core.Scoping;
+using Umbraco.Core.Security;
using Umbraco.Core.Serialization;
using Umbraco.Core.Services;
using Umbraco.Core.Services.Implement;
@@ -56,14 +59,7 @@ using Umbraco.Web.Sections;
using Umbraco.Web.Services;
using Umbraco.Web.Templates;
using Umbraco.Web.Trees;
-using IntegerValidator = Umbraco.Core.PropertyEditors.Validators.IntegerValidator;
using TextStringValueConverter = Umbraco.Core.PropertyEditors.ValueConverters.TextStringValueConverter;
-using Microsoft.Extensions.Logging;
-using Umbraco.Core.DependencyInjection;
-using Umbraco.Core.Configuration.HealthChecks;
-using Umbraco.Core.HealthCheck;
-using Umbraco.Core.HealthCheck.Checks;
-using Umbraco.Core.Security;
namespace Umbraco.Core.Runtime
{
@@ -303,6 +299,7 @@ namespace Umbraco.Core.Runtime
builder.Services.AddUnique();
// register *all* checks, except those marked [HideFromTypeFinder] of course
+ builder.Services.AddUnique();
builder.HealthChecks()
.Add(() => builder.TypeLoader.GetTypes());
@@ -382,6 +379,7 @@ namespace Umbraco.Core.Runtime
builder.Services.AddUnique();
builder.Services.AddUnique();
+ builder.Services.AddUnique();
}
}
}
diff --git a/src/Umbraco.Infrastructure/Runtime/SqlMainDomLock.cs b/src/Umbraco.Infrastructure/Runtime/SqlMainDomLock.cs
index 41bdaa9e01..c73a817327 100644
--- a/src/Umbraco.Infrastructure/Runtime/SqlMainDomLock.cs
+++ b/src/Umbraco.Infrastructure/Runtime/SqlMainDomLock.cs
@@ -7,7 +7,7 @@ using System.Security.Cryptography;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
-using Umbraco.Core.Configuration;
+using NPoco;
using Umbraco.Core.Configuration.Models;
using Umbraco.Core.Hosting;
using Umbraco.Core.Persistence;
@@ -42,7 +42,7 @@ namespace Umbraco.Core.Runtime
loggerFactory,
globalSettings,
connectionStrings,
- new Lazy(() => new MapperCollection(Enumerable.Empty())),
+ new Lazy(() => new Persistence.Mappers.MapperCollection(Enumerable.Empty())),
dbProviderFactoryCreator);
MainDomKey = MainDomKeyPrefix + "-" + (NetworkHelper.MachineName + MainDom.GetMainDomId(_hostingEnvironment)).GenerateHash();
@@ -57,7 +57,9 @@ namespace Umbraco.Core.Runtime
}
if (!(_dbFactory.SqlContext.SqlSyntax is SqlServerSyntaxProvider sqlServerSyntaxProvider))
+ {
throw new NotSupportedException("SqlMainDomLock is only supported for Sql Server");
+ }
_sqlServerSyntax = sqlServerSyntaxProvider;
@@ -65,11 +67,13 @@ namespace Umbraco.Core.Runtime
var tempId = Guid.NewGuid().ToString();
- using var db = _dbFactory.CreateDatabase();
- using var transaction = db.GetTransaction(IsolationLevel.ReadCommitted);
+ IUmbracoDatabase db = null;
try
{
+ db = _dbFactory.CreateDatabase();
+ db.BeginTransaction(IsolationLevel.ReadCommitted);
+
try
{
// wait to get a write lock
@@ -110,7 +114,8 @@ namespace Umbraco.Core.Runtime
}
finally
{
- transaction.Complete();
+ db?.CompleteTransaction();
+ db?.Dispose();
}
@@ -172,11 +177,11 @@ namespace Umbraco.Core.Runtime
return;
}
-
- using var db = _dbFactory.CreateDatabase();
- using var transaction = db.GetTransaction(IsolationLevel.ReadCommitted);
+ IUmbracoDatabase db = null;
try
{
+ db = _dbFactory.CreateDatabase();
+ db.BeginTransaction(IsolationLevel.ReadCommitted);
// get a read lock
_sqlServerSyntax.ReadLock(db, Constants.Locks.MainDom);
@@ -202,7 +207,8 @@ namespace Umbraco.Core.Runtime
}
finally
{
- transaction.Complete();
+ db?.CompleteTransaction();
+ db?.Dispose();
}
}
@@ -221,34 +227,47 @@ namespace Umbraco.Core.Runtime
return Task.Run(() =>
{
- using var db = _dbFactory.CreateDatabase();
-
- var watch = new Stopwatch();
- watch.Start();
- while (true)
+ try
{
- // poll very often, we need to take over as fast as we can
- // local testing shows the actual query to be executed from client/server is approx 300ms but would change depending on environment/IO
- Thread.Sleep(1000);
+ using var db = _dbFactory.CreateDatabase();
- var acquired = TryAcquire(db, tempId, updatedTempId);
- if (acquired.HasValue)
- return acquired.Value;
-
- if (watch.ElapsedMilliseconds >= millisecondsTimeout)
+ var watch = new Stopwatch();
+ watch.Start();
+ while (true)
{
- return AcquireWhenMaxWaitTimeElapsed(db);
+ // poll very often, we need to take over as fast as we can
+ // local testing shows the actual query to be executed from client/server is approx 300ms but would change depending on environment/IO
+ Thread.Sleep(1000);
+
+ var acquired = TryAcquire(db, tempId, updatedTempId);
+ if (acquired.HasValue)
+ return acquired.Value;
+
+ if (watch.ElapsedMilliseconds >= millisecondsTimeout)
+ {
+ return AcquireWhenMaxWaitTimeElapsed(db);
+ }
}
}
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "An error occurred trying to acquire and waiting for existing SqlMainDomLock to shutdown");
+ return false;
+ }
+
}, _cancellationTokenSource.Token);
}
private bool? TryAcquire(IUmbracoDatabase db, string tempId, string updatedTempId)
{
- using var transaction = db.GetTransaction(IsolationLevel.ReadCommitted);
+ // Creates a separate transaction to the DB instance so we aren't allocating tons of new DB instances for each transaction
+ // since this is executed in a tight loop
+
+ ITransaction transaction = null;
try
{
+ transaction = db.GetTransaction(IsolationLevel.ReadCommitted);
// get a read lock
_sqlServerSyntax.ReadLock(db, Constants.Locks.MainDom);
@@ -294,7 +313,8 @@ namespace Umbraco.Core.Runtime
}
finally
{
- transaction.Complete();
+ transaction?.Complete();
+ transaction?.Dispose();
}
return null; // continue
@@ -302,6 +322,9 @@ namespace Umbraco.Core.Runtime
private bool AcquireWhenMaxWaitTimeElapsed(IUmbracoDatabase db)
{
+ // Creates a separate transaction to the DB instance so we aren't allocating tons of new DB instances for each transaction
+ // since this is executed in a tight loop
+
// if the timeout has elapsed, it either means that the other main dom is taking too long to shutdown,
// or it could mean that the previous appdomain was terminated and didn't clear out the main dom SQL row
// and it's just been left as an orphan row.
@@ -311,10 +334,12 @@ namespace Umbraco.Core.Runtime
_logger.LogDebug("Timeout elapsed, assuming orphan row, acquiring MainDom.");
- using var transaction = db.GetTransaction(IsolationLevel.ReadCommitted);
+ ITransaction transaction = null;
try
{
+ transaction = db.GetTransaction(IsolationLevel.ReadCommitted);
+
_sqlServerSyntax.WriteLock(db, Constants.Locks.MainDom);
// so now we update the row with our appdomain id
@@ -337,7 +362,8 @@ namespace Umbraco.Core.Runtime
}
finally
{
- transaction.Complete();
+ transaction?.Complete();
+ transaction?.Dispose();
}
}
@@ -390,11 +416,12 @@ namespace Umbraco.Core.Runtime
if (_dbFactory.Configured)
{
- using var db = _dbFactory.CreateDatabase();
- using var transaction = db.GetTransaction(IsolationLevel.ReadCommitted);
-
+ IUmbracoDatabase db = null;
try
{
+ db = _dbFactory.CreateDatabase();
+ db.BeginTransaction(IsolationLevel.ReadCommitted);
+
// get a write lock
_sqlServerSyntax.WriteLock(db, Constants.Locks.MainDom);
@@ -421,7 +448,15 @@ namespace Umbraco.Core.Runtime
}
finally
{
- transaction.Complete();
+ try
+ {
+ db?.CompleteTransaction();
+ db?.Dispose();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Unexpected error during dispose when completing transaction.");
+ }
}
}
}
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.PublishedCache.NuCache/Umbraco.PublishedCache.NuCache.csproj b/src/Umbraco.PublishedCache.NuCache/Umbraco.PublishedCache.NuCache.csproj
index edb68c6b93..9f63604b0e 100644
--- a/src/Umbraco.PublishedCache.NuCache/Umbraco.PublishedCache.NuCache.csproj
+++ b/src/Umbraco.PublishedCache.NuCache/Umbraco.PublishedCache.NuCache.csproj
@@ -21,12 +21,15 @@
-
- <_Parameter1>Umbraco.Tests
-
+
+ <_Parameter1>Umbraco.Tests
+
+
+ <_Parameter1>Umbraco.Tests.UnitTests
+
<_Parameter1>Umbraco.Tests.Integration
-
+
<_Parameter1>Umbraco.Tests.Benchmarks
diff --git a/src/Umbraco.Tests.Common/Builders/DataEditorBuilder.cs b/src/Umbraco.Tests.Common/Builders/DataEditorBuilder.cs
index a781c6ccea..a600d2d962 100644
--- a/src/Umbraco.Tests.Common/Builders/DataEditorBuilder.cs
+++ b/src/Umbraco.Tests.Common/Builders/DataEditorBuilder.cs
@@ -5,6 +5,7 @@ using System.Collections.Generic;
using Microsoft.Extensions.Logging.Abstractions;
using Moq;
using Umbraco.Core.PropertyEditors;
+using Umbraco.Core.Serialization;
using Umbraco.Core.Services;
using Umbraco.Core.Strings;
@@ -46,7 +47,9 @@ namespace Umbraco.Tests.Common.Builders
Mock.Of(),
Mock.Of(),
Mock.Of(),
- Mock.Of())
+ Mock.Of(),
+ Mock.Of()
+ )
{
DefaultConfiguration = defaultConfiguration,
ExplicitConfigurationEditor = explicitConfigurationEditor,
diff --git a/src/Umbraco.Tests.Common/Builders/DataValueEditorBuilder.cs b/src/Umbraco.Tests.Common/Builders/DataValueEditorBuilder.cs
index cee0931060..61f6c3df78 100644
--- a/src/Umbraco.Tests.Common/Builders/DataValueEditorBuilder.cs
+++ b/src/Umbraco.Tests.Common/Builders/DataValueEditorBuilder.cs
@@ -4,6 +4,7 @@
using System;
using Moq;
using Umbraco.Core.PropertyEditors;
+using Umbraco.Core.Serialization;
using Umbraco.Core.Services;
using Umbraco.Core.Strings;
@@ -56,7 +57,9 @@ namespace Umbraco.Tests.Common.Builders
Mock.Of(),
Mock.Of(),
Mock.Of(),
- Mock.Of())
+ Mock.Of(),
+ Mock.Of()
+ )
{
Configuration = configuration,
View = view,
diff --git a/src/Umbraco.Tests.Common/TestHelperBase.cs b/src/Umbraco.Tests.Common/TestHelperBase.cs
index 24759f9ffb..ed3e28ee21 100644
--- a/src/Umbraco.Tests.Common/TestHelperBase.cs
+++ b/src/Umbraco.Tests.Common/TestHelperBase.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.IO;
using System.Reflection;
using Microsoft.Extensions.DependencyInjection;
@@ -48,7 +48,7 @@ namespace Umbraco.Tests.Common
public TypeLoader GetMockedTypeLoader()
{
- return new TypeLoader(Mock.Of(), Mock.Of(), new DirectoryInfo(GetHostingEnvironment().MapPathContentRoot("~/App_Data/TEMP")), Mock.Of>(), Mock.Of());
+ return new TypeLoader(Mock.Of(), Mock.Of(), new DirectoryInfo(GetHostingEnvironment().MapPathContentRoot(Constants.SystemDirectories.TempData)), Mock.Of>(), Mock.Of());
}
// public Configs GetConfigs() => GetConfigsFactory().Create();
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/Testing/TestDatabase.cs b/src/Umbraco.Tests.Common/TestHelpers/TestDatabase.cs
similarity index 99%
rename from src/Umbraco.Tests/Testing/TestDatabase.cs
rename to src/Umbraco.Tests.Common/TestHelpers/TestDatabase.cs
index 7d58433a52..d1e5669100 100644
--- a/src/Umbraco.Tests/Testing/TestDatabase.cs
+++ b/src/Umbraco.Tests.Common/TestHelpers/TestDatabase.cs
@@ -11,7 +11,6 @@ using NPoco.DatabaseTypes;
using NPoco.Linq;
using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.SqlSyntax;
-using Umbraco.Persistance.SqlCe;
namespace Umbraco.Tests.Testing
{
@@ -33,8 +32,8 @@ namespace Umbraco.Tests.Testing
///
public TestDatabase(DatabaseType databaseType = null, ISqlSyntaxProvider syntaxProvider = null)
{
- DatabaseType = databaseType ?? new SqlServerCEDatabaseType();
- SqlContext = new SqlContext(syntaxProvider ?? new SqlCeSyntaxProvider(), DatabaseType, Mock.Of());
+ DatabaseType = databaseType ?? new SqlServerDatabaseType();
+ SqlContext = new SqlContext(syntaxProvider ?? new SqlServerSyntaxProvider(), DatabaseType, Mock.Of());
}
///
diff --git a/src/Umbraco.Tests.Integration/GlobalSetupTeardown.cs b/src/Umbraco.Tests.Integration/GlobalSetupTeardown.cs
index fe1d604dd9..6e86e97770 100644
--- a/src/Umbraco.Tests.Integration/GlobalSetupTeardown.cs
+++ b/src/Umbraco.Tests.Integration/GlobalSetupTeardown.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
@@ -23,7 +23,8 @@ public class TestsSetup
[OneTimeTearDown]
public void TearDown()
{
- LocalDbTestDatabase.KillLocalDb();
+ LocalDbTestDatabase.Instance?.Finish();
+ SqlDeveloperTestDatabase.Instance?.Finish();
Console.WriteLine("TOTAL TESTS DURATION: {0}", _stopwatch.Elapsed);
}
}
diff --git a/src/Umbraco.Tests.Integration/TestServerTest/UmbracoTestServerTestBase.cs b/src/Umbraco.Tests.Integration/TestServerTest/UmbracoTestServerTestBase.cs
index d60f49971a..93769eaaed 100644
--- a/src/Umbraco.Tests.Integration/TestServerTest/UmbracoTestServerTestBase.cs
+++ b/src/Umbraco.Tests.Integration/TestServerTest/UmbracoTestServerTestBase.cs
@@ -132,11 +132,12 @@ namespace Umbraco.Tests.Integration.TestServerTest
public override void ConfigureServices(IServiceCollection services)
{
+ services.AddTransient();
var typeLoader = services.AddTypeLoader(GetType().Assembly, TestHelper.GetWebHostEnvironment(), TestHelper.GetHostingEnvironment(),
TestHelper.ConsoleLoggerFactory, AppCaches.NoCache, Configuration, TestHelper.Profiler);
var builder = new UmbracoBuilder(services, Configuration, typeLoader);
-
+
builder
.AddConfiguration()
.AddTestCore(TestHelper) // This is the important one!
diff --git a/src/Umbraco.Tests.Integration/Testing/BaseTestDatabase.cs b/src/Umbraco.Tests.Integration/Testing/BaseTestDatabase.cs
new file mode 100644
index 0000000000..02a3da676a
--- /dev/null
+++ b/src/Umbraco.Tests.Integration/Testing/BaseTestDatabase.cs
@@ -0,0 +1,218 @@
+using System;
+using System.Collections.Concurrent;
+using System.Collections.Generic;
+using System.Data;
+using System.Data.SqlClient;
+using System.Diagnostics;
+using System.Linq;
+using System.Threading;
+using Microsoft.Extensions.Logging;
+using Umbraco.Core.Configuration;
+using Umbraco.Core.Migrations.Install;
+using Umbraco.Core.Persistence;
+
+namespace Umbraco.Tests.Integration.Testing
+{
+ public abstract class BaseTestDatabase
+ {
+ protected ILoggerFactory _loggerFactory;
+ protected IUmbracoDatabaseFactory _databaseFactory;
+ protected IEnumerable _testDatabases;
+
+ protected UmbracoDatabase.CommandInfo[] _cachedDatabaseInitCommands;
+
+ protected BlockingCollection _prepareQueue;
+ protected BlockingCollection _readySchemaQueue;
+ protected BlockingCollection _readyEmptyQueue;
+
+ protected abstract void Initialize();
+
+ public TestDbMeta AttachEmpty()
+ {
+ if (_prepareQueue == null)
+ {
+ Initialize();
+ }
+
+ return _readyEmptyQueue.Take();
+ }
+
+ public TestDbMeta AttachSchema()
+ {
+ if (_prepareQueue == null)
+ {
+ Initialize();
+ }
+
+ return _readySchemaQueue.Take();
+ }
+
+ public void Detach(TestDbMeta meta)
+ {
+ _prepareQueue.TryAdd(meta);
+ }
+
+ protected void PrepareDatabase()
+ {
+ Retry(10, () =>
+ {
+ while (_prepareQueue.IsCompleted == false)
+ {
+ TestDbMeta meta;
+ try
+ {
+ meta = _prepareQueue.Take();
+ }
+ catch (InvalidOperationException)
+ {
+ continue;
+ }
+
+ using (var conn = new SqlConnection(meta.ConnectionString))
+ using (var cmd = conn.CreateCommand())
+ {
+ conn.Open();
+ ResetTestDatabase(cmd);
+
+ if (!meta.IsEmpty)
+ {
+ RebuildSchema(cmd, meta);
+ }
+ }
+
+ if (!meta.IsEmpty)
+ {
+ _readySchemaQueue.TryAdd(meta);
+ }
+ else
+ {
+ _readyEmptyQueue.TryAdd(meta);
+ }
+ }
+ });
+ }
+
+ protected void RebuildSchema(IDbCommand command, TestDbMeta meta)
+ {
+ if (_cachedDatabaseInitCommands != null)
+ {
+ foreach (var dbCommand in _cachedDatabaseInitCommands)
+ {
+
+ if (dbCommand.Text.StartsWith("SELECT "))
+ {
+ continue;
+ }
+
+ command.CommandText = dbCommand.Text;
+ command.Parameters.Clear();
+
+ foreach (var parameterInfo in dbCommand.Parameters)
+ {
+ AddParameter(command, parameterInfo);
+ }
+
+ command.ExecuteNonQuery();
+ }
+ }
+ else
+ {
+ _databaseFactory.Configure(meta.ConnectionString, Core.Constants.DatabaseProviders.SqlServer);
+
+ using (var database = (UmbracoDatabase)_databaseFactory.CreateDatabase())
+ {
+ database.LogCommands = true;
+
+ using (var transaction = database.GetTransaction())
+ {
+ var schemaCreator = new DatabaseSchemaCreator(database, _loggerFactory.CreateLogger(), _loggerFactory, new UmbracoVersion());
+ schemaCreator.InitializeDatabaseSchema();
+
+ transaction.Complete();
+
+ _cachedDatabaseInitCommands = database.Commands.ToArray();
+ }
+ }
+ }
+ }
+
+ protected static void SetCommand(SqlCommand command, string sql, params object[] args)
+ {
+ command.CommandType = CommandType.Text;
+ command.CommandText = sql;
+ command.Parameters.Clear();
+
+ for (var i = 0; i < args.Length; i++)
+ {
+ command.Parameters.AddWithValue("@" + i, args[i]);
+ }
+ }
+
+ protected static void AddParameter(IDbCommand cmd, UmbracoDatabase.ParameterInfo parameterInfo)
+ {
+ var p = cmd.CreateParameter();
+ p.ParameterName = parameterInfo.Name;
+ p.Value = parameterInfo.Value;
+ p.DbType = parameterInfo.DbType;
+ p.Size = parameterInfo.Size;
+ cmd.Parameters.Add(p);
+ }
+
+ protected static void ResetTestDatabase(IDbCommand cmd)
+ {
+ // https://stackoverflow.com/questions/536350
+
+ cmd.CommandType = CommandType.Text;
+ cmd.CommandText = @"
+ declare @n char(1);
+ set @n = char(10);
+ declare @stmt nvarchar(max);
+ -- check constraints
+ select @stmt = isnull( @stmt + @n, '' ) +
+ 'alter table [' + schema_name(schema_id) + '].[' + object_name( parent_object_id ) + '] drop constraint [' + name + ']'
+ from sys.check_constraints;
+ -- foreign keys
+ select @stmt = isnull( @stmt + @n, '' ) +
+ 'alter table [' + schema_name(schema_id) + '].[' + object_name( parent_object_id ) + '] drop constraint [' + name + ']'
+ from sys.foreign_keys;
+ -- tables
+ select @stmt = isnull( @stmt + @n, '' ) +
+ 'drop table [' + schema_name(schema_id) + '].[' + name + ']'
+ from sys.tables;
+ exec sp_executesql @stmt;
+ ";
+
+ // rudimentary retry policy since a db can still be in use when we try to drop
+ Retry(10, () => cmd.ExecuteNonQuery());
+ }
+
+ protected static void Retry(int maxIterations, Action action)
+ {
+ for (var i = 0; i < maxIterations; i++)
+ {
+ try
+ {
+ action();
+ return;
+ }
+ catch (SqlException)
+ {
+
+ //Console.Error.WriteLine($"SqlException occured, but we try again {i+1}/{maxIterations}.\n{e}");
+ // This can occur when there's a transaction deadlock which means (i think) that the database is still in use and hasn't been closed properly yet
+ // so we need to just wait a little bit
+ Thread.Sleep(100 * i);
+ if (i == maxIterations - 1)
+ {
+ Debugger.Launch();
+ throw;
+ }
+ }
+ catch (InvalidOperationException)
+ {
+ // Ignore
+ }
+ }
+ }
+ }
+}
diff --git a/src/Umbraco.Tests.Integration/Testing/ITestDatabase.cs b/src/Umbraco.Tests.Integration/Testing/ITestDatabase.cs
new file mode 100644
index 0000000000..28d7e9c8bc
--- /dev/null
+++ b/src/Umbraco.Tests.Integration/Testing/ITestDatabase.cs
@@ -0,0 +1,9 @@
+namespace Umbraco.Tests.Integration.Testing
+{
+ public interface ITestDatabase
+ {
+ TestDbMeta AttachEmpty();
+ TestDbMeta AttachSchema();
+ void Detach(TestDbMeta id);
+ }
+}
diff --git a/src/Umbraco.Tests.Integration/Testing/IntegrationTestComposer.cs b/src/Umbraco.Tests.Integration/Testing/IntegrationTestComposer.cs
index dacfd950e0..39d74f8869 100644
--- a/src/Umbraco.Tests.Integration/Testing/IntegrationTestComposer.cs
+++ b/src/Umbraco.Tests.Integration/Testing/IntegrationTestComposer.cs
@@ -49,8 +49,10 @@ namespace Umbraco.Tests.Integration.Testing
// we don't want persisted nucache files in tests
builder.Services.AddTransient(factory => new PublishedSnapshotServiceOptions { IgnoreLocalDb = true });
+ #if IS_WINDOWS
// ensure all lucene indexes are using RAM directory (no file system)
builder.Services.AddUnique();
+ #endif
// replace this service so that it can lookup the correct file locations
builder.Services.AddUnique(GetLocalizedTextService);
diff --git a/src/Umbraco.Tests.Integration/Testing/LocalDbTestDatabase.cs b/src/Umbraco.Tests.Integration/Testing/LocalDbTestDatabase.cs
index 39f9ca5592..a9a842cdcd 100644
--- a/src/Umbraco.Tests.Integration/Testing/LocalDbTestDatabase.cs
+++ b/src/Umbraco.Tests.Integration/Testing/LocalDbTestDatabase.cs
@@ -1,18 +1,8 @@
-using System;
+using System;
using System.Collections.Concurrent;
-using System.Configuration;
-using System.Data;
-using System.Data.Common;
-using System.Data.SqlClient;
-using System.Diagnostics;
using System.IO;
-using System.Linq;
using System.Threading;
using Microsoft.Extensions.Logging;
-using Umbraco.Core;
-using Umbraco.Core.Configuration;
-using Umbraco.Core.Configuration.Models;
-using Umbraco.Core.Migrations.Install;
using Umbraco.Core.Persistence;
namespace Umbraco.Tests.Integration.Testing
@@ -20,197 +10,104 @@ namespace Umbraco.Tests.Integration.Testing
///
/// Manages a pool of LocalDb databases for integration testing
///
- public class LocalDbTestDatabase
+ public class LocalDbTestDatabase : BaseTestDatabase, ITestDatabase
{
public const string InstanceName = "UmbracoTests";
public const string DatabaseName = "UmbracoTests";
- private readonly ILoggerFactory _loggerFactory;
private readonly LocalDb _localDb;
- private readonly IUmbracoVersion _umbracoVersion;
- private static LocalDb.Instance _instance;
+ private static LocalDb.Instance _localDbInstance;
private static string _filesPath;
- private readonly IUmbracoDatabaseFactory _dbFactory;
- private UmbracoDatabase.CommandInfo[] _dbCommands;
- private string _currentCstr;
- private static DatabasePool _emptyPool;
- private static DatabasePool _schemaPool;
- private DatabasePool _currentPool;
+
+ private const int _threadCount = 2;
+
+ public static LocalDbTestDatabase Instance { get; private set; }
//It's internal because `Umbraco.Core.Persistence.LocalDb` is internal
internal LocalDbTestDatabase(ILoggerFactory loggerFactory, LocalDb localDb, string filesPath, IUmbracoDatabaseFactory dbFactory)
{
- _umbracoVersion = new UmbracoVersion();
_loggerFactory = loggerFactory;
+ _databaseFactory = dbFactory;
+
_localDb = localDb;
_filesPath = filesPath;
- _dbFactory = dbFactory;
- _instance = _localDb.GetInstance(InstanceName);
- if (_instance != null) return;
+ Instance = this; // For GlobalSetupTeardown.cs
+
+ _testDatabases = new[]
+ {
+ // With Schema
+ TestDbMeta.CreateWithoutConnectionString($"{DatabaseName}-1", false),
+ TestDbMeta.CreateWithoutConnectionString($"{DatabaseName}-2", false),
+
+ // Empty (for migration testing etc)
+ TestDbMeta.CreateWithoutConnectionString($"{DatabaseName}-3", true),
+ TestDbMeta.CreateWithoutConnectionString($"{DatabaseName}-4", true),
+ };
+
+ _localDbInstance = _localDb.GetInstance(InstanceName);
+ if (_localDbInstance != null)
+ {
+ return;
+ }
if (_localDb.CreateInstance(InstanceName) == false)
+ {
throw new Exception("Failed to create a LocalDb instance.");
- _instance = _localDb.GetInstance(InstanceName);
+ }
+
+ _localDbInstance = _localDb.GetInstance(InstanceName);
}
- public string ConnectionString => _currentCstr ?? _instance.GetAttachedConnectionString("XXXXXX", _filesPath);
-
- private void Create()
+ protected override void Initialize()
{
var tempName = Guid.NewGuid().ToString("N");
- _instance.CreateDatabase(tempName, _filesPath);
- _instance.DetachDatabase(tempName);
+ _localDbInstance.CreateDatabase(tempName, _filesPath);
+ _localDbInstance.DetachDatabase(tempName);
+ _prepareQueue = new BlockingCollection();
+ _readySchemaQueue = new BlockingCollection();
+ _readyEmptyQueue = new BlockingCollection();
- // there's probably a sweet spot to be found for size / parallel...
-
- var s = ConfigurationManager.AppSettings["Umbraco.Tests.LocalDbTestDatabase.EmptyPoolSize"];
- var emptySize = s == null ? 1 : int.Parse(s);
- s = ConfigurationManager.AppSettings["Umbraco.Tests.LocalDbTestDatabase.EmptyPoolThreadCount"];
- var emptyParallel = s == null ? 1 : int.Parse(s);
- s = ConfigurationManager.AppSettings["Umbraco.Tests.LocalDbTestDatabase.SchemaPoolSize"];
- var schemaSize = s == null ? 1 : int.Parse(s);
- s = ConfigurationManager.AppSettings["Umbraco.Tests.LocalDbTestDatabase.SchemaPoolThreadCount"];
- var schemaParallel = s == null ? 1 : int.Parse(s);
-
- _emptyPool = new DatabasePool(_localDb, _instance, DatabaseName + "-Empty", tempName, _filesPath, emptySize, emptyParallel);
- _schemaPool = new DatabasePool(_localDb, _instance, DatabaseName + "-Schema", tempName, _filesPath, schemaSize, schemaParallel, delete: true, prepare: RebuildSchema);
- }
-
- public int AttachEmpty()
- {
- if (_emptyPool == null)
- Create();
-
- _currentCstr = _emptyPool.AttachDatabase(out var id);
- _currentPool = _emptyPool;
- return id;
- }
-
- public int AttachSchema()
- {
- if (_schemaPool == null)
- Create();
-
- _currentCstr = _schemaPool.AttachDatabase(out var id);
- _currentPool = _schemaPool;
- return id;
- }
-
- public void Detach(int id)
- {
- _currentPool.DetachDatabase(id);
- }
-
- private void RebuildSchema(DbConnection conn, IDbCommand cmd)
- {
-
- if (_dbCommands != null)
+ foreach (var meta in _testDatabases)
{
- foreach (var dbCommand in _dbCommands)
- {
-
- if (dbCommand.Text.StartsWith("SELECT ")) continue;
-
- cmd.CommandText = dbCommand.Text;
- cmd.Parameters.Clear();
- foreach (var parameterInfo in dbCommand.Parameters)
- AddParameter(cmd, parameterInfo);
- cmd.ExecuteNonQuery();
- }
- }
- else
- {
- _dbFactory.Configure(conn.ConnectionString, Constants.DatabaseProviders.SqlServer);
-
- using var database = (UmbracoDatabase)_dbFactory.CreateDatabase();
- // track each db command ran as part of creating the database so we can replay these
- database.LogCommands = true;
-
- using var trans = database.GetTransaction();
-
- var creator = new DatabaseSchemaCreator(database, _loggerFactory.CreateLogger(), _loggerFactory, _umbracoVersion);
- creator.InitializeDatabaseSchema();
-
- trans.Complete(); // commit it
-
- _dbCommands = database.Commands.ToArray();
+ _localDb.CopyDatabaseFiles(tempName, _filesPath, targetDatabaseName: meta.Name, overwrite: true, delete: false);
+ meta.ConnectionString = _localDbInstance.GetAttachedConnectionString(meta.Name, _filesPath);
+ _prepareQueue.Add(meta);
}
- }
-
- private static void AddParameter(IDbCommand cmd, UmbracoDatabase.ParameterInfo parameterInfo)
- {
- var p = cmd.CreateParameter();
- p.ParameterName = parameterInfo.Name;
- p.Value = parameterInfo.Value;
- p.DbType = parameterInfo.DbType;
- p.Size = parameterInfo.Size;
- cmd.Parameters.Add(p);
- }
-
- public void Clear()
- {
- var filename = Path.Combine(_filesPath, DatabaseName).ToUpper();
-
- foreach (var database in _instance.GetDatabases())
+ for (var i = 0; i < _threadCount; i++)
{
- if (database.StartsWith(filename))
- _instance.DropDatabase(database);
- }
-
- foreach (var file in Directory.EnumerateFiles(_filesPath))
- {
- if (file.EndsWith(".mdf") == false && file.EndsWith(".ldf") == false) continue;
- File.Delete(file);
+ var thread = new Thread(PrepareDatabase);
+ thread.Start();
}
}
- private static void ResetLocalDb(IDbCommand cmd)
+ public void Finish()
{
- // https://stackoverflow.com/questions/536350
+ if (_prepareQueue == null)
+ return;
- cmd.CommandType = CommandType.Text;
- cmd.CommandText = @"
- declare @n char(1);
- set @n = char(10);
- declare @stmt nvarchar(max);
- -- check constraints
- select @stmt = isnull( @stmt + @n, '' ) +
- 'alter table [' + schema_name(schema_id) + '].[' + object_name( parent_object_id ) + '] drop constraint [' + name + ']'
- from sys.check_constraints;
- -- foreign keys
- select @stmt = isnull( @stmt + @n, '' ) +
- 'alter table [' + schema_name(schema_id) + '].[' + object_name( parent_object_id ) + '] drop constraint [' + name + ']'
- from sys.foreign_keys;
- -- tables
- select @stmt = isnull( @stmt + @n, '' ) +
- 'drop table [' + schema_name(schema_id) + '].[' + name + ']'
- from sys.tables;
- exec sp_executesql @stmt;
- ";
+ _prepareQueue.CompleteAdding();
+ while (_prepareQueue.TryTake(out _))
+ { }
- // rudimentary retry policy since a db can still be in use when we try to drop
- Retry(10, () =>
- {
- cmd.ExecuteNonQuery();
- });
- }
+ _readyEmptyQueue.CompleteAdding();
+ while (_readyEmptyQueue.TryTake(out _))
+ { }
- public static void KillLocalDb()
- {
- _emptyPool?.Stop();
- _schemaPool?.Stop();
+ _readySchemaQueue.CompleteAdding();
+ while (_readySchemaQueue.TryTake(out _))
+ { }
if (_filesPath == null)
return;
var filename = Path.Combine(_filesPath, DatabaseName).ToUpper();
- foreach (var database in _instance.GetDatabases())
+ foreach (var database in _localDbInstance.GetDatabases())
{
if (database.StartsWith(filename))
- _instance.DropDatabase(database);
+ _localDbInstance.DropDatabase(database);
}
foreach (var file in Directory.EnumerateFiles(_filesPath))
@@ -226,145 +123,5 @@ namespace Umbraco.Tests.Integration.Testing
}
}
}
-
- private static void Retry(int maxIterations, Action action)
- {
- for (var i = 0; i < maxIterations; i++)
- {
- try
- {
- action();
- return;
- }
- catch (SqlException)
- {
-
- //Console.Error.WriteLine($"SqlException occured, but we try again {i+1}/{maxIterations}.\n{e}");
- // This can occur when there's a transaction deadlock which means (i think) that the database is still in use and hasn't been closed properly yet
- // so we need to just wait a little bit
- Thread.Sleep(100 * i);
- if (i == maxIterations - 1)
- {
- Debugger.Launch();
- throw;
- }
- }
- catch (InvalidOperationException)
- {
-
- }
- }
- }
-
- private class DatabasePool
- {
- private readonly LocalDb _localDb;
- private readonly LocalDb.Instance _instance;
- private readonly string _filesPath;
- private readonly string _name;
- private readonly int _size;
- private readonly string[] _cstrs;
- private readonly BlockingCollection _prepareQueue, _readyQueue;
- private readonly Action _prepare;
- private int _current;
-
- public DatabasePool(LocalDb localDb, LocalDb.Instance instance, string name, string tempName, string filesPath, int size, int parallel = 1, Action prepare = null, bool delete = false)
- {
- _localDb = localDb;
- _instance = instance;
- _filesPath = filesPath;
- _name = name;
- _size = size;
- _prepare = prepare;
- _prepareQueue = new BlockingCollection();
- _readyQueue = new BlockingCollection();
- _cstrs = new string[_size];
-
- for (var i = 0; i < size; i++)
- localDb.CopyDatabaseFiles(tempName, filesPath, targetDatabaseName: name + "-" + i, overwrite: true, delete: delete && i == size - 1);
-
- if (prepare == null)
- {
- for (var i = 0; i < size; i++)
- _readyQueue.Add(i);
- }
- else
- {
- for (var i = 0; i < size; i++)
- _prepareQueue.Add(i);
- }
-
- for (var i = 0; i < parallel; i++)
- {
- var thread = new Thread(PrepareThread);
- thread.Start();
- }
- }
-
- public string AttachDatabase(out int id)
- {
- _current = _readyQueue.Take();
- id = _current;
-
- return ConnectionString(_current);
- }
-
- public void DetachDatabase(int id)
- {
- if (id != _current)
- throw new InvalidOperationException("Cannot detatch the non-current db");
-
- _prepareQueue.Add(_current);
- }
-
- private string ConnectionString(int i)
- {
- return _cstrs[i] ?? (_cstrs[i] = _instance.GetAttachedConnectionString(_name + "-" + i, _filesPath));
- }
-
- private void PrepareThread()
- {
- Retry(10, () =>
- {
- while (_prepareQueue.IsCompleted == false)
- {
- int i;
- try
- {
- i = _prepareQueue.Take();
- }
- catch (InvalidOperationException)
- {
- continue;
- }
-
- using (var conn = new SqlConnection(ConnectionString(i)))
- using (var cmd = conn.CreateCommand())
- {
- conn.Open();
- ResetLocalDb(cmd);
-
- _prepare?.Invoke(conn, cmd);
-
- }
-
- if (!_readyQueue.IsAddingCompleted)
- {
- _readyQueue.Add(i);
- }
- }
- });
- }
-
- public void Stop()
- {
- int i;
- _prepareQueue.CompleteAdding();
- while (_prepareQueue.TryTake(out i)) { }
- _readyQueue.CompleteAdding();
- while (_readyQueue.TryTake(out i)) { }
- }
- }
-
}
}
diff --git a/src/Umbraco.Tests.Integration/Testing/SqlDeveloperTestDatabase.cs b/src/Umbraco.Tests.Integration/Testing/SqlDeveloperTestDatabase.cs
new file mode 100644
index 0000000000..4a7f602ac6
--- /dev/null
+++ b/src/Umbraco.Tests.Integration/Testing/SqlDeveloperTestDatabase.cs
@@ -0,0 +1,117 @@
+using System;
+using System.Collections.Concurrent;
+using System.Data.SqlClient;
+using System.Threading;
+using Microsoft.Extensions.Logging;
+using Umbraco.Core.Persistence;
+
+// ReSharper disable ConvertToUsingDeclaration
+
+namespace Umbraco.Tests.Integration.Testing
+{
+ ///
+ /// It's not meant to be pretty, rushed port of LocalDb.cs + LocalDbTestDatabase.cs
+ ///
+ public class SqlDeveloperTestDatabase : BaseTestDatabase, ITestDatabase
+ {
+ private readonly string _masterConnectionString;
+ public const string DatabaseName = "UmbracoTests";
+
+ private const int _threadCount = 2;
+
+ public static SqlDeveloperTestDatabase Instance { get; private set; }
+
+ public SqlDeveloperTestDatabase(ILoggerFactory loggerFactory, IUmbracoDatabaseFactory databaseFactory, string masterConnectionString)
+ {
+ _loggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory));
+ _databaseFactory = databaseFactory ?? throw new ArgumentNullException(nameof(databaseFactory));
+
+ _masterConnectionString = masterConnectionString;
+
+ _testDatabases = new[]
+ {
+ // With Schema
+ TestDbMeta.CreateWithMasterConnectionString($"{DatabaseName}-1", false, masterConnectionString),
+ TestDbMeta.CreateWithMasterConnectionString($"{DatabaseName}-2", false, masterConnectionString),
+
+ // Empty (for migration testing etc)
+ TestDbMeta.CreateWithMasterConnectionString($"{DatabaseName}-3", true, masterConnectionString),
+ TestDbMeta.CreateWithMasterConnectionString($"{DatabaseName}-4", true, masterConnectionString),
+ };
+
+ Instance = this; // For GlobalSetupTeardown.cs
+ }
+
+ protected override void Initialize()
+ {
+ _prepareQueue = new BlockingCollection();
+ _readySchemaQueue = new BlockingCollection();
+ _readyEmptyQueue = new BlockingCollection();
+
+ foreach (var meta in _testDatabases)
+ {
+ CreateDatabase(meta);
+ _prepareQueue.Add(meta);
+ }
+
+ for (var i = 0; i < _threadCount; i++)
+ {
+ var thread = new Thread(PrepareDatabase);
+ thread.Start();
+ }
+ }
+
+ private void CreateDatabase(TestDbMeta meta)
+ {
+ using (var connection = new SqlConnection(_masterConnectionString))
+ {
+ connection.Open();
+ using (var command = connection.CreateCommand())
+ {
+ SetCommand(command, $@"CREATE DATABASE {LocalDb.QuotedName(meta.Name)}");
+ command.ExecuteNonQuery();
+ }
+ }
+ }
+
+ private void Drop(TestDbMeta meta)
+ {
+ using (var connection = new SqlConnection(_masterConnectionString))
+ {
+ connection.Open();
+ using (var command = connection.CreateCommand())
+ {
+ SetCommand(command, $@"
+ ALTER DATABASE{LocalDb.QuotedName(meta.Name)}
+ SET SINGLE_USER
+ WITH ROLLBACK IMMEDIATE
+ ");
+ command.ExecuteNonQuery();
+
+ SetCommand(command, $@"DROP DATABASE {LocalDb.QuotedName(meta.Name)}");
+ command.ExecuteNonQuery();
+ }
+ }
+ }
+
+ public void Finish()
+ {
+ if (_prepareQueue == null)
+ return;
+
+ _prepareQueue.CompleteAdding();
+ while (_prepareQueue.TryTake(out _)) { }
+
+ _readyEmptyQueue.CompleteAdding();
+ while (_readyEmptyQueue.TryTake(out _)) { }
+
+ _readySchemaQueue.CompleteAdding();
+ while (_readySchemaQueue.TryTake(out _)) { }
+
+ foreach (var testDatabase in _testDatabases)
+ {
+ Drop(testDatabase);
+ }
+ }
+ }
+}
diff --git a/src/Umbraco.Tests.Integration/Testing/TestDatabaseFactory.cs b/src/Umbraco.Tests.Integration/Testing/TestDatabaseFactory.cs
new file mode 100644
index 0000000000..9bcbfa4d3a
--- /dev/null
+++ b/src/Umbraco.Tests.Integration/Testing/TestDatabaseFactory.cs
@@ -0,0 +1,43 @@
+using System;
+using Microsoft.Extensions.Logging;
+using Umbraco.Core.Persistence;
+
+namespace Umbraco.Tests.Integration.Testing
+{
+ public class TestDatabaseFactory
+ {
+ public static ITestDatabase Create(string filesPath, ILoggerFactory loggerFactory, TestUmbracoDatabaseFactoryProvider dbFactory)
+ {
+ return string.IsNullOrEmpty(Environment.GetEnvironmentVariable("UmbracoIntegrationTestConnectionString"))
+ ? CreateLocalDb(filesPath, loggerFactory, dbFactory.Create())
+ : CreateSqlDeveloper(loggerFactory, dbFactory.Create());
+ }
+
+ private static ITestDatabase CreateLocalDb(string filesPath, ILoggerFactory loggerFactory, IUmbracoDatabaseFactory dbFactory)
+ {
+ var localDb = new LocalDb();
+
+ if (!localDb.IsAvailable)
+ {
+ throw new InvalidOperationException("LocalDB is not available.");
+ }
+
+ return new LocalDbTestDatabase(loggerFactory, localDb, filesPath, dbFactory);
+ }
+
+ private static ITestDatabase CreateSqlDeveloper(ILoggerFactory loggerFactory, IUmbracoDatabaseFactory dbFactory)
+ {
+ // $ export SA_PASSWORD=Foobar123!
+ // $ export UmbracoIntegrationTestConnectionString="Server=localhost,1433;User Id=sa;Password=$SA_PASSWORD;"
+ // $ docker run -e 'ACCEPT_EULA=Y' -e "SA_PASSWORD=$SA_PASSWORD" -e 'MSSQL_PID=Developer' -p 1433:1433 -d mcr.microsoft.com/mssql/server:2017-latest-ubuntu
+ var connectionString = Environment.GetEnvironmentVariable("UmbracoIntegrationTestConnectionString");
+
+ if (string.IsNullOrEmpty(connectionString))
+ {
+ throw new InvalidOperationException("ENV: UmbracoIntegrationTestConnectionString is not set");
+ }
+
+ return new SqlDeveloperTestDatabase(loggerFactory, dbFactory, connectionString);
+ }
+ }
+}
diff --git a/src/Umbraco.Tests.Integration/Testing/TestDbMeta.cs b/src/Umbraco.Tests.Integration/Testing/TestDbMeta.cs
new file mode 100644
index 0000000000..83702db8e5
--- /dev/null
+++ b/src/Umbraco.Tests.Integration/Testing/TestDbMeta.cs
@@ -0,0 +1,39 @@
+using System.Text.RegularExpressions;
+
+namespace Umbraco.Tests.Integration.Testing
+{
+ public class TestDbMeta
+ {
+
+ public string Name { get; }
+
+ public bool IsEmpty { get; }
+
+ public string ConnectionString { get; set; }
+
+ private TestDbMeta(string name, bool isEmpty, string connectionString)
+ {
+ IsEmpty = isEmpty;
+ Name = name;
+ ConnectionString = connectionString;
+ }
+
+ private static string ConstructConnectionString(string masterConnectionString, string databaseName)
+ {
+ var prefix = Regex.Replace(masterConnectionString, "Database=.+?;", string.Empty);
+ var connectionString = $"{prefix};Database={databaseName};";
+ return connectionString.Replace(";;", ";");
+ }
+
+ public static TestDbMeta CreateWithMasterConnectionString(string name, bool isEmpty, string masterConnectionString)
+ {
+ return new TestDbMeta(name, isEmpty, ConstructConnectionString(masterConnectionString, name));
+ }
+
+ // LocalDb mdf funtimes
+ public static TestDbMeta CreateWithoutConnectionString(string name, bool isEmpty)
+ {
+ return new TestDbMeta(name, isEmpty, null);
+ }
+ }
+}
diff --git a/src/Umbraco.Tests.Integration/Testing/TestUmbracoDatabaseFactoryProvider.cs b/src/Umbraco.Tests.Integration/Testing/TestUmbracoDatabaseFactoryProvider.cs
new file mode 100644
index 0000000000..3eb3757207
--- /dev/null
+++ b/src/Umbraco.Tests.Integration/Testing/TestUmbracoDatabaseFactoryProvider.cs
@@ -0,0 +1,48 @@
+using System;
+using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Options;
+using Umbraco.Core.Configuration.Models;
+using Umbraco.Core.Persistence;
+using Umbraco.Core.Persistence.Mappers;
+
+namespace Umbraco.Tests.Integration.Testing
+{
+ ///
+ /// I want to be able to create a database for integration testsing without setting the connection string on the
+ /// singleton database factory forever.
+ ///
+ public class TestUmbracoDatabaseFactoryProvider
+ {
+ private readonly ILoggerFactory _loggerFactory;
+ private readonly IOptions _globalSettings;
+ private readonly IOptions _connectionStrings;
+ private readonly Lazy _mappers;
+ private readonly IDbProviderFactoryCreator _dbProviderFactoryCreator;
+
+ public TestUmbracoDatabaseFactoryProvider(
+ ILoggerFactory loggerFactory,
+ IOptions globalSettings,
+ IOptions connectionStrings,
+ Lazy mappers,
+ IDbProviderFactoryCreator dbProviderFactoryCreator)
+ {
+ _loggerFactory = loggerFactory;
+ _globalSettings = globalSettings;
+ _connectionStrings = connectionStrings;
+ _mappers = mappers;
+ _dbProviderFactoryCreator = dbProviderFactoryCreator;
+ }
+
+ public IUmbracoDatabaseFactory Create()
+ {
+ // ReSharper disable once ArrangeMethodOrOperatorBody
+ return new UmbracoDatabaseFactory(
+ _loggerFactory.CreateLogger(),
+ _loggerFactory,
+ _globalSettings.Value,
+ _connectionStrings.Value,
+ _mappers,
+ _dbProviderFactoryCreator);
+ }
+ }
+}
diff --git a/src/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs b/src/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs
index a8875de286..43b2d236c7 100644
--- a/src/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs
+++ b/src/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs
@@ -165,6 +165,7 @@ namespace Umbraco.Tests.Integration.Testing
public virtual void ConfigureServices(IServiceCollection services)
{
services.AddSingleton(TestHelper.DbProviderFactoryCreator);
+ services.AddTransient();
var webHostEnvironment = TestHelper.GetWebHostEnvironment();
services.AddRequiredNetCoreServices(TestHelper, webHostEnvironment);
@@ -242,17 +243,17 @@ namespace Umbraco.Tests.Integration.Testing
#region LocalDb
private static readonly object _dbLocker = new object();
- private static LocalDbTestDatabase _dbInstance;
+ private static ITestDatabase _dbInstance;
+ private static TestDbMeta _fixtureDbMeta;
protected void UseTestLocalDb(IServiceProvider serviceProvider)
{
var state = serviceProvider.GetRequiredService();
+ var testDatabaseFactoryProvider = serviceProvider.GetRequiredService();
var databaseFactory = serviceProvider.GetRequiredService();
// This will create a db, install the schema and ensure the app is configured to run
- InstallTestLocalDb(databaseFactory, TestHelper.ConsoleLoggerFactory, state, TestHelper.WorkingDirectory);
- TestDBConnectionString = databaseFactory.ConnectionString;
- InMemoryConfiguration["ConnectionStrings:" + Constants.System.UmbracoConnectionName] = TestDBConnectionString;
+ InstallTestLocalDb(testDatabaseFactoryProvider, databaseFactory, serviceProvider.GetRequiredService(), state, TestHelper.WorkingDirectory);
}
///
@@ -267,17 +268,14 @@ namespace Umbraco.Tests.Integration.Testing
///
/// There must only be ONE instance shared between all tests in a session
///
- private static LocalDbTestDatabase GetOrCreateDatabase(string filesPath, ILoggerFactory loggerFactory, IUmbracoDatabaseFactory dbFactory)
+ private static ITestDatabase GetOrCreateDatabase(string filesPath, ILoggerFactory loggerFactory, TestUmbracoDatabaseFactoryProvider dbFactory)
{
lock (_dbLocker)
{
if (_dbInstance != null)
return _dbInstance;
- var localDb = new LocalDb();
- if (localDb.IsAvailable == false)
- throw new InvalidOperationException("LocalDB is not available.");
- _dbInstance = new LocalDbTestDatabase(loggerFactory, localDb, filesPath, dbFactory);
+ _dbInstance = TestDatabaseFactory.Create(filesPath, loggerFactory, dbFactory);
return _dbInstance;
}
}
@@ -285,16 +283,12 @@ namespace Umbraco.Tests.Integration.Testing
///
/// Creates a LocalDb instance to use for the test
///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
private void InstallTestLocalDb(
- IUmbracoDatabaseFactory databaseFactory, ILoggerFactory loggerFactory,
- IRuntimeState runtimeState, string workingDirectory)
+ TestUmbracoDatabaseFactoryProvider testUmbracoDatabaseFactoryProvider,
+ IUmbracoDatabaseFactory databaseFactory,
+ ILoggerFactory loggerFactory,
+ IRuntimeState runtimeState,
+ string workingDirectory)
{
var dbFilePath = Path.Combine(workingDirectory, "LocalDb");
@@ -310,22 +304,22 @@ namespace Umbraco.Tests.Integration.Testing
if (!Directory.Exists(dbFilePath))
Directory.CreateDirectory(dbFilePath);
- var db = GetOrCreateDatabase(dbFilePath, loggerFactory, databaseFactory);
+ var db = GetOrCreateDatabase(dbFilePath, loggerFactory, testUmbracoDatabaseFactoryProvider);
switch (testOptions.Database)
{
case UmbracoTestOptions.Database.NewSchemaPerTest:
// New DB + Schema
- var newSchemaDbId = db.AttachSchema();
+ var newSchemaDbMeta = db.AttachSchema();
// Add teardown callback
- OnTestTearDown(() => db.Detach(newSchemaDbId));
+ OnTestTearDown(() => db.Detach(newSchemaDbMeta));
// We must re-configure our current factory since attaching a new LocalDb from the pool changes connection strings
if (!databaseFactory.Configured)
{
- databaseFactory.Configure(db.ConnectionString, Constants.DatabaseProviders.SqlServer);
+ databaseFactory.Configure(newSchemaDbMeta.ConnectionString, Constants.DatabaseProviders.SqlServer);
}
// re-run the runtime level check
@@ -335,15 +329,15 @@ namespace Umbraco.Tests.Integration.Testing
break;
case UmbracoTestOptions.Database.NewEmptyPerTest:
- var newEmptyDbId = db.AttachEmpty();
+ var newEmptyDbMeta = db.AttachEmpty();
// Add teardown callback
- OnTestTearDown(() => db.Detach(newEmptyDbId));
+ OnTestTearDown(() => db.Detach(newEmptyDbMeta));
// We must re-configure our current factory since attaching a new LocalDb from the pool changes connection strings
if (!databaseFactory.Configured)
{
- databaseFactory.Configure(db.ConnectionString, Constants.DatabaseProviders.SqlServer);
+ databaseFactory.Configure(newEmptyDbMeta.ConnectionString, Constants.DatabaseProviders.SqlServer);
}
// re-run the runtime level check
@@ -359,16 +353,17 @@ namespace Umbraco.Tests.Integration.Testing
if (FirstTestInFixture)
{
// New DB + Schema
- var newSchemaFixtureDbId = db.AttachSchema();
+ var newSchemaFixtureDbMeta = db.AttachSchema();
+ _fixtureDbMeta = newSchemaFixtureDbMeta;
// Add teardown callback
- OnFixtureTearDown(() => db.Detach(newSchemaFixtureDbId));
+ OnFixtureTearDown(() => db.Detach(newSchemaFixtureDbMeta));
}
// We must re-configure our current factory since attaching a new LocalDb from the pool changes connection strings
if (!databaseFactory.Configured)
{
- databaseFactory.Configure(db.ConnectionString, Constants.DatabaseProviders.SqlServer);
+ databaseFactory.Configure(_fixtureDbMeta.ConnectionString, Constants.DatabaseProviders.SqlServer);
}
// re-run the runtime level check
@@ -382,16 +377,17 @@ namespace Umbraco.Tests.Integration.Testing
if (FirstTestInFixture)
{
// New DB + Schema
- var newEmptyFixtureDbId = db.AttachEmpty();
+ var newEmptyFixtureDbMeta = db.AttachEmpty();
+ _fixtureDbMeta = newEmptyFixtureDbMeta;
// Add teardown callback
- OnFixtureTearDown(() => db.Detach(newEmptyFixtureDbId));
+ OnFixtureTearDown(() => db.Detach(newEmptyFixtureDbMeta));
}
// We must re-configure our current factory since attaching a new LocalDb from the pool changes connection strings
if (!databaseFactory.Configured)
{
- databaseFactory.Configure(db.ConnectionString, Constants.DatabaseProviders.SqlServer);
+ databaseFactory.Configure(_fixtureDbMeta.ConnectionString, Constants.DatabaseProviders.SqlServer);
}
break;
@@ -412,8 +408,6 @@ namespace Umbraco.Tests.Integration.Testing
public TestHelper TestHelper = new TestHelper();
- protected virtual string TestDBConnectionString { get; private set; }
-
protected virtual Action CustomTestSetup => services => { };
///
diff --git a/src/Umbraco.Tests/Migrations/AdvancedMigrationTests.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Migrations/AdvancedMigrationTests.cs
similarity index 97%
rename from src/Umbraco.Tests/Migrations/AdvancedMigrationTests.cs
rename to src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Migrations/AdvancedMigrationTests.cs
index 474528a8ec..ac502ddf80 100644
--- a/src/Umbraco.Tests/Migrations/AdvancedMigrationTests.cs
+++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Migrations/AdvancedMigrationTests.cs
@@ -5,6 +5,7 @@ using Microsoft.Extensions.Logging.Abstractions;
using Moq;
using NUnit.Framework;
using Microsoft.Extensions.Logging;
+using Umbraco.Core.Configuration;
using Umbraco.Core.Migrations;
using Umbraco.Core.Migrations.Install;
using Umbraco.Core.Migrations.Upgrade;
@@ -12,6 +13,7 @@ using Umbraco.Core.Persistence.DatabaseModelDefinitions;
using Umbraco.Core.Persistence.Dtos;
using Umbraco.Core.Services;
using Umbraco.Tests.Common.Builders;
+using Umbraco.Tests.Integration.Testing;
using Umbraco.Tests.TestHelpers;
using Umbraco.Tests.Testing;
@@ -19,10 +21,12 @@ namespace Umbraco.Tests.Migrations
{
[TestFixture]
[UmbracoTest(Database = UmbracoTestOptions.Database.NewEmptyPerTest)]
- public class AdvancedMigrationTests : TestWithDatabaseBase
+ public class AdvancedMigrationTests : UmbracoIntegrationTest
{
private ILoggerFactory _loggerFactory = NullLoggerFactory.Instance;
+ private IUmbracoVersion UmbracoVersion => GetRequiredService();
+
[Test]
public void CreateTableOfTDto()
{
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/Persistence/Repositories/PartialViewRepositoryTests.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/PartialViewRepositoryTests.cs
index 1ae46faa76..ffda46ed0d 100644
--- a/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/PartialViewRepositoryTests.cs
+++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/PartialViewRepositoryTests.cs
@@ -7,6 +7,7 @@ using Umbraco.Core.Models;
using Umbraco.Core.Persistence.Repositories.Implement;
using Umbraco.Tests.Testing;
using System;
+using System.IO;
using Umbraco.Core.Hosting;
using Umbraco.Tests.Integration.Testing;
@@ -55,28 +56,28 @@ namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositor
partialView = new PartialView(PartialViewType.PartialView, "path-2/test-path-2.cshtml") { Content = "// partialView" };
repository.Save(partialView);
Assert.IsTrue(_fileSystem.FileExists("path-2/test-path-2.cshtml"));
- Assert.AreEqual("path-2\\test-path-2.cshtml", partialView.Path); // fixed in 7.3 - 7.2.8 does not update the path
+ Assert.AreEqual("path-2\\test-path-2.cshtml".Replace("\\", $"{Path.DirectorySeparatorChar}"), partialView.Path); // fixed in 7.3 - 7.2.8 does not update the path
Assert.AreEqual("/Views/Partials/path-2/test-path-2.cshtml", partialView.VirtualPath);
partialView = (PartialView) repository.Get("path-2/test-path-2.cshtml");
Assert.IsNotNull(partialView);
- Assert.AreEqual("path-2\\test-path-2.cshtml", partialView.Path);
+ Assert.AreEqual("path-2\\test-path-2.cshtml".Replace("\\", $"{Path.DirectorySeparatorChar}"), partialView.Path);
Assert.AreEqual("/Views/Partials/path-2/test-path-2.cshtml", partialView.VirtualPath);
partialView = new PartialView(PartialViewType.PartialView, "path-2\\test-path-3.cshtml") { Content = "// partialView" };
repository.Save(partialView);
Assert.IsTrue(_fileSystem.FileExists("path-2/test-path-3.cshtml"));
- Assert.AreEqual("path-2\\test-path-3.cshtml", partialView.Path);
+ Assert.AreEqual("path-2\\test-path-3.cshtml".Replace("\\", $"{Path.DirectorySeparatorChar}"), partialView.Path);
Assert.AreEqual("/Views/Partials/path-2/test-path-3.cshtml", partialView.VirtualPath);
partialView = (PartialView) repository.Get("path-2/test-path-3.cshtml");
Assert.IsNotNull(partialView);
- Assert.AreEqual("path-2\\test-path-3.cshtml", partialView.Path);
+ Assert.AreEqual("path-2\\test-path-3.cshtml".Replace("\\", $"{Path.DirectorySeparatorChar}"), partialView.Path);
Assert.AreEqual("/Views/Partials/path-2/test-path-3.cshtml", partialView.VirtualPath);
partialView = (PartialView) repository.Get("path-2\\test-path-3.cshtml");
Assert.IsNotNull(partialView);
- Assert.AreEqual("path-2\\test-path-3.cshtml", partialView.Path);
+ Assert.AreEqual("path-2\\test-path-3.cshtml".Replace("\\", $"{Path.DirectorySeparatorChar}"), partialView.Path);
Assert.AreEqual("/Views/Partials/path-2/test-path-3.cshtml", partialView.VirtualPath);
partialView = new PartialView(PartialViewType.PartialView, "\\test-path-4.cshtml") { Content = "// partialView" };
diff --git a/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/ScriptRepositoryTest.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/ScriptRepositoryTest.cs
index 9e4ae80ec6..f9084332b7 100644
--- a/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/ScriptRepositoryTest.cs
+++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/ScriptRepositoryTest.cs
@@ -280,36 +280,36 @@ namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositor
repository.Save(script);
Assert.IsTrue(_fileSystem.FileExists("scripts/path-2/test-path-2.js"));
- Assert.AreEqual("scripts\\path-2\\test-path-2.js", script.Path);
+ Assert.AreEqual("scripts\\path-2\\test-path-2.js".Replace("\\", $"{Path.DirectorySeparatorChar}"), script.Path);
Assert.AreEqual("/scripts/scripts/path-2/test-path-2.js", script.VirtualPath);
script = new Script("path-2/test-path-2.js") { Content = "// script" };
repository.Save(script);
Assert.IsTrue(_fileSystem.FileExists("path-2/test-path-2.js"));
- Assert.AreEqual("path-2\\test-path-2.js", script.Path); // fixed in 7.3 - 7.2.8 does not update the path
+ Assert.AreEqual("path-2\\test-path-2.js".Replace("\\", $"{Path.DirectorySeparatorChar}"), script.Path);// fixed in 7.3 - 7.2.8 does not update the path
Assert.AreEqual("/scripts/path-2/test-path-2.js", script.VirtualPath);
script = repository.Get("path-2/test-path-2.js");
Assert.IsNotNull(script);
- Assert.AreEqual("path-2\\test-path-2.js", script.Path);
+ Assert.AreEqual("path-2\\test-path-2.js".Replace("\\", $"{Path.DirectorySeparatorChar}"), script.Path);
Assert.AreEqual("/scripts/path-2/test-path-2.js", script.VirtualPath);
script = new Script("path-2\\test-path-3.js") { Content = "// script" };
repository.Save(script);
Assert.IsTrue(_fileSystem.FileExists("path-2/test-path-3.js"));
- Assert.AreEqual("path-2\\test-path-3.js", script.Path);
+ Assert.AreEqual("path-2\\test-path-3.js".Replace("\\", $"{Path.DirectorySeparatorChar}"), script.Path);
Assert.AreEqual("/scripts/path-2/test-path-3.js", script.VirtualPath);
script = repository.Get("path-2/test-path-3.js");
Assert.IsNotNull(script);
- Assert.AreEqual("path-2\\test-path-3.js", script.Path);
+ Assert.AreEqual("path-2\\test-path-3.js".Replace("\\", $"{Path.DirectorySeparatorChar}"), script.Path);
Assert.AreEqual("/scripts/path-2/test-path-3.js", script.VirtualPath);
script = repository.Get("path-2\\test-path-3.js");
Assert.IsNotNull(script);
- Assert.AreEqual("path-2\\test-path-3.js", script.Path);
+ Assert.AreEqual("path-2\\test-path-3.js".Replace("\\", $"{Path.DirectorySeparatorChar}"), script.Path);
Assert.AreEqual("/scripts/path-2/test-path-3.js", script.VirtualPath);
script = new Script("\\test-path-4.js") { Content = "// script" };
diff --git a/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/StylesheetRepositoryTest.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/StylesheetRepositoryTest.cs
index a576666e6e..b4b8316f83 100644
--- a/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/StylesheetRepositoryTest.cs
+++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/StylesheetRepositoryTest.cs
@@ -135,7 +135,7 @@ namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositor
stylesheet = repository.Get(stylesheet.Name);
//Assert
- Assert.That(stylesheet.Content, Is.EqualTo("body { color:#000; } .bold {font-weight:bold;}\r\n\r\n/**umb_name:Test*/\r\np {\r\n\tfont-size:2em;\r\n}"));
+ Assert.That(stylesheet.Content, Is.EqualTo("body { color:#000; } .bold {font-weight:bold;}\r\n\r\n/**umb_name:Test*/\r\np {\r\n\tfont-size:2em;\r\n}".Replace("\r\n", Environment.NewLine)));
Assert.AreEqual(1, stylesheet.Properties.Count());
}
}
@@ -281,29 +281,29 @@ namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositor
repository.Save(stylesheet);
Assert.IsTrue(_fileSystem.FileExists("path-2/test-path-2.css"));
- Assert.AreEqual("path-2\\test-path-2.css", stylesheet.Path); // fixed in 7.3 - 7.2.8 does not update the path
+ Assert.AreEqual("path-2\\test-path-2.css".Replace("\\", $"{Path.DirectorySeparatorChar}"), stylesheet.Path);// fixed in 7.3 - 7.2.8 does not update the path
Assert.AreEqual("/css/path-2/test-path-2.css", stylesheet.VirtualPath);
stylesheet = repository.Get("path-2/test-path-2.css");
Assert.IsNotNull(stylesheet);
- Assert.AreEqual("path-2\\test-path-2.css", stylesheet.Path);
+ Assert.AreEqual("path-2\\test-path-2.css".Replace("\\", $"{Path.DirectorySeparatorChar}"), stylesheet.Path);
Assert.AreEqual("/css/path-2/test-path-2.css", stylesheet.VirtualPath);
stylesheet = new Stylesheet("path-2\\test-path-3.css") { Content = "body { color:#000; } .bold {font-weight:bold;}" };
repository.Save(stylesheet);
Assert.IsTrue(_fileSystem.FileExists("path-2/test-path-3.css"));
- Assert.AreEqual("path-2\\test-path-3.css", stylesheet.Path);
+ Assert.AreEqual("path-2\\test-path-3.css".Replace("\\", $"{Path.DirectorySeparatorChar}"), stylesheet.Path);
Assert.AreEqual("/css/path-2/test-path-3.css", stylesheet.VirtualPath);
stylesheet = repository.Get("path-2/test-path-3.css");
Assert.IsNotNull(stylesheet);
- Assert.AreEqual("path-2\\test-path-3.css", stylesheet.Path);
+ Assert.AreEqual("path-2\\test-path-3.css".Replace("\\", $"{Path.DirectorySeparatorChar}"), stylesheet.Path);
Assert.AreEqual("/css/path-2/test-path-3.css", stylesheet.VirtualPath);
stylesheet = repository.Get("path-2\\test-path-3.css");
Assert.IsNotNull(stylesheet);
- Assert.AreEqual("path-2\\test-path-3.css", stylesheet.Path);
+ Assert.AreEqual("path-2\\test-path-3.css".Replace("\\", $"{Path.DirectorySeparatorChar}"), stylesheet.Path);
Assert.AreEqual("/css/path-2/test-path-3.css", stylesheet.VirtualPath);
stylesheet = new Stylesheet("\\test-path-4.css") { Content = "body { color:#000; } .bold {font-weight:bold;}" };
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.Infrastructure/Services/Importing/ImportResources.resx b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/Importing/ImportResources.resx
index 5823fa1245..fdf7880297 100644
--- a/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/Importing/ImportResources.resx
+++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/Importing/ImportResources.resx
@@ -119,6 +119,6 @@
- dictionary-package.xml;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8
+ Dictionary-Package.xml;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8
-
\ No newline at end of file
+
diff --git a/src/Umbraco.Tests/Services/RedirectUrlServiceTests.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/RedirectUrlServiceTests.cs
similarity index 55%
rename from src/Umbraco.Tests/Services/RedirectUrlServiceTests.cs
rename to src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/RedirectUrlServiceTests.cs
index 8f38bd67eb..89cde051e3 100644
--- a/src/Umbraco.Tests/Services/RedirectUrlServiceTests.cs
+++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/RedirectUrlServiceTests.cs
@@ -1,81 +1,72 @@
-using System;
-using System.Linq;
+using System.Linq;
using System.Threading;
using Microsoft.Extensions.Logging;
using Moq;
using NUnit.Framework;
using Umbraco.Core.Cache;
-using Umbraco.Core.Logging;
using Umbraco.Core.Models;
-
-using Umbraco.Core.Persistence.Repositories;
using Umbraco.Core.Persistence.Repositories.Implement;
using Umbraco.Core.Scoping;
+using Umbraco.Core.Services;
+using Umbraco.Tests.Integration.Testing;
using Umbraco.Tests.Testing;
-namespace Umbraco.Tests.Services
+namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Services
{
[TestFixture]
[Apartment(ApartmentState.STA)]
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
- public class RedirectUrlServiceTests : TestWithSomeContentBase
+ public class RedirectUrlServiceTests : UmbracoIntegrationTestWithContent
{
private IContent _testPage;
private IContent _altTestPage;
- private string _url = "blah";
- private string _cultureA = "en";
- private string _cultureB = "de";
+ private const string Url = "blah";
+ private const string CultureA = "en";
+ private const string CultureB = "de";
+
+ private IRedirectUrlService RedirectUrlService => GetRequiredService();
+
public override void CreateTestData()
{
base.CreateTestData();
- using (var scope = ScopeProvider.CreateScope())
+ using (IScope scope = ScopeProvider.CreateScope())
{
var repository = new RedirectUrlRepository((IScopeAccessor)ScopeProvider, AppCaches.Disabled, Mock.Of>());
- var rootContent = ServiceContext.ContentService.GetRootContent().FirstOrDefault();
- var subPages = ServiceContext.ContentService.GetPagedChildren(rootContent.Id, 0, 2, out _).ToList();
+ IContent rootContent = ContentService.GetRootContent().First();
+ var subPages = ContentService.GetPagedChildren(rootContent.Id, 0, 2, out _).ToList();
_testPage = subPages[0];
_altTestPage = subPages[1];
repository.Save(new RedirectUrl
{
ContentKey = _testPage.Key,
- Url = _url,
- Culture = _cultureA
+ Url = Url,
+ Culture = CultureA
});
repository.Save(new RedirectUrl
{
ContentKey = _altTestPage.Key,
- Url = _url,
- Culture = _cultureB
+ Url = Url,
+ Culture = CultureB
});
scope.Complete();
}
}
- [TearDown]
- public override void TearDown()
- {
- base.TearDown();
- }
[Test]
public void Can_Get_Most_Recent_RedirectUrl()
{
- var redirectUrlService = ServiceContext.RedirectUrlService;
- var redirect = redirectUrlService.GetMostRecentRedirectUrl(_url);
+ IRedirectUrl redirect = RedirectUrlService.GetMostRecentRedirectUrl(Url);
Assert.AreEqual(redirect.ContentId, _altTestPage.Id);
-
}
[Test]
public void Can_Get_Most_Recent_RedirectUrl_With_Culture()
{
- var redirectUrlService = ServiceContext.RedirectUrlService;
- var redirect = redirectUrlService.GetMostRecentRedirectUrl(_url, _cultureA);
+ IRedirectUrl redirect = RedirectUrlService.GetMostRecentRedirectUrl(Url, CultureA);
Assert.AreEqual(redirect.ContentId, _testPage.Id);
-
}
-
}
}
diff --git a/src/Umbraco.Tests.Integration/Umbraco.Tests.Integration.csproj b/src/Umbraco.Tests.Integration/Umbraco.Tests.Integration.csproj
index c5b42f9848..b996205712 100644
--- a/src/Umbraco.Tests.Integration/Umbraco.Tests.Integration.csproj
+++ b/src/Umbraco.Tests.Integration/Umbraco.Tests.Integration.csproj
@@ -7,6 +7,10 @@
8
+
+ IS_WINDOWS
+
+
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/Cache/DefaultCachePolicyTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Cache/DefaultCachePolicyTests.cs
similarity index 91%
rename from src/Umbraco.Tests/Cache/DefaultCachePolicyTests.cs
rename to src/Umbraco.Tests.UnitTests/Umbraco.Core/Cache/DefaultCachePolicyTests.cs
index 74aba2b824..a8592356e9 100644
--- a/src/Umbraco.Tests/Cache/DefaultCachePolicyTests.cs
+++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Cache/DefaultCachePolicyTests.cs
@@ -1,13 +1,12 @@
using System;
using System.Collections.Generic;
-using System.Web.Caching;
using Moq;
using NUnit.Framework;
using Umbraco.Core.Cache;
using Umbraco.Core.Models;
using Umbraco.Core.Scoping;
-namespace Umbraco.Tests.Cache
+namespace Umbraco.Tests.UnitTests.Umbraco.Core.Cache
{
[TestFixture]
public class DefaultCachePolicyTests
@@ -37,7 +36,7 @@ namespace Umbraco.Tests.Cache
var defaultPolicy = new DefaultRepositoryCachePolicy(cache.Object, DefaultAccessor, new RepositoryCachePolicyOptions());
- var unused = defaultPolicy.Get(1, id => new AuditItem(1, AuditType.Copy, 123, "test", "blah"), o => null);
+ AuditItem unused = defaultPolicy.Get(1, id => new AuditItem(1, AuditType.Copy, 123, "test", "blah"), o => null);
Assert.IsTrue(isCached);
}
@@ -49,7 +48,7 @@ namespace Umbraco.Tests.Cache
var defaultPolicy = new DefaultRepositoryCachePolicy(cache.Object, DefaultAccessor, new RepositoryCachePolicyOptions());
- var found = defaultPolicy.Get(1, id => null, ids => null);
+ AuditItem found = defaultPolicy.Get(1, id => null, ids => null);
Assert.IsNotNull(found);
}
@@ -67,7 +66,7 @@ namespace Umbraco.Tests.Cache
var defaultPolicy = new DefaultRepositoryCachePolicy(cache.Object, DefaultAccessor, new RepositoryCachePolicyOptions());
- var unused = defaultPolicy.GetAll(new object[] {}, ids => new[]
+ AuditItem[] unused = defaultPolicy.GetAll(new object[] {}, ids => new[]
{
new AuditItem(1, AuditType.Copy, 123, "test", "blah"),
new AuditItem(2, AuditType.Copy, 123, "test", "blah2")
@@ -88,7 +87,7 @@ namespace Umbraco.Tests.Cache
var defaultPolicy = new DefaultRepositoryCachePolicy(cache.Object, DefaultAccessor, new RepositoryCachePolicyOptions());
- var found = defaultPolicy.GetAll(new object[] {}, ids => new[] { (AuditItem)null });
+ AuditItem[] found = defaultPolicy.GetAll(new object[] {}, ids => new[] { (AuditItem)null });
Assert.AreEqual(2, found.Length);
}
diff --git a/src/Umbraco.Tests/Cache/FullDataSetCachePolicyTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Cache/FullDataSetCachePolicyTests.cs
similarity index 99%
rename from src/Umbraco.Tests/Cache/FullDataSetCachePolicyTests.cs
rename to src/Umbraco.Tests.UnitTests/Umbraco.Core/Cache/FullDataSetCachePolicyTests.cs
index 027f6d2d69..e904f9104e 100644
--- a/src/Umbraco.Tests/Cache/FullDataSetCachePolicyTests.cs
+++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Cache/FullDataSetCachePolicyTests.cs
@@ -2,7 +2,6 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
-using System.Web.Caching;
using Moq;
using NUnit.Framework;
using Umbraco.Core.Cache;
@@ -10,7 +9,7 @@ using Umbraco.Core.Collections;
using Umbraco.Core.Models;
using Umbraco.Core.Scoping;
-namespace Umbraco.Tests.Cache
+namespace Umbraco.Tests.UnitTests.Umbraco.Core.Cache
{
[TestFixture]
public class FullDataSetCachePolicyTests
diff --git a/src/Umbraco.Tests/Cache/RefresherTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Cache/RefresherTests.cs
similarity index 98%
rename from src/Umbraco.Tests/Cache/RefresherTests.cs
rename to src/Umbraco.Tests.UnitTests/Umbraco.Core/Cache/RefresherTests.cs
index eb8580c9e2..59d2f010d2 100644
--- a/src/Umbraco.Tests/Cache/RefresherTests.cs
+++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Cache/RefresherTests.cs
@@ -4,7 +4,7 @@ using NUnit.Framework;
using Umbraco.Core.Services.Changes;
using Umbraco.Web.Cache;
-namespace Umbraco.Tests.Cache
+namespace Umbraco.Tests.UnitTests.Umbraco.Core.Cache
{
[TestFixture]
public class RefreshersTests
diff --git a/src/Umbraco.Tests/Cache/SingleItemsOnlyCachePolicyTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Cache/SingleItemsOnlyCachePolicyTests.cs
similarity index 97%
rename from src/Umbraco.Tests/Cache/SingleItemsOnlyCachePolicyTests.cs
rename to src/Umbraco.Tests.UnitTests/Umbraco.Core/Cache/SingleItemsOnlyCachePolicyTests.cs
index 335335e391..323b83699c 100644
--- a/src/Umbraco.Tests/Cache/SingleItemsOnlyCachePolicyTests.cs
+++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Cache/SingleItemsOnlyCachePolicyTests.cs
@@ -1,13 +1,12 @@
using System;
using System.Collections.Generic;
-using System.Web.Caching;
using Moq;
using NUnit.Framework;
using Umbraco.Core.Cache;
using Umbraco.Core.Models;
using Umbraco.Core.Scoping;
-namespace Umbraco.Tests.Cache
+namespace Umbraco.Tests.UnitTests.Umbraco.Core.Cache
{
[TestFixture]
public class SingleItemsOnlyCachePolicyTests
diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Components/ComponentTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Components/ComponentTests.cs
index 3bc29c9a9d..7b876af85d 100644
--- a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Components/ComponentTests.cs
+++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Components/ComponentTests.cs
@@ -67,7 +67,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.Components
private static TypeLoader MockTypeLoader()
{
var ioHelper = IOHelper;
- return new TypeLoader(Mock.Of(), Mock.Of(), new DirectoryInfo(TestHelper.GetHostingEnvironment().MapPathContentRoot("~/App_Data/TEMP")), Mock.Of>(), Mock.Of());
+ return new TypeLoader(Mock.Of(), Mock.Of(), new DirectoryInfo(TestHelper.GetHostingEnvironment().MapPathContentRoot(Constants.SystemDirectories.TempData)), Mock.Of>(), Mock.Of());
}
@@ -389,7 +389,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.Components
public void AllComposers()
{
var typeFinder = TestHelper.GetTypeFinder();
- var typeLoader = new TypeLoader(typeFinder, AppCaches.Disabled.RuntimeCache, new DirectoryInfo(TestHelper.GetHostingEnvironment().MapPathContentRoot("~/App_Data/TEMP")), Mock.Of>(), Mock.Of());
+ var typeLoader = new TypeLoader(typeFinder, AppCaches.Disabled.RuntimeCache, new DirectoryInfo(TestHelper.GetHostingEnvironment().MapPathContentRoot(Constants.SystemDirectories.TempData)), Mock.Of>(), Mock.Of());
var register = MockRegister();
var builder = new UmbracoBuilder(register, Mock.Of(), TestHelper.GetMockedTypeLoader());
diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Composing/ComposingTestBase.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Composing/ComposingTestBase.cs
index 43760d1c6c..1c8bf139ac 100644
--- a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Composing/ComposingTestBase.cs
+++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Composing/ComposingTestBase.cs
@@ -1,9 +1,10 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.IO;
using System.Reflection;
using Microsoft.Extensions.Logging;
using Moq;
using NUnit.Framework;
+using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Core.Composing;
using Umbraco.Core.Logging;
@@ -23,7 +24,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.Composing
ProfilingLogger = new ProfilingLogger(Mock.Of>(), Mock.Of());
var typeFinder = TestHelper.GetTypeFinder();
- TypeLoader = new TypeLoader(typeFinder, NoAppCache.Instance, new DirectoryInfo(TestHelper.GetHostingEnvironment().MapPathContentRoot("~/App_Data/TEMP")), Mock.Of>(), ProfilingLogger, false, AssembliesToScan);
+ TypeLoader = new TypeLoader(typeFinder, NoAppCache.Instance, new DirectoryInfo(TestHelper.GetHostingEnvironment().MapPathContentRoot(Constants.SystemDirectories.TempData)), Mock.Of>(), ProfilingLogger, false, AssembliesToScan);
}
protected virtual IEnumerable AssembliesToScan
diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Composing/TypeLoaderTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Composing/TypeLoaderTests.cs
index 20e9f8feef..36843ad1cc 100644
--- a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Composing/TypeLoaderTests.cs
+++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Composing/TypeLoaderTests.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -28,7 +28,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.Composing
// this ensures it's reset
var typeFinder = TestHelper.GetTypeFinder();
_typeLoader = new TypeLoader(typeFinder, NoAppCache.Instance,
- new DirectoryInfo(TestHelper.GetHostingEnvironment().MapPathContentRoot("~/App_Data/TEMP")),
+ new DirectoryInfo(TestHelper.GetHostingEnvironment().MapPathContentRoot(Constants.SystemDirectories.TempData)),
Mock.Of>(), new ProfilingLogger(Mock.Of>(), Mock.Of()), false,
// for testing, we'll specify which assemblies are scanned for the PluginTypeResolver
diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Configuration/Models/Extensions/HealthCheckSettingsExtensionsTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Configuration/Models/Extensions/HealthCheckSettingsExtensionsTests.cs
index 5bc14b3792..d3e2ca3014 100644
--- a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Configuration/Models/Extensions/HealthCheckSettingsExtensionsTests.cs
+++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Configuration/Models/Extensions/HealthCheckSettingsExtensionsTests.cs
@@ -4,8 +4,8 @@
using System;
using NUnit.Framework;
using Umbraco.Core.Configuration;
+using Umbraco.Core.Configuration.Extensions;
using Umbraco.Core.Configuration.Models;
-using Umbraco.Infrastructure.Configuration.Extensions;
namespace Umbraco.Tests.UnitTests.Umbraco.Core.Configuration.Models.Extensions
{
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/Published/ConvertersTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/ConvertersTests.cs
similarity index 62%
rename from src/Umbraco.Tests/Published/ConvertersTests.cs
rename to src/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/ConvertersTests.cs
index 840ec58f13..f41a950c27 100644
--- a/src/Umbraco.Tests/Published/ConvertersTests.cs
+++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/ConvertersTests.cs
@@ -14,9 +14,9 @@ using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Serialization;
using Umbraco.Core.Services;
using Umbraco.Core.Strings;
-using Umbraco.Tests.PublishedContent;
+using Umbraco.Tests.Common.PublishedContent;
using Umbraco.Tests.TestHelpers;
-using Umbraco.Web;
+using Umbraco.Tests.UnitTests.TestHelpers;
using Umbraco.Web.PublishedCache;
namespace Umbraco.Tests.Published
@@ -24,13 +24,10 @@ namespace Umbraco.Tests.Published
[TestFixture]
public class ConvertersTests
{
- #region SimpleConverter3
-
[Test]
public void SimpleConverter3Test()
{
- // Current.Reset();
- var register = TestHelper.GetRegister();
+ var register = new ServiceCollection();
var composition = new UmbracoBuilder(register, Mock.Of(), TestHelper.GetMockedTypeLoader());
@@ -38,37 +35,41 @@ namespace Umbraco.Tests.Published
.Append()
.Append();
- IPublishedModelFactory factory = new PublishedModelFactory(new[]
- {
- typeof (PublishedSnapshotTestObjects.TestElementModel1), typeof (PublishedSnapshotTestObjects.TestElementModel2),
- typeof (PublishedSnapshotTestObjects.TestContentModel1), typeof (PublishedSnapshotTestObjects.TestContentModel2),
- }, Mock.Of());
+ IPublishedModelFactory factory = new PublishedModelFactory(
+ new[]
+ {
+ typeof(PublishedSnapshotTestObjects.TestElementModel1),
+ typeof(PublishedSnapshotTestObjects.TestElementModel2),
+ typeof(PublishedSnapshotTestObjects.TestContentModel1),
+ typeof(PublishedSnapshotTestObjects.TestContentModel2)
+ }, Mock.Of());
register.AddTransient(f => factory);
-
var cacheMock = new Mock();
var cacheContent = new Dictionary();
- cacheMock.Setup(x => x.GetById(It.IsAny())).Returns(id => cacheContent.TryGetValue(id, out IPublishedContent content) ? content : null);
+ cacheMock.Setup(x => x.GetById(It.IsAny())).Returns(id =>
+ cacheContent.TryGetValue(id, out IPublishedContent content) ? content : null);
var publishedSnapshotMock = new Mock();
publishedSnapshotMock.Setup(x => x.Content).Returns(cacheMock.Object);
var publishedSnapshotAccessorMock = new Mock();
publishedSnapshotAccessorMock.Setup(x => x.PublishedSnapshot).Returns(publishedSnapshotMock.Object);
register.AddTransient(f => publishedSnapshotAccessorMock.Object);
- var registerFactory = composition.CreateServiceProvider();
- var converters = registerFactory.GetRequiredService();
+ IServiceProvider registerFactory = composition.CreateServiceProvider();
+ PropertyValueConverterCollection converters =
+ registerFactory.GetRequiredService();
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)
- { Id = 1 };
+ 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)
- { Id = 2 };
+ Mock.Of(), Mock.Of(), Mock.Of(), new JsonNetSerializer()),
+ serializer) { Id = 2 };
- dataTypeServiceMock.Setup(x => x.GetAll()).Returns(new []{dataType1, dataType2 });
+ dataTypeServiceMock.Setup(x => x.GetAll()).Returns(new[] { dataType1, dataType2 });
var contentTypeFactory = new PublishedContentTypeFactory(factory, converters, dataTypeServiceMock.Object);
@@ -77,52 +78,69 @@ namespace Umbraco.Tests.Published
yield return contentTypeFactory.CreatePropertyType(contentType, "prop" + i, i);
}
- var elementType1 = contentTypeFactory.CreateContentType(Guid.NewGuid(), 1000, "element1", t => CreatePropertyTypes(t, 1));
- var elementType2 = contentTypeFactory.CreateContentType(Guid.NewGuid(), 1001, "element2", t => CreatePropertyTypes(t, 2));
- var contentType1 = contentTypeFactory.CreateContentType(Guid.NewGuid(), 1002, "content1", t => CreatePropertyTypes(t, 1));
- var contentType2 = contentTypeFactory.CreateContentType(Guid.NewGuid(), 1003, "content2", t => CreatePropertyTypes(t, 2));
+ IPublishedContentType elementType1 =
+ contentTypeFactory.CreateContentType(Guid.NewGuid(), 1000, "element1", t => CreatePropertyTypes(t, 1));
+ IPublishedContentType elementType2 =
+ contentTypeFactory.CreateContentType(Guid.NewGuid(), 1001, "element2", t => CreatePropertyTypes(t, 2));
+ IPublishedContentType contentType1 =
+ contentTypeFactory.CreateContentType(Guid.NewGuid(), 1002, "content1", t => CreatePropertyTypes(t, 1));
+ IPublishedContentType contentType2 =
+ contentTypeFactory.CreateContentType(Guid.NewGuid(), 1003, "content2", t => CreatePropertyTypes(t, 2));
- var element1 = new PublishedElement(elementType1, Guid.NewGuid(), new Dictionary { { "prop1", "val1" } }, false);
- var element2 = new PublishedElement(elementType2, Guid.NewGuid(), new Dictionary { { "prop2", "1003" } }, false);
+ var element1 = new PublishedElement(elementType1, Guid.NewGuid(),
+ new Dictionary { { "prop1", "val1" } }, false);
+ var element2 = new PublishedElement(elementType2, Guid.NewGuid(),
+ new Dictionary { { "prop2", "1003" } }, false);
var cnt1 = new SolidPublishedContent(contentType1)
{
Id = 1003,
- Properties = new[] { new SolidPublishedProperty { Alias = "prop1", SolidHasValue = true, SolidValue = "val1" } }
+ Properties = new[]
+ {
+ new SolidPublishedProperty { Alias = "prop1", SolidHasValue = true, SolidValue = "val1" }
+ }
};
var cnt2 = new SolidPublishedContent(contentType1)
{
Id = 1004,
- Properties = new[] { new SolidPublishedProperty { Alias = "prop2", SolidHasValue = true, SolidValue = "1003" } }
+ Properties = new[]
+ {
+ new SolidPublishedProperty { Alias = "prop2", SolidHasValue = true, SolidValue = "1003" }
+ }
};
- var publishedModelFactory = registerFactory.GetRequiredService();
+ IPublishedModelFactory publishedModelFactory = registerFactory.GetRequiredService();
cacheContent[cnt1.Id] = cnt1.CreateModel(publishedModelFactory);
cacheContent[cnt2.Id] = cnt2.CreateModel(publishedModelFactory);
// can get the actual property Clr type
// ie ModelType gets properly mapped by IPublishedContentModelFactory
// must test ModelClrType with special equals 'cos they are not ref-equals
- Assert.IsTrue(ModelType.Equals(typeof(IEnumerable<>).MakeGenericType(ModelType.For("content1")), contentType2.GetPropertyType("prop2").ModelClrType));
- Assert.AreEqual(typeof(IEnumerable), contentType2.GetPropertyType("prop2").ClrType);
+ Assert.IsTrue(ModelType.Equals(typeof(IEnumerable<>).MakeGenericType(ModelType.For("content1")),
+ contentType2.GetPropertyType("prop2").ModelClrType));
+ Assert.AreEqual(typeof(IEnumerable),
+ contentType2.GetPropertyType("prop2").ClrType);
// can create a model for an element
- var model1 = factory.CreateModel(element1);
+ IPublishedElement model1 = factory.CreateModel(element1);
Assert.IsInstanceOf(model1);
Assert.AreEqual("val1", ((PublishedSnapshotTestObjects.TestElementModel1)model1).Prop1);
// can create a model for a published content
- var model2 = factory.CreateModel(element2);
+ IPublishedElement model2 = factory.CreateModel(element2);
Assert.IsInstanceOf(model2);
var mmodel2 = (PublishedSnapshotTestObjects.TestElementModel2)model2;
// and get direct property
- Assert.IsInstanceOf(model2.Value(Mock.Of(), "prop2"));
- Assert.AreEqual(1, ((PublishedSnapshotTestObjects.TestContentModel1[])model2.Value(Mock.Of(), "prop2")).Length);
+ Assert.IsInstanceOf(
+ model2.Value(Mock.Of(), "prop2"));
+ Assert.AreEqual(1,
+ ((PublishedSnapshotTestObjects.TestContentModel1[])model2.Value(Mock.Of(),
+ "prop2")).Length);
// and get model property
Assert.IsInstanceOf>(mmodel2.Prop2);
Assert.IsInstanceOf(mmodel2.Prop2);
- var mmodel1 = mmodel2.Prop2.First();
+ PublishedSnapshotTestObjects.TestContentModel1 mmodel1 = mmodel2.Prop2.First();
// and we get what we want
Assert.AreSame(cacheContent[mmodel1.Id], mmodel1);
@@ -144,10 +162,8 @@ namespace Umbraco.Tests.Published
{
private readonly IPublishedSnapshotAccessor _publishedSnapshotAccessor;
- public SimpleConverter3B(IPublishedSnapshotAccessor publishedSnapshotAccessor)
- {
+ public SimpleConverter3B(IPublishedSnapshotAccessor publishedSnapshotAccessor) =>
_publishedSnapshotAccessor = publishedSnapshotAccessor;
- }
public override bool IsConverter(IPublishedPropertyType propertyType)
=> propertyType.EditorAlias == "Umbraco.Void.2";
@@ -158,18 +174,18 @@ namespace Umbraco.Tests.Published
public override PropertyCacheLevel GetPropertyCacheLevel(IPublishedPropertyType propertyType)
=> PropertyCacheLevel.Elements;
- public override object ConvertSourceToIntermediate(IPublishedElement owner, IPublishedPropertyType propertyType, object source, bool preview)
+ public override object ConvertSourceToIntermediate(IPublishedElement owner,
+ IPublishedPropertyType propertyType, object source, bool preview)
{
var s = source as string;
return s?.Split(',').Select(int.Parse).ToArray() ?? Array.Empty();
}
- public override object ConvertIntermediateToObject(IPublishedElement owner, IPublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview)
- {
- return ((int[])inter).Select(x => (PublishedSnapshotTestObjects.TestContentModel1)_publishedSnapshotAccessor.PublishedSnapshot.Content.GetById(x)).ToArray();
- }
+ public override object ConvertIntermediateToObject(IPublishedElement owner,
+ IPublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter,
+ bool preview) => ((int[])inter).Select(x =>
+ (PublishedSnapshotTestObjects.TestContentModel1)_publishedSnapshotAccessor.PublishedSnapshot.Content
+ .GetById(x)).ToArray();
}
-
- #endregion
}
}
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