diff --git a/build/NuSpecs/UmbracoCms.Core.nuspec b/build/NuSpecs/UmbracoCms.Core.nuspec
index 56462fcc40..fce15eb487 100644
--- a/build/NuSpecs/UmbracoCms.Core.nuspec
+++ b/build/NuSpecs/UmbracoCms.Core.nuspec
@@ -14,6 +14,7 @@
Contains the core assemblies needed to run Umbraco Cms
en-US
umbraco
+
@@ -44,7 +45,7 @@
-
+
@@ -55,6 +56,6 @@
-
+
diff --git a/build/NuSpecs/UmbracoCms.Web.nuspec b/build/NuSpecs/UmbracoCms.Web.nuspec
index 614a816f3f..4aa354eba2 100644
--- a/build/NuSpecs/UmbracoCms.Web.nuspec
+++ b/build/NuSpecs/UmbracoCms.Web.nuspec
@@ -14,6 +14,7 @@
Contains the core assemblies needed to run Umbraco Cms
en-US
umbraco
+
@@ -43,7 +44,7 @@
-
+
@@ -58,7 +59,7 @@
-
-
+
+
diff --git a/build/NuSpecs/UmbracoCms.nuspec b/build/NuSpecs/UmbracoCms.nuspec
index 5cdacca419..b7bfaaff5b 100644
--- a/build/NuSpecs/UmbracoCms.nuspec
+++ b/build/NuSpecs/UmbracoCms.nuspec
@@ -14,6 +14,7 @@
Installs Umbraco Cms in your Visual Studio ASP.NET project
en-US
umbraco
+
@@ -25,7 +26,7 @@
not want this to happen as the alpha of the next major is, really, the next major already.
-->
-
+
diff --git a/build/NuSpecs/tools/Views.Web.config.install.xdt b/build/NuSpecs/tools/Views.Web.config.install.xdt
index 4d660301a8..828bb8612f 100644
--- a/build/NuSpecs/tools/Views.Web.config.install.xdt
+++ b/build/NuSpecs/tools/Views.Web.config.install.xdt
@@ -8,7 +8,7 @@
-
+
@@ -18,13 +18,13 @@
-
+
diff --git a/build/NuSpecs/tools/install.ps1 b/build/NuSpecs/tools/install.ps1
index 1411cb5c97..0be28f9467 100644
--- a/build/NuSpecs/tools/install.ps1
+++ b/build/NuSpecs/tools/install.ps1
@@ -18,9 +18,20 @@ if ($project) {
# Copy umbraco and umbraco_files from package to project folder
$umbracoFolder = Join-Path $projectPath "Umbraco"
- New-Item -ItemType Directory -Force -Path $umbracoFolder
+ New-Item -ItemType Directory -Force -Path $umbracoFolder
$umbracoFolderSource = Join-Path $installPath "UmbracoFiles\Umbraco"
- robocopy $umbracoFolderSource $umbracoFolder /is /it /e /xf UI.xml /LOG:$copyLogsPath\UmbracoCopy.log
+
+ Write-Host "copying files to $umbracoFolder ..."
+ # see https://support.microsoft.com/en-us/help/954404/return-codes-that-are-used-by-the-robocopy-utility-in-windows-server-2
+ robocopy $umbracoFolderSource $umbracoFolder /is /it /e
+ if (($lastexitcode -eq 1) -or ($lastexitcode -eq 3) -or ($lastexitcode -eq 5) -or ($lastexitcode -eq 7))
+ {
+ write-host "Copy succeeded!"
+ }
+ else
+ {
+ write-host "Copy failed with exit code:" $lastexitcode
+ }
$copyWebconfig = $true
$destinationWebConfig = Join-Path $projectPath "Web.config"
@@ -40,7 +51,11 @@ if ($project) {
}
}
}
- Catch { }
+ Catch
+ {
+ Write-Host "An error occurred:"
+ Write-Host $_
+ }
}
if($copyWebconfig -eq $true)
@@ -74,7 +89,9 @@ if ($project) {
}
Catch
{
- # Not a big problem if this fails, let it go
+ # Not a big problem if this fails, let it go
+ # Write-Host "An error occurred:"
+ # Write-Host $_
}
}
diff --git a/build/build.ps1 b/build/build.ps1
index 55b686c98e..e4994d2c4a 100644
--- a/build/build.ps1
+++ b/build/build.ps1
@@ -15,7 +15,7 @@
[Parameter(Mandatory=$false)]
[Alias("doc")]
[switch] $docfx = $false,
-
+
# keep the build directories, don't clear them
[Parameter(Mandatory=$false)]
[Alias("c")]
@@ -392,13 +392,13 @@
&$this.BuildEnv.NuGet Pack "$nuspecs\UmbracoCms.Core.nuspec" `
-Properties BuildTmp="$($this.BuildTemp)" `
-Version "$($this.Version.Semver.ToString())" `
- -Symbols -SymbolPackageFormat snupkg -Verbosity detailed -outputDirectory "$($this.BuildOutput)" > "$($this.BuildTemp)\nupack.cmscore.log"
+ -Verbosity detailed -outputDirectory "$($this.BuildOutput)" > "$($this.BuildTemp)\nupack.cmscore.log"
if (-not $?) { throw "Failed to pack NuGet UmbracoCms.Core." }
&$this.BuildEnv.NuGet Pack "$nuspecs\UmbracoCms.Web.nuspec" `
-Properties BuildTmp="$($this.BuildTemp)" `
-Version "$($this.Version.Semver.ToString())" `
- -Symbols -SymbolPackageFormat snupkg -Verbosity detailed -outputDirectory "$($this.BuildOutput)" > "$($this.BuildTemp)\nupack.cmsweb.log"
+ -Verbosity detailed -outputDirectory "$($this.BuildOutput)" > "$($this.BuildTemp)\nupack.cmsweb.log"
if (-not $?) { throw "Failed to pack NuGet UmbracoCms.Web." }
&$this.BuildEnv.NuGet Pack "$nuspecs\UmbracoCms.nuspec" `
@@ -429,37 +429,37 @@
Write-Host "Prepare Azure Gallery"
$this.CopyFile("$($this.SolutionRoot)\build\Azure\azuregalleryrelease.ps1", $this.BuildOutput)
})
-
+
$ubuild.DefineMethod("PrepareCSharpDocs",
{
Write-Host "Prepare C# Documentation"
-
+
$src = "$($this.SolutionRoot)\src"
$tmp = $this.BuildTemp
$out = $this.BuildOutput
$DocFxJson = Join-Path -Path $src "\ApiDocs\docfx.json"
$DocFxSiteOutput = Join-Path -Path $tmp "\_site\*.*"
-
+
#restore nuget packages
$this.RestoreNuGet()
# run DocFx
$DocFx = $this.BuildEnv.DocFx
-
+
& $DocFx metadata $DocFxJson
& $DocFx build $DocFxJson
# zip it
& $this.BuildEnv.Zip a -tzip -r "$out\csharp-docs.zip" $DocFxSiteOutput
})
-
+
$ubuild.DefineMethod("PrepareAngularDocs",
{
Write-Host "Prepare Angular Documentation"
-
+
$src = "$($this.SolutionRoot)\src"
$out = $this.BuildOutput
-
+
$this.CompileBelle()
"Moving to Umbraco.Web.UI.Client folder"
diff --git a/src/Umbraco.Abstractions/EnumerableExtensions.cs b/src/Umbraco.Abstractions/EnumerableExtensions.cs
index cee8199a6c..a055cdb08e 100644
--- a/src/Umbraco.Abstractions/EnumerableExtensions.cs
+++ b/src/Umbraco.Abstractions/EnumerableExtensions.cs
@@ -9,44 +9,7 @@ namespace Umbraco.Core
///
public static class EnumerableExtensions
{
- // based upon the original Zip method
- public static IEnumerable Zip(this IEnumerable e1, IEnumerable e2, IEnumerable e3,
- Func resultSelector)
- {
- if (e1 == null) throw new ArgumentNullException("e1");
- if (e2 == null) throw new ArgumentNullException("e2");
- if (e3 == null) throw new ArgumentNullException("e3");
- if (resultSelector == null) throw new ArgumentNullException("resultSelector");
- return ZipIterator(e1, e2, e3, resultSelector);
- }
-
- private static IEnumerable ZipIterator(IEnumerable ie1, IEnumerable ie2, IEnumerable ie3,
- Func resultSelector)
- {
- var e1 = ie1.GetEnumerator();
- try
- {
- var e2 = ie2.GetEnumerator();
- var e3 = ie3.GetEnumerator();
- try
- {
- while (e1.MoveNext() && e2.MoveNext() && e3.MoveNext())
- yield return resultSelector(e1.Current, e2.Current, e3.Current);
- }
- finally
- {
- if (e2 != null)
- e2.Dispose();
- if (e3 != null)
- e3.Dispose();
- }
- }
- finally
- {
- if (e1 != null)
- e1.Dispose();
- }
- }
+ public static bool IsCollectionEmpty(this IReadOnlyCollection list) => list == null || list.Count == 0;
internal static bool HasDuplicates(this IEnumerable items, bool includeNull)
{
diff --git a/src/Umbraco.Abstractions/Models/Entities/EntityBase.cs b/src/Umbraco.Abstractions/Models/Entities/EntityBase.cs
index 967bf9adfc..3d312eea4f 100644
--- a/src/Umbraco.Abstractions/Models/Entities/EntityBase.cs
+++ b/src/Umbraco.Abstractions/Models/Entities/EntityBase.cs
@@ -85,7 +85,7 @@ namespace Umbraco.Core.Models.Entities
///
/// Updates the entity when it is being saved for the first time.
///
- public virtual void AddingEntity()
+ internal virtual void AddingEntity()
{
var now = DateTime.Now;
@@ -99,7 +99,7 @@ namespace Umbraco.Core.Models.Entities
///
/// Updates the entity when it is being saved.
///
- public virtual void UpdatingEntity()
+ internal virtual void UpdatingEntity()
{
var now = DateTime.Now;
diff --git a/src/Umbraco.Abstractions/Models/PublishedContent/PublishedCultureInfos.cs b/src/Umbraco.Abstractions/Models/PublishedContent/PublishedCultureInfos.cs
index 749b37a41a..47c81ab9a1 100644
--- a/src/Umbraco.Abstractions/Models/PublishedContent/PublishedCultureInfos.cs
+++ b/src/Umbraco.Abstractions/Models/PublishedContent/PublishedCultureInfos.cs
@@ -13,10 +13,9 @@ namespace Umbraco.Core.Models.PublishedContent
///
public PublishedCultureInfo(string culture, string name, string urlSegment, DateTime date)
{
- if (string.IsNullOrWhiteSpace(culture)) throw new ArgumentNullOrEmptyException(nameof(culture));
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullOrEmptyException(nameof(name));
- Culture = culture;
+ Culture = culture ?? throw new ArgumentNullException(nameof(culture));
Name = name;
UrlSegment = urlSegment;
Date = date;
diff --git a/src/Umbraco.Abstractions/Services/Changes/ContentTypeChangeTypes.cs b/src/Umbraco.Abstractions/Services/Changes/ContentTypeChangeTypes.cs
index 497f7d47a9..bf7f87fd1a 100644
--- a/src/Umbraco.Abstractions/Services/Changes/ContentTypeChangeTypes.cs
+++ b/src/Umbraco.Abstractions/Services/Changes/ContentTypeChangeTypes.cs
@@ -6,9 +6,25 @@ namespace Umbraco.Core.Services.Changes
public enum ContentTypeChangeTypes : byte
{
None = 0,
- Create = 1, // item type has been created, no impact
- RefreshMain = 2, // changed, impacts content (adding property or composition does NOT)
- RefreshOther = 4, // changed, other changes
- Remove = 8 // item type has been removed
+
+ ///
+ /// Item type has been created, no impact
+ ///
+ Create = 1,
+
+ ///
+ /// Content type changes impact only the Content type being saved
+ ///
+ RefreshMain = 2,
+
+ ///
+ /// Content type changes impacts the content type being saved and others used that are composed of it
+ ///
+ RefreshOther = 4, // changed, other change
+
+ ///
+ /// Content type was removed
+ ///
+ Remove = 8
}
}
diff --git a/src/Umbraco.Core/Composing/TypeLoader.cs b/src/Umbraco.Core/Composing/TypeLoader.cs
index af9277fce9..fe7a561eca 100644
--- a/src/Umbraco.Core/Composing/TypeLoader.cs
+++ b/src/Umbraco.Core/Composing/TypeLoader.cs
@@ -42,8 +42,8 @@ namespace Umbraco.Core.Composing
private string _currentAssembliesHash;
private IEnumerable _assemblies;
private bool _reportedChange;
- private static string _localTempPath;
- private static string _fileBasePath;
+ private readonly string _localTempPath;
+ private string _fileBasePath;
///
/// Initializes a new instance of the class.
diff --git a/src/Umbraco.Core/CompositionExtensions.cs b/src/Umbraco.Core/CompositionExtensions.cs
index 828a577c34..5dd33c2a60 100644
--- a/src/Umbraco.Core/CompositionExtensions.cs
+++ b/src/Umbraco.Core/CompositionExtensions.cs
@@ -4,6 +4,7 @@ using Umbraco.Core.Composing;
using Umbraco.Core.Dictionary;
using Umbraco.Core.IO;
using Umbraco.Core.Logging.Viewer;
+using Umbraco.Core.Manifest;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Core.PackageActions;
using Umbraco.Core.Persistence.Mappers;
@@ -66,9 +67,16 @@ namespace Umbraco.Core
/// Gets the validators collection builder.
///
/// The composition.
- internal static ManifestValueValidatorCollectionBuilder Validators(this Composition composition)
+ internal static ManifestValueValidatorCollectionBuilder ManifestValueValidators(this Composition composition)
=> composition.WithCollectionBuilder();
+ ///
+ /// Gets the manifest filter collection builder.
+ ///
+ /// The composition.
+ public static ManifestFilterCollectionBuilder ManifestFilters(this Composition composition)
+ => composition.WithCollectionBuilder();
+
///
/// Gets the components collection builder.
///
diff --git a/src/Umbraco.Core/ConfigsExtensions.cs b/src/Umbraco.Core/ConfigsExtensions.cs
index 6fdf7ea3b9..d1672c6c7f 100644
--- a/src/Umbraco.Core/ConfigsExtensions.cs
+++ b/src/Umbraco.Core/ConfigsExtensions.cs
@@ -7,6 +7,7 @@ using Umbraco.Core.Configuration.HealthChecks;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
+using Umbraco.Core.Manifest;
namespace Umbraco.Core
{
@@ -41,7 +42,12 @@ namespace Umbraco.Core
configs.Add(() => new CoreDebug());
// GridConfig depends on runtime caches, manifest parsers... and cannot be available during composition
- configs.Add(factory => new GridConfig(factory.GetInstance(), factory.GetInstance(), configDir, factory.GetInstance().Debug));
+ configs.Add(factory => new GridConfig(
+ factory.GetInstance(),
+ factory.GetInstance(),
+ configDir,
+ factory.GetInstance(),
+ factory.GetInstance().Debug));
}
}
}
diff --git a/src/Umbraco.Core/Configuration/Grid/GridConfig.cs b/src/Umbraco.Core/Configuration/Grid/GridConfig.cs
index b2dae09fc9..9aead74886 100644
--- a/src/Umbraco.Core/Configuration/Grid/GridConfig.cs
+++ b/src/Umbraco.Core/Configuration/Grid/GridConfig.cs
@@ -1,14 +1,15 @@
using System.IO;
using Umbraco.Core.Cache;
using Umbraco.Core.Logging;
+using Umbraco.Core.Manifest;
namespace Umbraco.Core.Configuration.Grid
{
class GridConfig : IGridConfig
{
- public GridConfig(ILogger logger, AppCaches appCaches, DirectoryInfo configFolder, bool isDebug)
+ public GridConfig(ILogger logger, AppCaches appCaches, DirectoryInfo configFolder, ManifestParser manifestParser, bool isDebug)
{
- EditorsConfig = new GridEditorsConfig(logger, appCaches, configFolder, isDebug);
+ EditorsConfig = new GridEditorsConfig(logger, appCaches, configFolder, manifestParser, isDebug);
}
public IGridEditorsConfig EditorsConfig { get; }
diff --git a/src/Umbraco.Core/Configuration/Grid/GridEditorsConfig.cs b/src/Umbraco.Core/Configuration/Grid/GridEditorsConfig.cs
index 0e7ef62c58..d434da8c70 100644
--- a/src/Umbraco.Core/Configuration/Grid/GridEditorsConfig.cs
+++ b/src/Umbraco.Core/Configuration/Grid/GridEditorsConfig.cs
@@ -1,9 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
-using Newtonsoft.Json.Linq;
using Umbraco.Core.Cache;
-using Umbraco.Core.Composing;
using Umbraco.Core.Logging;
using Umbraco.Core.Manifest;
using Umbraco.Core.PropertyEditors;
@@ -15,13 +13,15 @@ namespace Umbraco.Core.Configuration.Grid
private readonly ILogger _logger;
private readonly AppCaches _appCaches;
private readonly DirectoryInfo _configFolder;
+ private readonly ManifestParser _manifestParser;
private readonly bool _isDebug;
- public GridEditorsConfig(ILogger logger, AppCaches appCaches, DirectoryInfo configFolder, bool isDebug)
+ public GridEditorsConfig(ILogger logger, AppCaches appCaches, DirectoryInfo configFolder, ManifestParser manifestParser, bool isDebug)
{
_logger = logger;
_appCaches = appCaches;
_configFolder = configFolder;
+ _manifestParser = manifestParser;
_isDebug = isDebug;
}
@@ -31,9 +31,6 @@ namespace Umbraco.Core.Configuration.Grid
{
List GetResult()
{
- // TODO: should use the common one somehow! + ignoring _appPlugins here!
- var parser = new ManifestParser(_appCaches, Current.ManifestValidators, _logger);
-
var editors = new List();
var gridConfig = Path.Combine(_configFolder.FullName, "grid.editors.config.js");
if (File.Exists(gridConfig))
@@ -42,7 +39,7 @@ namespace Umbraco.Core.Configuration.Grid
try
{
- editors.AddRange(parser.ParseGridEditors(sourceString));
+ editors.AddRange(_manifestParser.ParseGridEditors(sourceString));
}
catch (Exception ex)
{
@@ -51,7 +48,7 @@ namespace Umbraco.Core.Configuration.Grid
}
// add manifest editors, skip duplicates
- foreach (var gridEditor in parser.Manifest.GridEditors)
+ foreach (var gridEditor in _manifestParser.Manifest.GridEditors)
{
if (editors.Contains(gridEditor) == false) editors.Add(gridEditor);
}
diff --git a/src/Umbraco.Core/Constants-DataTypes.cs b/src/Umbraco.Core/Constants-DataTypes.cs
index f2b31be28f..673da8f9a3 100644
--- a/src/Umbraco.Core/Constants-DataTypes.cs
+++ b/src/Umbraco.Core/Constants-DataTypes.cs
@@ -1,27 +1,375 @@
-namespace Umbraco.Core
+using System;
+
+namespace Umbraco.Core
{
public static partial class Constants
{
public static class DataTypes
{
- public const int LabelString = -92;
+ //NOTE: unfortunately due to backwards compat we can't move/rename these, with the addition of the GUID
+ //constants, it would make more sense to have these suffixed with "ID" or in a Subclass called "INT", for
+ //now all we can do is make a subclass called Guids to put the GUID IDs.
+
+ public const int LabelString = System.DefaultLabelDataTypeId;
public const int LabelInt = -91;
public const int LabelBigint = -93;
public const int LabelDateTime = -94;
public const int LabelTime = -98;
public const int LabelDecimal = -99;
+ public const int Textarea = -89;
public const int Textbox = -88;
+ public const int RichtextEditor = -87;
public const int Boolean = -49;
public const int DateTime = -36;
public const int DropDownSingle = -39;
public const int DropDownMultiple = -42;
+ public const int Upload = -90;
public const int DefaultContentListView = -95;
public const int DefaultMediaListView = -96;
public const int DefaultMembersListView = -97;
+ public const int ImageCropper = 1043;
public const int Tags = 1041;
+
+ public static class ReservedPreValueKeys
+ {
+ public const string IgnoreUserStartNodes = "ignoreUserStartNodes";
+ }
+
+ ///
+ /// Defines the identifiers for Umbraco data types as constants for easy centralized access/management.
+ ///
+ public static class Guids
+ {
+
+ ///
+ /// Guid for Content Picker as string
+ ///
+ public const string ContentPicker = "FD1E0DA5-5606-4862-B679-5D0CF3A52A59";
+
+ ///
+ /// Guid for Content Picker
+ ///
+ public static readonly Guid ContentPickerGuid = new Guid(ContentPicker);
+
+
+ ///
+ /// Guid for Member Picker as string
+ ///
+ public const string MemberPicker = "1EA2E01F-EBD8-4CE1-8D71-6B1149E63548";
+
+ ///
+ /// Guid for Member Picker
+ ///
+ public static readonly Guid MemberPickerGuid = new Guid(MemberPicker);
+
+
+ ///
+ /// Guid for Media Picker as string
+ ///
+ public const string MediaPicker = "135D60E0-64D9-49ED-AB08-893C9BA44AE5";
+
+ ///
+ /// Guid for Media Picker
+ ///
+ public static readonly Guid MediaPickerGuid = new Guid(MediaPicker);
+
+
+ ///
+ /// Guid for Multiple Media Picker as string
+ ///
+ public const string MultipleMediaPicker = "9DBBCBBB-2327-434A-B355-AF1B84E5010A";
+
+ ///
+ /// Guid for Multiple Media Picker
+ ///
+ public static readonly Guid MultipleMediaPickerGuid = new Guid(MultipleMediaPicker);
+
+
+ ///
+ /// Guid for Related Links as string
+ ///
+ public const string RelatedLinks = "B4E3535A-1753-47E2-8568-602CF8CFEE6F";
+
+ ///
+ /// Guid for Related Links
+ ///
+ public static readonly Guid RelatedLinksGuid = new Guid(RelatedLinks);
+
+
+ ///
+ /// Guid for Member as string
+ ///
+ public const string Member = "d59be02f-1df9-4228-aa1e-01917d806cda";
+
+ ///
+ /// Guid for Member
+ ///
+ public static readonly Guid MemberGuid = new Guid(Member);
+
+
+ ///
+ /// Guid for Image Cropper as string
+ ///
+ public const string ImageCropper = "1df9f033-e6d4-451f-b8d2-e0cbc50a836f";
+
+ ///
+ /// Guid for Image Cropper
+ ///
+ public static readonly Guid ImageCropperGuid = new Guid(ImageCropper);
+
+
+ ///
+ /// Guid for Tags as string
+ ///
+ public const string Tags = "b6b73142-b9c1-4bf8-a16d-e1c23320b549";
+
+ ///
+ /// Guid for Tags
+ ///
+ public static readonly Guid TagsGuid = new Guid(Tags);
+
+
+ ///
+ /// Guid for List View - Content as string
+ ///
+ public const string ListViewContent = "C0808DD3-8133-4E4B-8CE8-E2BEA84A96A4";
+
+ ///
+ /// Guid for List View - Content
+ ///
+ public static readonly Guid ListViewContentGuid = new Guid(ListViewContent);
+
+
+ ///
+ /// Guid for List View - Media as string
+ ///
+ public const string ListViewMedia = "3A0156C4-3B8C-4803-BDC1-6871FAA83FFF";
+
+ ///
+ /// Guid for List View - Media
+ ///
+ public static readonly Guid ListViewMediaGuid = new Guid(ListViewMedia);
+
+
+ ///
+ /// Guid for List View - Members as string
+ ///
+ public const string ListViewMembers = "AA2C52A0-CE87-4E65-A47C-7DF09358585D";
+
+ ///
+ /// Guid for List View - Members
+ ///
+ public static readonly Guid ListViewMembersGuid = new Guid(ListViewMembers);
+
+
+ ///
+ /// Guid for Date Picker with time as string
+ ///
+ public const string DatePickerWithTime = "e4d66c0f-b935-4200-81f0-025f7256b89a";
+
+ ///
+ /// Guid for Date Picker with time
+ ///
+ public static readonly Guid DatePickerWithTimeGuid = new Guid(DatePickerWithTime);
+
+
+ ///
+ /// Guid for Approved Color as string
+ ///
+ public const string ApprovedColor = "0225af17-b302-49cb-9176-b9f35cab9c17";
+
+ ///
+ /// Guid for Approved Color
+ ///
+ public static readonly Guid ApprovedColorGuid = new Guid(ApprovedColor);
+
+
+ ///
+ /// Guid for Dropdown multiple as string
+ ///
+ public const string DropdownMultiple = "f38f0ac7-1d27-439c-9f3f-089cd8825a53";
+
+ ///
+ /// Guid for Dropdown multiple
+ ///
+ public static readonly Guid DropdownMultipleGuid = new Guid(DropdownMultiple);
+
+
+ ///
+ /// Guid for Radiobox as string
+ ///
+ public const string Radiobox = "bb5f57c9-ce2b-4bb9-b697-4caca783a805";
+
+ ///
+ /// Guid for Radiobox
+ ///
+ public static readonly Guid RadioboxGuid = new Guid(Radiobox);
+
+
+ ///
+ /// Guid for Date Picker as string
+ ///
+ public const string DatePicker = "5046194e-4237-453c-a547-15db3a07c4e1";
+
+ ///
+ /// Guid for Date Picker
+ ///
+ public static readonly Guid DatePickerGuid = new Guid(DatePicker);
+
+
+ ///
+ /// Guid for Dropdown as string
+ ///
+ public const string Dropdown = "0b6a45e7-44ba-430d-9da5-4e46060b9e03";
+
+ ///
+ /// Guid for Dropdown
+ ///
+ public static readonly Guid DropdownGuid = new Guid(Dropdown);
+
+
+ ///
+ /// Guid for Checkbox list as string
+ ///
+ public const string CheckboxList = "fbaf13a8-4036-41f2-93a3-974f678c312a";
+
+ ///
+ /// Guid for Checkbox list
+ ///
+ public static readonly Guid CheckboxListGuid = new Guid(CheckboxList);
+
+
+ ///
+ /// Guid for Checkbox as string
+ ///
+ public const string Checkbox = "92897bc6-a5f3-4ffe-ae27-f2e7e33dda49";
+
+ ///
+ /// Guid for Checkbox
+ ///
+ public static readonly Guid CheckboxGuid = new Guid(Checkbox);
+
+
+ ///
+ /// Guid for Numeric as string
+ ///
+ public const string Numeric = "2e6d3631-066e-44b8-aec4-96f09099b2b5";
+
+ ///
+ /// Guid for Dropdown
+ ///
+ public static readonly Guid NumericGuid = new Guid(Numeric);
+
+
+ ///
+ /// Guid for Richtext editor as string
+ ///
+ public const string RichtextEditor = "ca90c950-0aff-4e72-b976-a30b1ac57dad";
+
+ ///
+ /// Guid for Richtext editor
+ ///
+ public static readonly Guid RichtextEditorGuid = new Guid(RichtextEditor);
+
+
+ ///
+ /// Guid for Textstring as string
+ ///
+ public const string Textstring = "0cc0eba1-9960-42c9-bf9b-60e150b429ae";
+
+ ///
+ /// Guid for Textstring
+ ///
+ public static readonly Guid TextstringGuid = new Guid(Textstring);
+
+
+ ///
+ /// Guid for Textarea as string
+ ///
+ public const string Textarea = "c6bac0dd-4ab9-45b1-8e30-e4b619ee5da3";
+
+ ///
+ /// Guid for Dropdown
+ ///
+ public static readonly Guid TextareaGuid = new Guid(Textarea);
+
+
+ ///
+ /// Guid for Upload as string
+ ///
+ public const string Upload = "84c6b441-31df-4ffe-b67e-67d5bc3ae65a";
+
+ ///
+ /// Guid for Upload
+ ///
+ public static readonly Guid UploadGuid = new Guid(Upload);
+
+
+ ///
+ /// Guid for Label as string
+ ///
+ public const string LabelString = "f0bc4bfb-b499-40d6-ba86-058885a5178c";
+
+ ///
+ /// Guid for Label string
+ ///
+ public static readonly Guid LabelStringGuid = new Guid(LabelString);
+
+ ///
+ /// Guid for Label as int
+ ///
+ public const string LabelInt = "8e7f995c-bd81-4627-9932-c40e568ec788";
+
+ ///
+ /// Guid for Label int
+ ///
+ public static readonly Guid LabelIntGuid = new Guid(LabelInt);
+
+ ///
+ /// Guid for Label as big int
+ ///
+ public const string LabelBigInt = "930861bf-e262-4ead-a704-f99453565708";
+
+ ///
+ /// Guid for Label big int
+ ///
+ public static readonly Guid LabelBigIntGuid = new Guid(LabelBigInt);
+
+ ///
+ /// Guid for Label as date time
+ ///
+ public const string LabelDateTime = "0e9794eb-f9b5-4f20-a788-93acd233a7e4";
+
+ ///
+ /// Guid for Label date time
+ ///
+ public static readonly Guid LabelDateTimeGuid = new Guid(LabelDateTime);
+
+ ///
+ /// Guid for Label as time
+ ///
+ public const string LabelTime = "a97cec69-9b71-4c30-8b12-ec398860d7e8";
+
+ ///
+ /// Guid for Label time
+ ///
+ public static readonly Guid LabelTimeGuid = new Guid(LabelTime);
+
+ ///
+ /// Guid for Label as decimal
+ ///
+ public const string LabelDecimal = "8f1ef1e1-9de4-40d3-a072-6673f631ca64";
+
+ ///
+ /// Guid for Label decimal
+ ///
+ public static readonly Guid LabelDecimalGuid = new Guid(LabelDecimal);
+
+
+ }
}
}
}
diff --git a/src/Umbraco.Core/Constants-Icons.cs b/src/Umbraco.Core/Constants-Icons.cs
index d3e8b4ad3b..05213ed1c4 100644
--- a/src/Umbraco.Core/Constants-Icons.cs
+++ b/src/Umbraco.Core/Constants-Icons.cs
@@ -5,39 +5,89 @@
public static class Icons
{
///
- /// System contenttype icon
+ /// System default icon
///
- public const string ContentType = "icon-arrangement";
+ public const string DefaultIcon = Content;
///
- /// System datatype icon
+ /// System content icon
+ ///
+ public const string Content = "icon-document";
+
+ ///
+ /// System content type icon
+ ///
+ public const string ContentType = "icon-item-arrangement";
+
+ ///
+ /// System data type icon
///
public const string DataType = "icon-autofill";
///
- /// System property editor icon
+ /// System list view icon
///
- public const string PropertyEditor = "icon-autofill";
+ public const string ListView = "icon-thumbnail-list";
///
/// System macro icon
///
public const string Macro = "icon-settings-alt";
+ ///
+ /// System media file icon
+ ///
+ public const string MediaFile = "icon-document";
+
+ ///
+ /// System media folder icon
+ ///
+ public const string MediaFolder = "icon-folder";
+
+ ///
+ /// System media image icon
+ ///
+ public const string MediaImage = "icon-picture";
+
+ ///
+ /// System media type icon
+ ///
+ public const string MediaType = "icon-thumbnails";
+
///
/// System member icon
///
public const string Member = "icon-user";
///
- /// System member icon
+ /// System member group icon
+ ///
+ public const string MemberGroup = "icon-users-alt";
+
+ ///
+ /// System member type icon
///
public const string MemberType = "icon-users";
+ ///
+ /// System property editor icon
+ ///
+ public const string PropertyEditor = "icon-autofill";
+
///
/// System member icon
///
public const string Template = "icon-layout";
+
+ ///
+ /// System user icon
+ ///
+ public const string User = "icon-user";
+
+ ///
+ /// System user group icon
+ ///
+ public const string UserGroup = "icon-users";
}
}
}
diff --git a/src/Umbraco.Core/ContentVariationExtensions.cs b/src/Umbraco.Core/ContentVariationExtensions.cs
index d25997b5f0..9fdc5f0b90 100644
--- a/src/Umbraco.Core/ContentVariationExtensions.cs
+++ b/src/Umbraco.Core/ContentVariationExtensions.cs
@@ -66,44 +66,44 @@ namespace Umbraco.Core
///
/// Determines whether the content type is invariant.
///
- public static bool VariesByNothing(this PublishedContentType contentType) => contentType.Variations.VariesByNothing();
+ public static bool VariesByNothing(this IPublishedContentType contentType) => contentType.Variations.VariesByNothing();
///
/// Determines whether the content type varies by culture.
///
/// And then it could also vary by segment.
- public static bool VariesByCulture(this PublishedContentType contentType) => contentType.Variations.VariesByCulture();
+ public static bool VariesByCulture(this IPublishedContentType contentType) => contentType.Variations.VariesByCulture();
///
/// Determines whether the content type varies by segment.
///
/// And then it could also vary by culture.
- public static bool VariesBySegment(this PublishedContentType contentType) => contentType.Variations.VariesBySegment();
+ public static bool VariesBySegment(this IPublishedContentType contentType) => contentType.Variations.VariesBySegment();
///
/// Determines whether the content type varies by culture and segment.
///
- public static bool VariesByCultureAndSegment(this PublishedContentType contentType) => contentType.Variations.VariesByCultureAndSegment();
+ public static bool VariesByCultureAndSegment(this IPublishedContentType contentType) => contentType.Variations.VariesByCultureAndSegment();
///
/// Determines whether the property type is invariant.
///
- public static bool VariesByNothing(this PublishedPropertyType propertyType) => propertyType.Variations.VariesByNothing();
+ public static bool VariesByNothing(this IPublishedPropertyType propertyType) => propertyType.Variations.VariesByNothing();
///
/// Determines whether the property type varies by culture.
///
- public static bool VariesByCulture(this PublishedPropertyType propertyType) => propertyType.Variations.VariesByCulture();
+ public static bool VariesByCulture(this IPublishedPropertyType propertyType) => propertyType.Variations.VariesByCulture();
///
/// Determines whether the property type varies by segment.
///
- public static bool VariesBySegment(this PublishedPropertyType propertyType) => propertyType.Variations.VariesBySegment();
+ public static bool VariesBySegment(this IPublishedPropertyType propertyType) => propertyType.Variations.VariesBySegment();
///
/// Determines whether the property type varies by culture and segment.
///
- public static bool VariesByCultureAndSegment(this PublishedPropertyType propertyType) => propertyType.Variations.VariesByCultureAndSegment();
+ public static bool VariesByCultureAndSegment(this IPublishedPropertyType propertyType) => propertyType.Variations.VariesByCultureAndSegment();
///
/// Determines whether a variation is invariant.
diff --git a/src/Umbraco.Core/Manifest/IManifestFilter.cs b/src/Umbraco.Core/Manifest/IManifestFilter.cs
new file mode 100644
index 0000000000..505f13d385
--- /dev/null
+++ b/src/Umbraco.Core/Manifest/IManifestFilter.cs
@@ -0,0 +1,19 @@
+using System.Collections.Generic;
+
+namespace Umbraco.Core.Manifest
+{
+ ///
+ /// Provides filtering for package manifests.
+ ///
+ public interface IManifestFilter
+ {
+ ///
+ /// Filters package manifests.
+ ///
+ /// The package manifests.
+ ///
+ /// It is possible to remove, change, or add manifests.
+ ///
+ void Filter(List manifests);
+ }
+}
diff --git a/src/Umbraco.Core/Manifest/ManifestFilterCollection.cs b/src/Umbraco.Core/Manifest/ManifestFilterCollection.cs
new file mode 100644
index 0000000000..febdb7e356
--- /dev/null
+++ b/src/Umbraco.Core/Manifest/ManifestFilterCollection.cs
@@ -0,0 +1,28 @@
+using System.Collections.Generic;
+using Umbraco.Core.Composing;
+
+namespace Umbraco.Core.Manifest
+{
+ ///
+ /// Contains the manifest filters.
+ ///
+ public class ManifestFilterCollection : BuilderCollectionBase
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public ManifestFilterCollection(IEnumerable items)
+ : base(items)
+ { }
+
+ ///
+ /// Filters package manifests.
+ ///
+ /// The package manifests.
+ public void Filter(List manifests)
+ {
+ foreach (var filter in this)
+ filter.Filter(manifests);
+ }
+ }
+}
diff --git a/src/Umbraco.Core/Manifest/ManifestFilterCollectionBuilder.cs b/src/Umbraco.Core/Manifest/ManifestFilterCollectionBuilder.cs
new file mode 100644
index 0000000000..4d98700f93
--- /dev/null
+++ b/src/Umbraco.Core/Manifest/ManifestFilterCollectionBuilder.cs
@@ -0,0 +1,12 @@
+using Umbraco.Core.Composing;
+
+namespace Umbraco.Core.Manifest
+{
+ public class ManifestFilterCollectionBuilder : OrderedCollectionBuilderBase
+ {
+ protected override ManifestFilterCollectionBuilder This => this;
+
+ // do NOT cache this, it's only used once
+ protected override Lifetime CollectionLifetime => Lifetime.Transient;
+ }
+}
\ No newline at end of file
diff --git a/src/Umbraco.Core/Manifest/ManifestParser.cs b/src/Umbraco.Core/Manifest/ManifestParser.cs
index dc40cd90a2..efd9e92b1f 100644
--- a/src/Umbraco.Core/Manifest/ManifestParser.cs
+++ b/src/Umbraco.Core/Manifest/ManifestParser.cs
@@ -22,24 +22,26 @@ namespace Umbraco.Core.Manifest
private readonly IAppPolicyCache _cache;
private readonly ILogger _logger;
private readonly ManifestValueValidatorCollection _validators;
+ private readonly ManifestFilterCollection _filters;
private string _path;
///
/// Initializes a new instance of the class.
///
- public ManifestParser(AppCaches appCaches, ManifestValueValidatorCollection validators, ILogger logger)
- : this(appCaches, validators, "~/App_Plugins", logger)
+ public ManifestParser(AppCaches appCaches, ManifestValueValidatorCollection validators, ManifestFilterCollection filters, ILogger logger)
+ : this(appCaches, validators, filters, "~/App_Plugins", logger)
{ }
///
/// Initializes a new instance of the class.
///
- private ManifestParser(AppCaches appCaches, ManifestValueValidatorCollection validators, string path, ILogger logger)
+ private ManifestParser(AppCaches appCaches, ManifestValueValidatorCollection validators, ManifestFilterCollection filters, string path, ILogger logger)
{
if (appCaches == null) throw new ArgumentNullException(nameof(appCaches));
_cache = appCaches.RuntimeCache;
_validators = validators ?? throw new ArgumentNullException(nameof(validators));
+ _filters = filters ?? throw new ArgumentNullException(nameof(filters));
if (string.IsNullOrWhiteSpace(path)) throw new ArgumentNullOrEmptyException(nameof(path));
Path = path;
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
@@ -78,6 +80,7 @@ namespace Umbraco.Core.Manifest
if (string.IsNullOrWhiteSpace(text))
continue;
var manifest = ParseManifest(text);
+ manifest.Source = path;
manifests.Add(manifest);
}
catch (Exception e)
@@ -86,6 +89,8 @@ namespace Umbraco.Core.Manifest
}
}
+ _filters.Filter(manifests);
+
return manifests;
}
diff --git a/src/Umbraco.Core/Manifest/PackageManifest.cs b/src/Umbraco.Core/Manifest/PackageManifest.cs
index 475ee8a7f8..e50eb69467 100644
--- a/src/Umbraco.Core/Manifest/PackageManifest.cs
+++ b/src/Umbraco.Core/Manifest/PackageManifest.cs
@@ -9,6 +9,16 @@ namespace Umbraco.Core.Manifest
///
public class PackageManifest
{
+ ///
+ /// Gets the source path of the manifest.
+ ///
+ ///
+ /// Gets the full absolute file path of the manifest,
+ /// using system directory separators.
+ ///
+ [JsonIgnore]
+ public string Source { get; set; }
+
///
/// Gets or sets the scripts listed in the manifest.
///
diff --git a/src/Umbraco.Core/Mapping/UmbracoMapper.cs b/src/Umbraco.Core/Mapping/UmbracoMapper.cs
index 2d495b38b5..8915ebcf74 100644
--- a/src/Umbraco.Core/Mapping/UmbracoMapper.cs
+++ b/src/Umbraco.Core/Mapping/UmbracoMapper.cs
@@ -191,7 +191,7 @@ namespace Umbraco.Core.Mapping
private TTarget Map(object source, Type sourceType, MapperContext context)
{
if (source == null)
- throw new ArgumentNullException(nameof(source));
+ return default;
var targetType = typeof(TTarget);
diff --git a/src/Umbraco.Core/Migrations/Install/DatabaseDataCreator.cs b/src/Umbraco.Core/Migrations/Install/DatabaseDataCreator.cs
index 1de983636b..dd5c17713a 100644
--- a/src/Umbraco.Core/Migrations/Install/DatabaseDataCreator.cs
+++ b/src/Umbraco.Core/Migrations/Install/DatabaseDataCreator.cs
@@ -101,33 +101,33 @@ namespace Umbraco.Core.Migrations.Install
_database.Insert(Constants.DatabaseSchema.Tables.Node, "id", false, new NodeDto { NodeId = -1, Trashed = false, ParentId = -1, UserId = -1, Level = 0, Path = "-1", SortOrder = 0, UniqueId = new Guid("916724a5-173d-4619-b97e-b9de133dd6f5"), Text = "SYSTEM DATA: umbraco master root", NodeObjectType = Constants.ObjectTypes.SystemRoot, CreateDate = DateTime.Now });
_database.Insert(Constants.DatabaseSchema.Tables.Node, "id", false, new NodeDto { NodeId = -20, Trashed = false, ParentId = -1, UserId = -1, Level = 0, Path = "-1,-20", SortOrder = 0, UniqueId = new Guid("0F582A79-1E41-4CF0-BFA0-76340651891A"), Text = "Recycle Bin", NodeObjectType = Constants.ObjectTypes.ContentRecycleBin, CreateDate = DateTime.Now });
_database.Insert(Constants.DatabaseSchema.Tables.Node, "id", false, new NodeDto { NodeId = -21, Trashed = false, ParentId = -1, UserId = -1, Level = 0, Path = "-1,-21", SortOrder = 0, UniqueId = new Guid("BF7C7CBC-952F-4518-97A2-69E9C7B33842"), Text = "Recycle Bin", NodeObjectType = Constants.ObjectTypes.MediaRecycleBin, CreateDate = DateTime.Now });
- InsertDataTypeNodeDto(Constants.DataTypes.LabelString, 35, "f0bc4bfb-b499-40d6-ba86-058885a5178c", "Label");
- InsertDataTypeNodeDto(Constants.DataTypes.LabelInt, 36, "8e7f995c-bd81-4627-9932-c40e568ec788", "Label (integer)");
- InsertDataTypeNodeDto(Constants.DataTypes.LabelBigint, 36, "930861bf-e262-4ead-a704-f99453565708", "Label (bigint)");
- InsertDataTypeNodeDto(Constants.DataTypes.LabelDateTime, 37, "0e9794eb-f9b5-4f20-a788-93acd233a7e4", "Label (datetime)");
- InsertDataTypeNodeDto(Constants.DataTypes.LabelTime, 38, "a97cec69-9b71-4c30-8b12-ec398860d7e8", "Label (time)");
- InsertDataTypeNodeDto(Constants.DataTypes.LabelDecimal, 39, "8f1ef1e1-9de4-40d3-a072-6673f631ca64", "Label (decimal)");
- _database.Insert(Constants.DatabaseSchema.Tables.Node, "id", false, new NodeDto { NodeId = -90, Trashed = false, ParentId = -1, UserId = -1, Level = 1, Path = "-1,-90", SortOrder = 34, UniqueId = new Guid("84c6b441-31df-4ffe-b67e-67d5bc3ae65a"), Text = "Upload", NodeObjectType = Constants.ObjectTypes.DataType, CreateDate = DateTime.Now });
- _database.Insert(Constants.DatabaseSchema.Tables.Node, "id", false, new NodeDto { NodeId = -89, Trashed = false, ParentId = -1, UserId = -1, Level = 1, Path = "-1,-89", SortOrder = 33, UniqueId = new Guid("c6bac0dd-4ab9-45b1-8e30-e4b619ee5da3"), Text = "Textarea", NodeObjectType = Constants.ObjectTypes.DataType, CreateDate = DateTime.Now });
- _database.Insert(Constants.DatabaseSchema.Tables.Node, "id", false, new NodeDto { NodeId = -88, Trashed = false, ParentId = -1, UserId = -1, Level = 1, Path = "-1,-88", SortOrder = 32, UniqueId = new Guid("0cc0eba1-9960-42c9-bf9b-60e150b429ae"), Text = "Textstring", NodeObjectType = Constants.ObjectTypes.DataType, CreateDate = DateTime.Now });
- _database.Insert(Constants.DatabaseSchema.Tables.Node, "id", false, new NodeDto { NodeId = -87, Trashed = false, ParentId = -1, UserId = -1, Level = 1, Path = "-1,-87", SortOrder = 4, UniqueId = new Guid("ca90c950-0aff-4e72-b976-a30b1ac57dad"), Text = "Richtext editor", NodeObjectType = Constants.ObjectTypes.DataType, CreateDate = DateTime.Now });
- _database.Insert(Constants.DatabaseSchema.Tables.Node, "id", false, new NodeDto { NodeId = -51, Trashed = false, ParentId = -1, UserId = -1, Level = 1, Path = "-1,-51", SortOrder = 2, UniqueId = new Guid("2e6d3631-066e-44b8-aec4-96f09099b2b5"), Text = "Numeric", NodeObjectType = Constants.ObjectTypes.DataType, CreateDate = DateTime.Now });
- _database.Insert(Constants.DatabaseSchema.Tables.Node, "id", false, new NodeDto { NodeId = -49, Trashed = false, ParentId = -1, UserId = -1, Level = 1, Path = "-1,-49", SortOrder = 2, UniqueId = new Guid("92897bc6-a5f3-4ffe-ae27-f2e7e33dda49"), Text = "True/false", NodeObjectType = Constants.ObjectTypes.DataType, CreateDate = DateTime.Now });
- _database.Insert(Constants.DatabaseSchema.Tables.Node, "id", false, new NodeDto { NodeId = -43, Trashed = false, ParentId = -1, UserId = -1, Level = 1, Path = "-1,-43", SortOrder = 2, UniqueId = new Guid("fbaf13a8-4036-41f2-93a3-974f678c312a"), Text = "Checkbox list", NodeObjectType = Constants.ObjectTypes.DataType, CreateDate = DateTime.Now });
- _database.Insert(Constants.DatabaseSchema.Tables.Node, "id", false, new NodeDto { NodeId = Constants.DataTypes.DropDownSingle, Trashed = false, ParentId = -1, UserId = -1, Level = 1, Path = $"-1,{Constants.DataTypes.DropDownSingle}", SortOrder = 2, UniqueId = new Guid("0b6a45e7-44ba-430d-9da5-4e46060b9e03"), Text = "Dropdown", NodeObjectType = Constants.ObjectTypes.DataType, CreateDate = DateTime.Now });
- _database.Insert(Constants.DatabaseSchema.Tables.Node, "id", false, new NodeDto { NodeId = -41, Trashed = false, ParentId = -1, UserId = -1, Level = 1, Path = "-1,-41", SortOrder = 2, UniqueId = new Guid("5046194e-4237-453c-a547-15db3a07c4e1"), Text = "Date Picker", NodeObjectType = Constants.ObjectTypes.DataType, CreateDate = DateTime.Now });
- _database.Insert(Constants.DatabaseSchema.Tables.Node, "id", false, new NodeDto { NodeId = -40, Trashed = false, ParentId = -1, UserId = -1, Level = 1, Path = "-1,-40", SortOrder = 2, UniqueId = new Guid("bb5f57c9-ce2b-4bb9-b697-4caca783a805"), Text = "Radiobox", NodeObjectType = Constants.ObjectTypes.DataType, CreateDate = DateTime.Now });
- _database.Insert(Constants.DatabaseSchema.Tables.Node, "id", false, new NodeDto { NodeId = Constants.DataTypes.DropDownMultiple, Trashed = false, ParentId = -1, UserId = -1, Level = 1, Path = $"-1,{Constants.DataTypes.DropDownMultiple}", SortOrder = 2, UniqueId = new Guid("f38f0ac7-1d27-439c-9f3f-089cd8825a53"), Text = "Dropdown multiple", NodeObjectType = Constants.ObjectTypes.DataType, CreateDate = DateTime.Now });
- _database.Insert(Constants.DatabaseSchema.Tables.Node, "id", false, new NodeDto { NodeId = -37, Trashed = false, ParentId = -1, UserId = -1, Level = 1, Path = "-1,-37", SortOrder = 2, UniqueId = new Guid("0225af17-b302-49cb-9176-b9f35cab9c17"), Text = "Approved Color", NodeObjectType = Constants.ObjectTypes.DataType, CreateDate = DateTime.Now });
- _database.Insert(Constants.DatabaseSchema.Tables.Node, "id", false, new NodeDto { NodeId = -36, Trashed = false, ParentId = -1, UserId = -1, Level = 1, Path = "-1,-36", SortOrder = 2, UniqueId = new Guid("e4d66c0f-b935-4200-81f0-025f7256b89a"), Text = "Date Picker with time", NodeObjectType = Constants.ObjectTypes.DataType, CreateDate = DateTime.Now });
- _database.Insert(Constants.DatabaseSchema.Tables.Node, "id", false, new NodeDto { NodeId = Constants.DataTypes.DefaultContentListView, Trashed = false, ParentId = -1, UserId = -1, Level = 1, Path = $"-1,{Constants.DataTypes.DefaultContentListView}", SortOrder = 2, UniqueId = new Guid("C0808DD3-8133-4E4B-8CE8-E2BEA84A96A4"), Text = Constants.Conventions.DataTypes.ListViewPrefix + "Content", NodeObjectType = Constants.ObjectTypes.DataType, CreateDate = DateTime.Now });
- _database.Insert(Constants.DatabaseSchema.Tables.Node, "id", false, new NodeDto { NodeId = Constants.DataTypes.DefaultMediaListView, Trashed = false, ParentId = -1, UserId = -1, Level = 1, Path = $"-1,{Constants.DataTypes.DefaultMediaListView}", SortOrder = 2, UniqueId = new Guid("3A0156C4-3B8C-4803-BDC1-6871FAA83FFF"), Text = Constants.Conventions.DataTypes.ListViewPrefix + "Media", NodeObjectType = Constants.ObjectTypes.DataType, CreateDate = DateTime.Now });
- _database.Insert(Constants.DatabaseSchema.Tables.Node, "id", false, new NodeDto { NodeId = Constants.DataTypes.DefaultMembersListView, Trashed = false, ParentId = -1, UserId = -1, Level = 1, Path = $"-1,{Constants.DataTypes.DefaultMembersListView}", SortOrder = 2, UniqueId = new Guid("AA2C52A0-CE87-4E65-A47C-7DF09358585D"), Text = Constants.Conventions.DataTypes.ListViewPrefix + "Members", NodeObjectType = Constants.ObjectTypes.DataType, CreateDate = DateTime.Now });
+ InsertDataTypeNodeDto(Constants.DataTypes.LabelString, 35, Constants.DataTypes.Guids.LabelString, "Label (string)");
+ InsertDataTypeNodeDto(Constants.DataTypes.LabelInt, 36, Constants.DataTypes.Guids.LabelInt, "Label (integer)");
+ InsertDataTypeNodeDto(Constants.DataTypes.LabelBigint, 36, Constants.DataTypes.Guids.LabelBigInt, "Label (bigint)");
+ InsertDataTypeNodeDto(Constants.DataTypes.LabelDateTime, 37, Constants.DataTypes.Guids.LabelDateTime, "Label (datetime)");
+ InsertDataTypeNodeDto(Constants.DataTypes.LabelTime, 38, Constants.DataTypes.Guids.LabelTime, "Label (time)");
+ InsertDataTypeNodeDto(Constants.DataTypes.LabelDecimal, 39, Constants.DataTypes.Guids.LabelDecimal, "Label (decimal)");
+ _database.Insert(Constants.DatabaseSchema.Tables.Node, "id", false, new NodeDto { NodeId = Constants.DataTypes.Upload, Trashed = false, ParentId = -1, UserId = -1, Level = 1, Path = $"-1,{Constants.DataTypes.Upload}", SortOrder = 34, UniqueId = Constants.DataTypes.Guids.UploadGuid, Text = "Upload", NodeObjectType = Constants.ObjectTypes.DataType, CreateDate = DateTime.Now });
+ _database.Insert(Constants.DatabaseSchema.Tables.Node, "id", false, new NodeDto { NodeId = Constants.DataTypes.Textarea, Trashed = false, ParentId = -1, UserId = -1, Level = 1, Path = $"-1,{Constants.DataTypes.Textarea}", SortOrder = 33, UniqueId = Constants.DataTypes.Guids.TextareaGuid, Text = "Textarea", NodeObjectType = Constants.ObjectTypes.DataType, CreateDate = DateTime.Now });
+ _database.Insert(Constants.DatabaseSchema.Tables.Node, "id", false, new NodeDto { NodeId = Constants.DataTypes.Textbox, Trashed = false, ParentId = -1, UserId = -1, Level = 1, Path = $"-1,{Constants.DataTypes.Textbox}", SortOrder = 32, UniqueId = Constants.DataTypes.Guids.TextstringGuid, Text = "Textstring", NodeObjectType = Constants.ObjectTypes.DataType, CreateDate = DateTime.Now });
+ _database.Insert(Constants.DatabaseSchema.Tables.Node, "id", false, new NodeDto { NodeId = Constants.DataTypes.RichtextEditor, Trashed = false, ParentId = -1, UserId = -1, Level = 1, Path = $"-1,{Constants.DataTypes.RichtextEditor}", SortOrder = 4, UniqueId = Constants.DataTypes.Guids.RichtextEditorGuid, Text = "Richtext editor", NodeObjectType = Constants.ObjectTypes.DataType, CreateDate = DateTime.Now });
+ _database.Insert(Constants.DatabaseSchema.Tables.Node, "id", false, new NodeDto { NodeId = -51, Trashed = false, ParentId = -1, UserId = -1, Level = 1, Path = "-1,-51", SortOrder = 2, UniqueId = Constants.DataTypes.Guids.NumericGuid, Text = "Numeric", NodeObjectType = Constants.ObjectTypes.DataType, CreateDate = DateTime.Now });
+ _database.Insert(Constants.DatabaseSchema.Tables.Node, "id", false, new NodeDto { NodeId = Constants.DataTypes.Boolean, Trashed = false, ParentId = -1, UserId = -1, Level = 1, Path = $"-1,{Constants.DataTypes.Boolean}", SortOrder = 2, UniqueId = Constants.DataTypes.Guids.CheckboxGuid, Text = "True/false", NodeObjectType = Constants.ObjectTypes.DataType, CreateDate = DateTime.Now });
+ _database.Insert(Constants.DatabaseSchema.Tables.Node, "id", false, new NodeDto { NodeId = -43, Trashed = false, ParentId = -1, UserId = -1, Level = 1, Path = "-1,-43", SortOrder = 2, UniqueId = Constants.DataTypes.Guids.CheckboxListGuid, Text = "Checkbox list", NodeObjectType = Constants.ObjectTypes.DataType, CreateDate = DateTime.Now });
+ _database.Insert(Constants.DatabaseSchema.Tables.Node, "id", false, new NodeDto { NodeId = Constants.DataTypes.DropDownSingle, Trashed = false, ParentId = -1, UserId = -1, Level = 1, Path = $"-1,{Constants.DataTypes.DropDownSingle}", SortOrder = 2, UniqueId = Constants.DataTypes.Guids.DropdownGuid, Text = "Dropdown", NodeObjectType = Constants.ObjectTypes.DataType, CreateDate = DateTime.Now });
+ _database.Insert(Constants.DatabaseSchema.Tables.Node, "id", false, new NodeDto { NodeId = -41, Trashed = false, ParentId = -1, UserId = -1, Level = 1, Path = "-1,-41", SortOrder = 2, UniqueId = Constants.DataTypes.Guids.DatePickerGuid, Text = "Date Picker", NodeObjectType = Constants.ObjectTypes.DataType, CreateDate = DateTime.Now });
+ _database.Insert(Constants.DatabaseSchema.Tables.Node, "id", false, new NodeDto { NodeId = -40, Trashed = false, ParentId = -1, UserId = -1, Level = 1, Path = "-1,-40", SortOrder = 2, UniqueId = Constants.DataTypes.Guids.RadioboxGuid, Text = "Radiobox", NodeObjectType = Constants.ObjectTypes.DataType, CreateDate = DateTime.Now });
+ _database.Insert(Constants.DatabaseSchema.Tables.Node, "id", false, new NodeDto { NodeId = Constants.DataTypes.DropDownMultiple, Trashed = false, ParentId = -1, UserId = -1, Level = 1, Path = $"-1,{Constants.DataTypes.DropDownMultiple}", SortOrder = 2, UniqueId = Constants.DataTypes.Guids.DropdownMultipleGuid, Text = "Dropdown multiple", NodeObjectType = Constants.ObjectTypes.DataType, CreateDate = DateTime.Now });
+ _database.Insert(Constants.DatabaseSchema.Tables.Node, "id", false, new NodeDto { NodeId = -37, Trashed = false, ParentId = -1, UserId = -1, Level = 1, Path = "-1,-37", SortOrder = 2, UniqueId = Constants.DataTypes.Guids.ApprovedColorGuid, Text = "Approved Color", NodeObjectType = Constants.ObjectTypes.DataType, CreateDate = DateTime.Now });
+ _database.Insert(Constants.DatabaseSchema.Tables.Node, "id", false, new NodeDto { NodeId = Constants.DataTypes.DateTime, Trashed = false, ParentId = -1, UserId = -1, Level = 1, Path = $"-1,{Constants.DataTypes.DateTime}", SortOrder = 2, UniqueId = Constants.DataTypes.Guids.DatePickerWithTimeGuid, Text = "Date Picker with time", NodeObjectType = Constants.ObjectTypes.DataType, CreateDate = DateTime.Now });
+ _database.Insert(Constants.DatabaseSchema.Tables.Node, "id", false, new NodeDto { NodeId = Constants.DataTypes.DefaultContentListView, Trashed = false, ParentId = -1, UserId = -1, Level = 1, Path = $"-1,{Constants.DataTypes.DefaultContentListView}", SortOrder = 2, UniqueId = Constants.DataTypes.Guids.ListViewContentGuid, Text = Constants.Conventions.DataTypes.ListViewPrefix + "Content", NodeObjectType = Constants.ObjectTypes.DataType, CreateDate = DateTime.Now });
+ _database.Insert(Constants.DatabaseSchema.Tables.Node, "id", false, new NodeDto { NodeId = Constants.DataTypes.DefaultMediaListView, Trashed = false, ParentId = -1, UserId = -1, Level = 1, Path = $"-1,{Constants.DataTypes.DefaultMediaListView}", SortOrder = 2, UniqueId = Constants.DataTypes.Guids.ListViewMediaGuid, Text = Constants.Conventions.DataTypes.ListViewPrefix + "Media", NodeObjectType = Constants.ObjectTypes.DataType, CreateDate = DateTime.Now });
+ _database.Insert(Constants.DatabaseSchema.Tables.Node, "id", false, new NodeDto { NodeId = Constants.DataTypes.DefaultMembersListView, Trashed = false, ParentId = -1, UserId = -1, Level = 1, Path = $"-1,{Constants.DataTypes.DefaultMembersListView}", SortOrder = 2, UniqueId = Constants.DataTypes.Guids.ListViewMembersGuid, Text = Constants.Conventions.DataTypes.ListViewPrefix + "Members", NodeObjectType = Constants.ObjectTypes.DataType, CreateDate = DateTime.Now });
_database.Insert(Constants.DatabaseSchema.Tables.Node, "id", false, new NodeDto { NodeId = 1031, Trashed = false, ParentId = -1, UserId = -1, Level = 1, Path = "-1,1031", SortOrder = 2, UniqueId = new Guid("f38bd2d7-65d0-48e6-95dc-87ce06ec2d3d"), Text = Constants.Conventions.MediaTypes.Folder, NodeObjectType = Constants.ObjectTypes.MediaType, CreateDate = DateTime.Now });
_database.Insert(Constants.DatabaseSchema.Tables.Node, "id", false, new NodeDto { NodeId = 1032, Trashed = false, ParentId = -1, UserId = -1, Level = 1, Path = "-1,1032", SortOrder = 2, UniqueId = new Guid("cc07b313-0843-4aa8-bbda-871c8da728c8"), Text = Constants.Conventions.MediaTypes.Image, NodeObjectType = Constants.ObjectTypes.MediaType, CreateDate = DateTime.Now });
_database.Insert(Constants.DatabaseSchema.Tables.Node, "id", false, new NodeDto { NodeId = 1033, Trashed = false, ParentId = -1, UserId = -1, Level = 1, Path = "-1,1033", SortOrder = 2, UniqueId = new Guid("4c52d8ab-54e6-40cd-999c-7a5f24903e4d"), Text = Constants.Conventions.MediaTypes.File, NodeObjectType = Constants.ObjectTypes.MediaType, CreateDate = DateTime.Now });
- _database.Insert(Constants.DatabaseSchema.Tables.Node, "id", false, new NodeDto { NodeId = 1041, Trashed = false, ParentId = -1, UserId = -1, Level = 1, Path = "-1,1041", SortOrder = 2, UniqueId = new Guid("b6b73142-b9c1-4bf8-a16d-e1c23320b549"), Text = "Tags", NodeObjectType = Constants.ObjectTypes.DataType, CreateDate = DateTime.Now });
- _database.Insert(Constants.DatabaseSchema.Tables.Node, "id", false, new NodeDto { NodeId = 1043, Trashed = false, ParentId = -1, UserId = -1, Level = 1, Path = "-1,1043", SortOrder = 2, UniqueId = new Guid("1df9f033-e6d4-451f-b8d2-e0cbc50a836f"), Text = "Image Cropper", NodeObjectType = Constants.ObjectTypes.DataType, CreateDate = DateTime.Now });
+ _database.Insert(Constants.DatabaseSchema.Tables.Node, "id", false, new NodeDto { NodeId = Constants.DataTypes.Tags, Trashed = false, ParentId = -1, UserId = -1, Level = 1, Path = $"-1,{Constants.DataTypes.Tags}", SortOrder = 2, UniqueId = new Guid("b6b73142-b9c1-4bf8-a16d-e1c23320b549"), Text = "Tags", NodeObjectType = Constants.ObjectTypes.DataType, CreateDate = DateTime.Now });
+ _database.Insert(Constants.DatabaseSchema.Tables.Node, "id", false, new NodeDto { NodeId = Constants.DataTypes.ImageCropper, Trashed = false, ParentId = -1, UserId = -1, Level = 1, Path = $"-1,{Constants.DataTypes.ImageCropper}", SortOrder = 2, UniqueId = new Guid("1df9f033-e6d4-451f-b8d2-e0cbc50a836f"), Text = "Image Cropper", NodeObjectType = Constants.ObjectTypes.DataType, CreateDate = DateTime.Now });
_database.Insert(Constants.DatabaseSchema.Tables.Node, "id", false, new NodeDto { NodeId = 1044, Trashed = false, ParentId = -1, UserId = -1, Level = 1, Path = "-1,1044", SortOrder = 0, UniqueId = new Guid("d59be02f-1df9-4228-aa1e-01917d806cda"), Text = Constants.Conventions.MemberTypes.DefaultAlias, NodeObjectType = Constants.ObjectTypes.MemberType, CreateDate = DateTime.Now });
//New UDI pickers with newer Ids
@@ -155,10 +155,10 @@ namespace Umbraco.Core.Migrations.Install
private void CreateContentTypeData()
{
- _database.Insert(Constants.DatabaseSchema.Tables.ContentType, "pk", false, new ContentTypeDto { PrimaryKey = 532, NodeId = 1031, Alias = Constants.Conventions.MediaTypes.Folder, Icon = "icon-folder", Thumbnail = "icon-folder", IsContainer = false, AllowAtRoot = true, Variations = (byte) ContentVariation.Nothing });
- _database.Insert(Constants.DatabaseSchema.Tables.ContentType, "pk", false, new ContentTypeDto { PrimaryKey = 533, NodeId = 1032, Alias = Constants.Conventions.MediaTypes.Image, Icon = "icon-picture", Thumbnail = "icon-picture", AllowAtRoot = true, Variations = (byte) ContentVariation.Nothing });
- _database.Insert(Constants.DatabaseSchema.Tables.ContentType, "pk", false, new ContentTypeDto { PrimaryKey = 534, NodeId = 1033, Alias = Constants.Conventions.MediaTypes.File, Icon = "icon-document", Thumbnail = "icon-document", AllowAtRoot = true, Variations = (byte) ContentVariation.Nothing });
- _database.Insert(Constants.DatabaseSchema.Tables.ContentType, "pk", false, new ContentTypeDto { PrimaryKey = 531, NodeId = 1044, Alias = Constants.Conventions.MemberTypes.DefaultAlias, Icon = "icon-user", Thumbnail = "icon-user", Variations = (byte) ContentVariation.Nothing });
+ _database.Insert(Constants.DatabaseSchema.Tables.ContentType, "pk", false, new ContentTypeDto { PrimaryKey = 532, NodeId = 1031, Alias = Constants.Conventions.MediaTypes.Folder, Icon = Constants.Icons.MediaFolder, Thumbnail = Constants.Icons.MediaFolder, IsContainer = false, AllowAtRoot = true, Variations = (byte) ContentVariation.Nothing });
+ _database.Insert(Constants.DatabaseSchema.Tables.ContentType, "pk", false, new ContentTypeDto { PrimaryKey = 533, NodeId = 1032, Alias = Constants.Conventions.MediaTypes.Image, Icon = Constants.Icons.MediaImage, Thumbnail = Constants.Icons.MediaImage, AllowAtRoot = true, Variations = (byte) ContentVariation.Nothing });
+ _database.Insert(Constants.DatabaseSchema.Tables.ContentType, "pk", false, new ContentTypeDto { PrimaryKey = 534, NodeId = 1033, Alias = Constants.Conventions.MediaTypes.File, Icon = Constants.Icons.MediaFile, Thumbnail = Constants.Icons.MediaFile, AllowAtRoot = true, Variations = (byte) ContentVariation.Nothing });
+ _database.Insert(Constants.DatabaseSchema.Tables.ContentType, "pk", false, new ContentTypeDto { PrimaryKey = 531, NodeId = 1044, Alias = Constants.Conventions.MemberTypes.DefaultAlias, Icon = Constants.Icons.Member, Thumbnail = Constants.Icons.Member, Variations = (byte) ContentVariation.Nothing });
}
private void CreateUserData()
@@ -210,19 +210,19 @@ namespace Umbraco.Core.Migrations.Install
private void CreatePropertyTypeData()
{
- _database.Insert(Constants.DatabaseSchema.Tables.PropertyType, "id", false, new PropertyTypeDto { Id = 6, UniqueId = 6.ToGuid(), DataTypeId = 1043, ContentTypeId = 1032, PropertyTypeGroupId = 3, Alias = Constants.Conventions.Media.File, Name = "Upload image", SortOrder = 0, Mandatory = true, ValidationRegExp = null, Description = null, Variations = (byte) ContentVariation.Nothing });
+ _database.Insert(Constants.DatabaseSchema.Tables.PropertyType, "id", false, new PropertyTypeDto { Id = 6, UniqueId = 6.ToGuid(), DataTypeId = Constants.DataTypes.ImageCropper, ContentTypeId = 1032, PropertyTypeGroupId = 3, Alias = Constants.Conventions.Media.File, Name = "Upload image", SortOrder = 0, Mandatory = true, ValidationRegExp = null, Description = null, Variations = (byte) ContentVariation.Nothing });
_database.Insert(Constants.DatabaseSchema.Tables.PropertyType, "id", false, new PropertyTypeDto { Id = 7, UniqueId = 7.ToGuid(), DataTypeId = Constants.DataTypes.LabelInt, ContentTypeId = 1032, PropertyTypeGroupId = 3, Alias = Constants.Conventions.Media.Width, Name = "Width", SortOrder = 0, Mandatory = false, ValidationRegExp = null, Description = "in pixels", Variations = (byte) ContentVariation.Nothing });
_database.Insert(Constants.DatabaseSchema.Tables.PropertyType, "id", false, new PropertyTypeDto { Id = 8, UniqueId = 8.ToGuid(), DataTypeId = Constants.DataTypes.LabelInt, ContentTypeId = 1032, PropertyTypeGroupId = 3, Alias = Constants.Conventions.Media.Height, Name = "Height", SortOrder = 0, Mandatory = false, ValidationRegExp = null, Description = "in pixels", Variations = (byte) ContentVariation.Nothing });
_database.Insert(Constants.DatabaseSchema.Tables.PropertyType, "id", false, new PropertyTypeDto { Id = 9, UniqueId = 9.ToGuid(), DataTypeId = Constants.DataTypes.LabelBigint, ContentTypeId = 1032, PropertyTypeGroupId = 3, Alias = Constants.Conventions.Media.Bytes, Name = "Size", SortOrder = 0, Mandatory = false, ValidationRegExp = null, Description = "in bytes", Variations = (byte) ContentVariation.Nothing });
_database.Insert(Constants.DatabaseSchema.Tables.PropertyType, "id", false, new PropertyTypeDto { Id = 10, UniqueId = 10.ToGuid(), DataTypeId = -92, ContentTypeId = 1032, PropertyTypeGroupId = 3, Alias = Constants.Conventions.Media.Extension, Name = "Type", SortOrder = 0, Mandatory = false, ValidationRegExp = null, Description = null, Variations = (byte) ContentVariation.Nothing });
- _database.Insert(Constants.DatabaseSchema.Tables.PropertyType, "id", false, new PropertyTypeDto { Id = 24, UniqueId = 24.ToGuid(), DataTypeId = -90, ContentTypeId = 1033, PropertyTypeGroupId = 4, Alias = Constants.Conventions.Media.File, Name = "Upload file", SortOrder = 0, Mandatory = true, ValidationRegExp = null, Description = null, Variations = (byte) ContentVariation.Nothing });
+ _database.Insert(Constants.DatabaseSchema.Tables.PropertyType, "id", false, new PropertyTypeDto { Id = 24, UniqueId = 24.ToGuid(), DataTypeId = Constants.DataTypes.Upload, ContentTypeId = 1033, PropertyTypeGroupId = 4, Alias = Constants.Conventions.Media.File, Name = "Upload file", SortOrder = 0, Mandatory = true, ValidationRegExp = null, Description = null, Variations = (byte) ContentVariation.Nothing });
_database.Insert(Constants.DatabaseSchema.Tables.PropertyType, "id", false, new PropertyTypeDto { Id = 25, UniqueId = 25.ToGuid(), DataTypeId = -92, ContentTypeId = 1033, PropertyTypeGroupId = 4, Alias = Constants.Conventions.Media.Extension, Name = "Type", SortOrder = 0, Mandatory = false, ValidationRegExp = null, Description = null, Variations = (byte) ContentVariation.Nothing });
_database.Insert(Constants.DatabaseSchema.Tables.PropertyType, "id", false, new PropertyTypeDto { Id = 26, UniqueId = 26.ToGuid(), DataTypeId = Constants.DataTypes.LabelBigint, ContentTypeId = 1033, PropertyTypeGroupId = 4, Alias = Constants.Conventions.Media.Bytes, Name = "Size", SortOrder = 0, Mandatory = false, ValidationRegExp = null, Description = "in bytes", Variations = (byte) ContentVariation.Nothing });
//membership property types
- _database.Insert(Constants.DatabaseSchema.Tables.PropertyType, "id", false, new PropertyTypeDto { Id = 28, UniqueId = 28.ToGuid(), DataTypeId = -89, ContentTypeId = 1044, PropertyTypeGroupId = 11, Alias = Constants.Conventions.Member.Comments, Name = Constants.Conventions.Member.CommentsLabel, SortOrder = 0, Mandatory = false, ValidationRegExp = null, Description = null, Variations = (byte) ContentVariation.Nothing });
+ _database.Insert(Constants.DatabaseSchema.Tables.PropertyType, "id", false, new PropertyTypeDto { Id = 28, UniqueId = 28.ToGuid(), DataTypeId = Constants.DataTypes.Textarea, ContentTypeId = 1044, PropertyTypeGroupId = 11, Alias = Constants.Conventions.Member.Comments, Name = Constants.Conventions.Member.CommentsLabel, SortOrder = 0, Mandatory = false, ValidationRegExp = null, Description = null, Variations = (byte) ContentVariation.Nothing });
_database.Insert(Constants.DatabaseSchema.Tables.PropertyType, "id", false, new PropertyTypeDto { Id = 29, UniqueId = 29.ToGuid(), DataTypeId = Constants.DataTypes.LabelInt, ContentTypeId = 1044, PropertyTypeGroupId = 11, Alias = Constants.Conventions.Member.FailedPasswordAttempts, Name = Constants.Conventions.Member.FailedPasswordAttemptsLabel, SortOrder = 1, Mandatory = false, ValidationRegExp = null, Description = null, Variations = (byte) ContentVariation.Nothing });
- _database.Insert(Constants.DatabaseSchema.Tables.PropertyType, "id", false, new PropertyTypeDto { Id = 30, UniqueId = 30.ToGuid(), DataTypeId = -49, ContentTypeId = 1044, PropertyTypeGroupId = 11, Alias = Constants.Conventions.Member.IsApproved, Name = Constants.Conventions.Member.IsApprovedLabel, SortOrder = 2, Mandatory = false, ValidationRegExp = null, Description = null, Variations = (byte) ContentVariation.Nothing });
- _database.Insert(Constants.DatabaseSchema.Tables.PropertyType, "id", false, new PropertyTypeDto { Id = 31, UniqueId = 31.ToGuid(), DataTypeId = -49, ContentTypeId = 1044, PropertyTypeGroupId = 11, Alias = Constants.Conventions.Member.IsLockedOut, Name = Constants.Conventions.Member.IsLockedOutLabel, SortOrder = 3, Mandatory = false, ValidationRegExp = null, Description = null, Variations = (byte) ContentVariation.Nothing });
+ _database.Insert(Constants.DatabaseSchema.Tables.PropertyType, "id", false, new PropertyTypeDto { Id = 30, UniqueId = 30.ToGuid(), DataTypeId = Constants.DataTypes.Boolean, ContentTypeId = 1044, PropertyTypeGroupId = 11, Alias = Constants.Conventions.Member.IsApproved, Name = Constants.Conventions.Member.IsApprovedLabel, SortOrder = 2, Mandatory = false, ValidationRegExp = null, Description = null, Variations = (byte) ContentVariation.Nothing });
+ _database.Insert(Constants.DatabaseSchema.Tables.PropertyType, "id", false, new PropertyTypeDto { Id = 31, UniqueId = 31.ToGuid(), DataTypeId = Constants.DataTypes.Boolean, ContentTypeId = 1044, PropertyTypeGroupId = 11, Alias = Constants.Conventions.Member.IsLockedOut, Name = Constants.Conventions.Member.IsLockedOutLabel, SortOrder = 3, Mandatory = false, ValidationRegExp = null, Description = null, Variations = (byte) ContentVariation.Nothing });
_database.Insert(Constants.DatabaseSchema.Tables.PropertyType, "id", false, new PropertyTypeDto { Id = 32, UniqueId = 32.ToGuid(), DataTypeId = Constants.DataTypes.LabelDateTime, ContentTypeId = 1044, PropertyTypeGroupId = 11, Alias = Constants.Conventions.Member.LastLockoutDate, Name = Constants.Conventions.Member.LastLockoutDateLabel, SortOrder = 4, Mandatory = false, ValidationRegExp = null, Description = null, Variations = (byte) ContentVariation.Nothing });
_database.Insert(Constants.DatabaseSchema.Tables.PropertyType, "id", false, new PropertyTypeDto { Id = 33, UniqueId = 33.ToGuid(), DataTypeId = Constants.DataTypes.LabelDateTime, ContentTypeId = 1044, PropertyTypeGroupId = 11, Alias = Constants.Conventions.Member.LastLoginDate, Name = Constants.Conventions.Member.LastLoginDateLabel, SortOrder = 5, Mandatory = false, ValidationRegExp = null, Description = null, Variations = (byte) ContentVariation.Nothing });
_database.Insert(Constants.DatabaseSchema.Tables.PropertyType, "id", false, new PropertyTypeDto { Id = 34, UniqueId = 34.ToGuid(), DataTypeId = Constants.DataTypes.LabelDateTime, ContentTypeId = 1044, PropertyTypeGroupId = 11, Alias = Constants.Conventions.Member.LastPasswordChangeDate, Name = Constants.Conventions.Member.LastPasswordChangeDateLabel, SortOrder = 6, Mandatory = false, ValidationRegExp = null, Description = null, Variations = (byte) ContentVariation.Nothing });
@@ -266,30 +266,30 @@ namespace Umbraco.Core.Migrations.Install
const string layouts = "[" + cardLayout + "," + listLayout + "]";
// TODO: Check which of the DataTypeIds below doesn't exist in umbracoNode, which results in a foreign key constraint errors.
- _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = -49, EditorAlias = Constants.PropertyEditors.Aliases.Boolean, DbType = "Integer" });
+ _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = Constants.DataTypes.Boolean, EditorAlias = Constants.PropertyEditors.Aliases.Boolean, DbType = "Integer" });
_database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = -51, EditorAlias = Constants.PropertyEditors.Aliases.Integer, DbType = "Integer" });
_database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = -87, EditorAlias = Constants.PropertyEditors.Aliases.TinyMce, DbType = "Ntext",
Configuration = "{\"value\":\",code,undo,redo,cut,copy,mcepasteword,stylepicker,bold,italic,bullist,numlist,outdent,indent,mcelink,unlink,mceinsertanchor,mceimage,umbracomacro,mceinserttable,umbracoembed,mcecharmap,|1|1,2,3,|0|500,400|1049,|true|\"}" });
- _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = -88, EditorAlias = Constants.PropertyEditors.Aliases.TextBox, DbType = "Nvarchar" });
- _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = -89, EditorAlias = Constants.PropertyEditors.Aliases.TextArea, DbType = "Ntext" });
- _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = -90, EditorAlias = Constants.PropertyEditors.Aliases.UploadField, DbType = "Nvarchar" });
+ _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = Constants.DataTypes.Textbox, EditorAlias = Constants.PropertyEditors.Aliases.TextBox, DbType = "Nvarchar" });
+ _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = Constants.DataTypes.Textarea, EditorAlias = Constants.PropertyEditors.Aliases.TextArea, DbType = "Ntext" });
+ _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = Constants.DataTypes.Upload, EditorAlias = Constants.PropertyEditors.Aliases.UploadField, DbType = "Nvarchar" });
InsertDataTypeDto(Constants.DataTypes.LabelString, Constants.PropertyEditors.Aliases.Label, "Nvarchar", "{\"umbracoDataValueType\":\"STRING\"}");
InsertDataTypeDto(Constants.DataTypes.LabelInt, Constants.PropertyEditors.Aliases.Label, "Integer", "{\"umbracoDataValueType\":\"INT\"}");
InsertDataTypeDto(Constants.DataTypes.LabelBigint, Constants.PropertyEditors.Aliases.Label, "Nvarchar", "{\"umbracoDataValueType\":\"BIGINT\"}");
InsertDataTypeDto(Constants.DataTypes.LabelDateTime, Constants.PropertyEditors.Aliases.Label, "Date", "{\"umbracoDataValueType\":\"DATETIME\"}");
InsertDataTypeDto(Constants.DataTypes.LabelDecimal, Constants.PropertyEditors.Aliases.Label, "Decimal", "{\"umbracoDataValueType\":\"DECIMAL\"}");
InsertDataTypeDto(Constants.DataTypes.LabelTime, Constants.PropertyEditors.Aliases.Label, "Date", "{\"umbracoDataValueType\":\"TIME\"}");
- _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = -36, EditorAlias = Constants.PropertyEditors.Aliases.DateTime, DbType = "Date" });
+ _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = Constants.DataTypes.DateTime, EditorAlias = Constants.PropertyEditors.Aliases.DateTime, DbType = "Date" });
_database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = -37, EditorAlias = Constants.PropertyEditors.Aliases.ColorPicker, DbType = "Nvarchar" });
InsertDataTypeDto(Constants.DataTypes.DropDownSingle, Constants.PropertyEditors.Aliases.DropDownListFlexible, "Nvarchar", "{\"multiple\":false}");
_database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = -40, EditorAlias = Constants.PropertyEditors.Aliases.RadioButtonList, DbType = "Nvarchar" });
_database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = -41, EditorAlias = "Umbraco.DateTime", DbType = "Date", Configuration = "{\"format\":\"YYYY-MM-DD\"}" });
InsertDataTypeDto(Constants.DataTypes.DropDownMultiple, Constants.PropertyEditors.Aliases.DropDownListFlexible, "Nvarchar", "{\"multiple\":true}");
_database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = -43, EditorAlias = Constants.PropertyEditors.Aliases.CheckBoxList, DbType = "Nvarchar" });
- _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = 1041, EditorAlias = Constants.PropertyEditors.Aliases.Tags, DbType = "Ntext",
+ _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = Constants.DataTypes.Tags, EditorAlias = Constants.PropertyEditors.Aliases.Tags, DbType = "Ntext",
Configuration = "{\"group\":\"default\", \"storageType\":\"Json\"}"
});
- _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = 1043, EditorAlias = Constants.PropertyEditors.Aliases.ImageCropper, DbType = "Ntext" });
+ _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = Constants.DataTypes.ImageCropper, EditorAlias = Constants.PropertyEditors.Aliases.ImageCropper, DbType = "Ntext" });
_database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = Constants.DataTypes.DefaultContentListView, EditorAlias = Constants.PropertyEditors.Aliases.ListView, DbType = "Nvarchar",
Configuration = "{\"pageSize\":100, \"orderBy\":\"updateDate\", \"orderDirection\":\"desc\", \"layouts\":" + layouts + ", \"includeProperties\":[{\"alias\":\"updateDate\",\"header\":\"Last edited\",\"isSystem\":1},{\"alias\":\"owner\",\"header\":\"Updated by\",\"isSystem\":1}]}" });
_database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = Constants.DataTypes.DefaultMediaListView, EditorAlias = Constants.PropertyEditors.Aliases.ListView, DbType = "Nvarchar",
diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/DataTypes/PreValueMigratorComposer.cs b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/DataTypes/PreValueMigratorComposer.cs
index 9e2dec9b70..4c3f8534e7 100644
--- a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/DataTypes/PreValueMigratorComposer.cs
+++ b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/DataTypes/PreValueMigratorComposer.cs
@@ -2,24 +2,24 @@
namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0.DataTypes
{
- [RuntimeLevel(MinLevel = RuntimeLevel.Upgrade, MaxLevel = RuntimeLevel.Upgrade)] // only on upgrades
- public class PreValueMigratorComposer : ICoreComposer
+[RuntimeLevel(MinLevel = RuntimeLevel.Upgrade, MaxLevel = RuntimeLevel.Upgrade)] // only on upgrades
+public class PreValueMigratorComposer : ICoreComposer
+{
+ public void Compose(Composition composition)
{
- public void Compose(Composition composition)
- {
- // do NOT add DefaultPreValueMigrator to this list!
- // it will be automatically used if nothing matches
+ // do NOT add DefaultPreValueMigrator to this list!
+ // it will be automatically used if nothing matches
- composition.WithCollectionBuilder()
- .Append()
- .Append()
- .Append()
- .Append()
- .Append()
- .Append()
- .Append()
- .Append()
- .Append();
- }
+ composition.WithCollectionBuilder()
+ .Append()
+ .Append()
+ .Append()
+ .Append()
+ .Append()
+ .Append()
+ .Append()
+ .Append()
+ .Append();
}
}
+}
diff --git a/src/Umbraco.Core/Models/DataTypeExtensions.cs b/src/Umbraco.Core/Models/DataTypeExtensions.cs
index df8a3caea8..f460edbde7 100644
--- a/src/Umbraco.Core/Models/DataTypeExtensions.cs
+++ b/src/Umbraco.Core/Models/DataTypeExtensions.cs
@@ -35,5 +35,58 @@ namespace Umbraco.Core.Models
throw new InvalidCastException($"Cannot cast dataType configuration, of type {configuration.GetType().Name}, to {typeof(T).Name}.");
}
+
+ private static readonly ISet IdsOfBuildInDataTypes = new HashSet()
+ {
+ Constants.DataTypes.Guids.ContentPickerGuid,
+ Constants.DataTypes.Guids.MemberPickerGuid,
+ Constants.DataTypes.Guids.MediaPickerGuid,
+ Constants.DataTypes.Guids.MultipleMediaPickerGuid,
+ Constants.DataTypes.Guids.RelatedLinksGuid,
+ Constants.DataTypes.Guids.MemberGuid,
+ Constants.DataTypes.Guids.ImageCropperGuid,
+ Constants.DataTypes.Guids.TagsGuid,
+ Constants.DataTypes.Guids.ListViewContentGuid,
+ Constants.DataTypes.Guids.ListViewMediaGuid,
+ Constants.DataTypes.Guids.ListViewMembersGuid,
+ Constants.DataTypes.Guids.DatePickerWithTimeGuid,
+ Constants.DataTypes.Guids.ApprovedColorGuid,
+ Constants.DataTypes.Guids.DropdownMultipleGuid,
+ Constants.DataTypes.Guids.RadioboxGuid,
+ Constants.DataTypes.Guids.DatePickerGuid,
+ Constants.DataTypes.Guids.DropdownGuid,
+ Constants.DataTypes.Guids.CheckboxListGuid,
+ Constants.DataTypes.Guids.CheckboxGuid,
+ Constants.DataTypes.Guids.NumericGuid,
+ Constants.DataTypes.Guids.RichtextEditorGuid,
+ Constants.DataTypes.Guids.TextstringGuid,
+ Constants.DataTypes.Guids.TextareaGuid,
+ Constants.DataTypes.Guids.UploadGuid,
+ Constants.DataTypes.Guids.LabelStringGuid,
+ Constants.DataTypes.Guids.LabelDecimalGuid,
+ Constants.DataTypes.Guids.LabelDateTimeGuid,
+ Constants.DataTypes.Guids.LabelBigIntGuid,
+ Constants.DataTypes.Guids.LabelTimeGuid,
+ Constants.DataTypes.Guids.LabelDateTimeGuid,
+ };
+
+ ///
+ /// Returns true if this date type is build-in/default.
+ ///
+ /// The data type definition.
+ ///
+ internal static bool IsBuildInDataType(this IDataType dataType)
+ {
+ return IsBuildInDataType(dataType.Key);
+ }
+
+ ///
+ /// Returns true if this date type is build-in/default.
+ ///
+ internal static bool IsBuildInDataType(Guid key)
+ {
+ return IdsOfBuildInDataTypes.Contains(key);
+ }
+
}
}
diff --git a/src/Umbraco.Core/Models/Entities/EntityExtensions.cs b/src/Umbraco.Core/Models/Entities/EntityExtensions.cs
new file mode 100644
index 0000000000..2ee6a2d5ed
--- /dev/null
+++ b/src/Umbraco.Core/Models/Entities/EntityExtensions.cs
@@ -0,0 +1,46 @@
+using System;
+
+namespace Umbraco.Core.Models.Entities
+{
+ internal static class EntityExtensions
+ {
+ ///
+ /// Updates the entity when it is being saved.
+ ///
+ internal static void UpdatingEntity(this IEntity entity)
+ {
+ var now = DateTime.Now;
+
+ // just in case
+ if (entity.CreateDate == default)
+ {
+ entity.CreateDate = now;
+ }
+
+ // set the update date if not already set
+ if (entity.UpdateDate == default || (entity is ICanBeDirty canBeDirty && canBeDirty.IsPropertyDirty("UpdateDate") == false))
+ {
+ entity.UpdateDate = now;
+ }
+ }
+
+ ///
+ /// Updates the entity when it is being saved for the first time.
+ ///
+ internal static void AddingEntity(this IEntity entity)
+ {
+ var now = DateTime.Now;
+ var canBeDirty = entity as ICanBeDirty;
+
+ // set the create and update dates, if not already set
+ if (entity.CreateDate == default || canBeDirty?.IsPropertyDirty("CreateDate") == false)
+ {
+ entity.CreateDate = now;
+ }
+ if (entity.UpdateDate == default || canBeDirty?.IsPropertyDirty("UpdateDate") == false)
+ {
+ entity.UpdateDate = now;
+ }
+ }
+ }
+}
diff --git a/src/Umbraco.Core/Models/Member.cs b/src/Umbraco.Core/Models/Member.cs
index 537a830bca..b473a154f1 100644
--- a/src/Umbraco.Core/Models/Member.cs
+++ b/src/Umbraco.Core/Models/Member.cs
@@ -478,19 +478,6 @@ namespace Umbraco.Core.Models
set => SetPropertyValueAndDetectChanges(value, ref _providerUserKey, nameof(ProviderUserKey));
}
-
- ///
- /// Method to call when Entity is being saved
- ///
- /// Created date is set and a Unique key is assigned
- public override void AddingEntity()
- {
- base.AddingEntity();
-
- if (ProviderUserKey == null)
- ProviderUserKey = Key;
- }
-
/* Internal experiment - only used for mapping queries.
* Adding these to have first level properties instead of the Properties collection.
*/
diff --git a/src/Umbraco.Core/Models/PropertyType.cs b/src/Umbraco.Core/Models/PropertyType.cs
index 908491fbb2..e7a9ae2dfd 100644
--- a/src/Umbraco.Core/Models/PropertyType.cs
+++ b/src/Umbraco.Core/Models/PropertyType.cs
@@ -20,6 +20,7 @@ namespace Umbraco.Core.Models
private string _alias;
private string _description;
private int _dataTypeId;
+ private Guid _dataTypeKey;
private Lazy _propertyGroupId;
private string _propertyEditorAlias;
private ValueStorageType _valueStorageType;
@@ -138,6 +139,13 @@ namespace Umbraco.Core.Models
set => SetPropertyValueAndDetectChanges(value, ref _dataTypeId, nameof(DataTypeId));
}
+ [DataMember]
+ public Guid DataTypeKey
+ {
+ get => _dataTypeKey;
+ set => SetPropertyValueAndDetectChanges(value, ref _dataTypeKey, nameof(DataTypeKey));
+ }
+
///
/// Gets or sets the alias of the property editor for this property type.
///
diff --git a/src/Umbraco.Core/Models/PublishedContent/ILivePublishedModelFactory.cs b/src/Umbraco.Core/Models/PublishedContent/ILivePublishedModelFactory.cs
index 4027184f3c..0810f2207b 100644
--- a/src/Umbraco.Core/Models/PublishedContent/ILivePublishedModelFactory.cs
+++ b/src/Umbraco.Core/Models/PublishedContent/ILivePublishedModelFactory.cs
@@ -13,6 +13,10 @@
///
/// Refreshes the factory.
///
+ ///
+ /// This will typically re-compiled models/classes into a new DLL that are used to populate the cache.
+ /// This is called prior to refreshing the cache.
+ ///
void Refresh();
}
}
diff --git a/src/Umbraco.Core/Models/PublishedContent/IPublishedContent.cs b/src/Umbraco.Core/Models/PublishedContent/IPublishedContent.cs
index d38c8eb721..1c0d39a8b8 100644
--- a/src/Umbraco.Core/Models/PublishedContent/IPublishedContent.cs
+++ b/src/Umbraco.Core/Models/PublishedContent/IPublishedContent.cs
@@ -3,7 +3,6 @@ using System.Collections.Generic;
namespace Umbraco.Core.Models.PublishedContent
{
-
///
///
/// Represents a published content item.
@@ -27,21 +26,13 @@ namespace Umbraco.Core.Models.PublishedContent
int Id { get; }
///
- /// Gets the name of the content item.
+ /// Gets the name of the content item for the current culture.
///
- ///
- /// The value of this property is contextual. When the content type is multi-lingual,
- /// this is the name for the 'current' culture. Otherwise, it is the invariant name.
- ///
string Name { get; }
///
- /// Gets the url segment of the content item.
+ /// Gets the url segment of the content item for the current culture.
///
- ///
- /// The value of this property is contextual. When the content type is multi-lingual,
- /// this is the name for the 'current' culture. Otherwise, it is the invariant url segment.
- ///
string UrlSegment { get; }
///
@@ -94,43 +85,28 @@ namespace Umbraco.Core.Models.PublishedContent
///
///
/// For published content items, this is also the date the item was published.
- /// This date is always global to the content item, see GetCulture().Date for the
+ /// This date is always global to the content item, see CultureDate() for the
/// date each culture was published.
///
DateTime UpdateDate { get; }
///
- /// Gets the url of the content item.
+ /// Gets the url of the content item for the current culture.
///
///
/// The value of this property is contextual. It depends on the 'current' request uri,
- /// if any. In addition, when the content type is multi-lingual, this is the url for the
- /// 'current' culture. Otherwise, it is the invariant url.
+ /// if any.
///
string Url { get; }
///
- /// Gets the url of the content item.
- ///
- ///
- /// The value of this property is contextual. It depends on the 'current' request uri,
- /// if any. In addition, when the content type is multi-lingual, this is the url for the
- /// specified culture. Otherwise, it is the invariant url.
- ///
- string GetUrl(string culture = null);
-
- ///
- /// Gets culture infos for a culture.
- ///
- PublishedCultureInfo GetCulture(string culture = null);
-
- ///
- /// Gets culture infos.
+ /// Gets available culture infos.
///
///
/// Contains only those culture that are available. For a published content, these are
/// the cultures that are published. For a draft content, those that are 'available' ie
/// have a non-empty content name.
+ /// Does not contain the invariant culture. // fixme?
///
IReadOnlyDictionary Cultures { get; }
@@ -178,11 +154,15 @@ namespace Umbraco.Core.Models.PublishedContent
IPublishedContent Parent { get; }
///
- /// Gets the children of the content item.
+ /// Gets the children of the content item that are available for the current culture.
///
- /// Children are sorted by their sortOrder.
IEnumerable Children { get; }
+ ///
+ /// Gets all the children of the content item, regardless of whether they are available for the current culture.
+ ///
+ IEnumerable ChildrenForAllCultures { get; }
+
#endregion
}
}
diff --git a/src/Umbraco.Core/Models/PublishedContent/IPublishedContentType.cs b/src/Umbraco.Core/Models/PublishedContent/IPublishedContentType.cs
new file mode 100644
index 0000000000..ab6920377c
--- /dev/null
+++ b/src/Umbraco.Core/Models/PublishedContent/IPublishedContentType.cs
@@ -0,0 +1,63 @@
+using System.Collections.Generic;
+
+namespace Umbraco.Core.Models.PublishedContent
+{
+ ///
+ /// Represents an type.
+ ///
+ /// Instances implementing the interface should be
+ /// immutable, ie if the content type changes, then a new instance needs to be created.
+ public interface IPublishedContentType
+ {
+ ///
+ /// Gets the content type identifier.
+ ///
+ int Id { get; }
+
+ ///
+ /// Gets the content type alias.
+ ///
+ string Alias { get; }
+
+ ///
+ /// Gets the content item type.
+ ///
+ PublishedItemType ItemType { get; }
+
+ ///
+ /// Gets the aliases of the content types participating in the composition.
+ ///
+ HashSet CompositionAliases { get; }
+
+ ///
+ /// Gets the content variations of the content type.
+ ///
+ ContentVariation Variations { get; }
+
+ ///
+ /// Gets a value indicating whether this content type is for an element.
+ ///
+ bool IsElement { get; }
+
+ ///
+ /// Gets the content type properties.
+ ///
+ IEnumerable PropertyTypes { get; }
+
+ ///
+ /// Gets a property type index.
+ ///
+ /// The alias is case-insensitive. This is the only place where alias strings are compared.
+ int GetPropertyIndex(string alias);
+
+ ///
+ /// Gets a property type.
+ ///
+ IPublishedPropertyType GetPropertyType(string alias);
+
+ ///
+ /// Gets a property type.
+ ///
+ IPublishedPropertyType GetPropertyType(int index);
+ }
+}
diff --git a/src/Umbraco.Core/Models/PublishedContent/IPublishedContentTypeFactory.cs b/src/Umbraco.Core/Models/PublishedContent/IPublishedContentTypeFactory.cs
index e75e8a4eb9..816bfdbb01 100644
--- a/src/Umbraco.Core/Models/PublishedContent/IPublishedContentTypeFactory.cs
+++ b/src/Umbraco.Core/Models/PublishedContent/IPublishedContentTypeFactory.cs
@@ -10,7 +10,7 @@
///
/// An content type.
/// A published content type corresponding to the item type and content type.
- PublishedContentType CreateContentType(IContentTypeComposition contentType);
+ IPublishedContentType CreateContentType(IContentTypeComposition contentType);
///
/// Creates a published property type.
@@ -18,7 +18,7 @@
/// The published content type owning the property.
/// A property type.
/// Is used by constructor to create property types.
- PublishedPropertyType CreatePropertyType(PublishedContentType contentType, PropertyType propertyType);
+ IPublishedPropertyType CreatePropertyType(IPublishedContentType contentType, PropertyType propertyType);
///
/// Creates a published property type.
@@ -28,7 +28,7 @@
/// The datatype identifier.
/// The variations.
/// Is used by constructor to create special property types.
- PublishedPropertyType CreatePropertyType(PublishedContentType contentType, string propertyTypeAlias, int dataTypeId, ContentVariation variations);
+ IPublishedPropertyType CreatePropertyType(IPublishedContentType contentType, string propertyTypeAlias, int dataTypeId, ContentVariation variations);
///
/// Gets a published datatype.
diff --git a/src/Umbraco.Core/Models/PublishedContent/IPublishedElement.cs b/src/Umbraco.Core/Models/PublishedContent/IPublishedElement.cs
index 4b579d824b..4c72dc914a 100644
--- a/src/Umbraco.Core/Models/PublishedContent/IPublishedElement.cs
+++ b/src/Umbraco.Core/Models/PublishedContent/IPublishedElement.cs
@@ -13,7 +13,7 @@ namespace Umbraco.Core.Models.PublishedContent
///
/// Gets the content type.
///
- PublishedContentType ContentType { get; }
+ IPublishedContentType ContentType { get; }
#endregion
diff --git a/src/Umbraco.Core/Models/PublishedContent/IPublishedProperty.cs b/src/Umbraco.Core/Models/PublishedContent/IPublishedProperty.cs
index 9a00e94d3e..2ee7dcb28f 100644
--- a/src/Umbraco.Core/Models/PublishedContent/IPublishedProperty.cs
+++ b/src/Umbraco.Core/Models/PublishedContent/IPublishedProperty.cs
@@ -5,7 +5,7 @@
///
public interface IPublishedProperty
{
- PublishedPropertyType PropertyType { get; }
+ IPublishedPropertyType PropertyType { get; }
///
/// Gets the alias of the property.
diff --git a/src/Umbraco.Core/Models/PublishedContent/IPublishedPropertyType.cs b/src/Umbraco.Core/Models/PublishedContent/IPublishedPropertyType.cs
new file mode 100644
index 0000000000..40f2bf3df2
--- /dev/null
+++ b/src/Umbraco.Core/Models/PublishedContent/IPublishedPropertyType.cs
@@ -0,0 +1,108 @@
+using System;
+using Umbraco.Core.PropertyEditors;
+
+namespace Umbraco.Core.Models.PublishedContent
+{
+ ///
+ /// Represents a published property type.
+ ///
+ /// Instances implementing the interface should be
+ /// immutable, ie if the property type changes, then a new instance needs to be created.
+ public interface IPublishedPropertyType
+ {
+ ///
+ /// Gets the published content type containing the property type.
+ ///
+ IPublishedContentType ContentType { get; }
+
+ ///
+ /// Gets the data type.
+ ///
+ PublishedDataType DataType { get; }
+
+ ///
+ /// Gets property type alias.
+ ///
+ string Alias { get; }
+
+ ///
+ /// Gets the property editor alias.
+ ///
+ string EditorAlias { get; }
+
+ ///
+ /// Gets a value indicating whether the property is a user content property.
+ ///
+ /// A non-user content property is a property that has been added to a
+ /// published content type by Umbraco but does not corresponds to a user-defined
+ /// published property.
+ bool IsUserProperty { get; }
+
+ ///
+ /// Gets the content variations of the property type.
+ ///
+ ContentVariation Variations { get; }
+
+ ///
+ /// Determines whether a value is an actual value, or not a value.
+ ///
+ /// Used by property.HasValue and, for instance, in fallback scenarios.
+ bool? IsValue(object value, PropertyValueLevel level);
+
+ ///
+ /// Gets the property cache level.
+ ///
+ PropertyCacheLevel CacheLevel { get; }
+
+ ///
+ /// Converts the source value into the intermediate value.
+ ///
+ /// The published element owning the property.
+ /// The source value.
+ /// A value indicating whether content should be considered draft.
+ /// The intermediate value.
+ object ConvertSourceToInter(IPublishedElement owner, object source, bool preview);
+
+ ///
+ /// Converts the intermediate value into the object value.
+ ///
+ /// The published element owning the property.
+ /// The reference cache level.
+ /// The intermediate value.
+ /// A value indicating whether content should be considered draft.
+ /// The object value.
+ object ConvertInterToObject(IPublishedElement owner, PropertyCacheLevel referenceCacheLevel, object inter, bool preview);
+
+ ///
+ /// Converts the intermediate value into the XPath value.
+ ///
+ /// The published element owning the property.
+ /// The reference cache level.
+ /// The intermediate value.
+ /// A value indicating whether content should be considered draft.
+ /// The XPath value.
+ ///
+ /// The XPath value can be either a string or an XPathNavigator.
+ ///
+ object ConvertInterToXPath(IPublishedElement owner, PropertyCacheLevel referenceCacheLevel, object inter, bool preview);
+
+ ///
+ /// Gets the property model CLR type.
+ ///
+ ///
+ /// The model CLR type may be a type, or may contain types.
+ /// For the actual CLR type, see .
+ ///
+ Type ModelClrType { get; }
+
+ ///
+ /// Gets the property CLR type.
+ ///
+ ///
+ /// Returns the actual CLR type which does not contain types.
+ /// Mapping from may throw if some instances
+ /// could not be mapped to actual CLR types.
+ ///
+ Type ClrType { get; }
+ }
+}
\ No newline at end of file
diff --git a/src/Umbraco.Core/Models/PublishedContent/PublishedContentType.cs b/src/Umbraco.Core/Models/PublishedContent/PublishedContentType.cs
index 0798e9a4e0..3b03cfc9ea 100644
--- a/src/Umbraco.Core/Models/PublishedContent/PublishedContentType.cs
+++ b/src/Umbraco.Core/Models/PublishedContent/PublishedContentType.cs
@@ -5,13 +5,13 @@ using System.Linq;
namespace Umbraco.Core.Models.PublishedContent
{
///
- /// Represents an type.
+ /// Represents an type.
///
/// Instances of the class are immutable, ie
/// if the content type changes, then a new class needs to be created.
- public class PublishedContentType
+ public class PublishedContentType : IPublishedContentType
{
- private readonly PublishedPropertyType[] _propertyTypes;
+ private readonly IPublishedPropertyType[] _propertyTypes;
// fast alias-to-index xref containing both the raw alias and its lowercase version
private readonly Dictionary _indexes = new Dictionary();
@@ -35,11 +35,10 @@ namespace Umbraco.Core.Models.PublishedContent
}
///
- /// Initializes a new instance of the with specific values.
+ /// This constructor is for tests and is not intended to be used directly from application code.
///
///
- /// This constructor is for tests and is not intended to be used directly from application code.
- /// Values are assumed to be consisted and are not checked.
+ /// Values are assumed to be consistent and are not checked.
///
public PublishedContentType(int id, string alias, PublishedItemType itemType, IEnumerable compositionAliases, IEnumerable propertyTypes, ContentVariation variations, bool isElement = false)
: this (id, alias, itemType, compositionAliases, variations, isElement)
@@ -52,6 +51,20 @@ namespace Umbraco.Core.Models.PublishedContent
InitializeIndexes();
}
+ ///
+ /// This constructor is for tests and is not intended to be used directly from application code.
+ ///
+ ///
+ /// Values are assumed to be consistent and are not checked.
+ ///
+ public PublishedContentType(int id, string alias, PublishedItemType itemType, IEnumerable compositionAliases, Func> propertyTypes, ContentVariation variations, bool isElement = false)
+ : this(id, alias, itemType, compositionAliases, variations, isElement)
+ {
+ _propertyTypes = propertyTypes(this).ToArray();
+
+ InitializeIndexes();
+ }
+
private PublishedContentType(int id, string alias, PublishedItemType itemType, IEnumerable compositionAliases, ContentVariation variations, bool isElement)
{
Id = id;
@@ -75,7 +88,7 @@ namespace Umbraco.Core.Models.PublishedContent
// Members have properties such as IMember LastLoginDate which are plain C# properties and not content
// properties; they are exposed as pseudo content properties, as long as a content property with the
// same alias does not exist already.
- private void EnsureMemberProperties(List propertyTypes, IPublishedContentTypeFactory factory)
+ private void EnsureMemberProperties(List propertyTypes, IPublishedContentTypeFactory factory)
{
var aliases = new HashSet(propertyTypes.Select(x => x.Alias), StringComparer.OrdinalIgnoreCase);
@@ -103,44 +116,29 @@ namespace Umbraco.Core.Models.PublishedContent
#region Content type
- ///
- /// Gets the content type identifier.
- ///
+ ///
public int Id { get; }
- ///
- /// Gets the content type alias.
- ///
+ ///
public string Alias { get; }
- ///
- /// Gets the content item type.
- ///
+ ///
public PublishedItemType ItemType { get; }
- ///
- /// Gets the aliases of the content types participating in the composition.
- ///
+ ///
public HashSet CompositionAliases { get; }
- ///
- /// Gets the content variations of the content type.
- ///
+ ///
public ContentVariation Variations { get; }
#endregion
#region Properties
- ///
- /// Gets the content type properties.
- ///
- public IEnumerable PropertyTypes => _propertyTypes;
+ ///
+ public IEnumerable PropertyTypes => _propertyTypes;
- ///
- /// Gets a property type index.
- ///
- /// The alias is case-insensitive. This is the only place where alias strings are compared.
+ ///
public int GetPropertyIndex(string alias)
{
if (_indexes.TryGetValue(alias, out var index)) return index; // fastest
@@ -150,10 +148,8 @@ namespace Umbraco.Core.Models.PublishedContent
// virtual for unit tests
// TODO: explain why
- ///
- /// Gets a property type.
- ///
- public virtual PublishedPropertyType GetPropertyType(string alias)
+ ///
+ public virtual IPublishedPropertyType GetPropertyType(string alias)
{
var index = GetPropertyIndex(alias);
return GetPropertyType(index);
@@ -161,17 +157,13 @@ namespace Umbraco.Core.Models.PublishedContent
// virtual for unit tests
// TODO: explain why
- ///
- /// Gets a property type.
- ///
- public virtual PublishedPropertyType GetPropertyType(int index)
+ ///
+ public virtual IPublishedPropertyType GetPropertyType(int index)
{
return index >= 0 && index < _propertyTypes.Length ? _propertyTypes[index] : null;
}
- ///
- /// Gets a value indicating whether this content type is for an element.
- ///
+ ///
public bool IsElement { get; }
#endregion
diff --git a/src/Umbraco.Core/Models/PublishedContent/PublishedContentTypeFactory.cs b/src/Umbraco.Core/Models/PublishedContent/PublishedContentTypeFactory.cs
index 2ca3593b55..17a15a2536 100644
--- a/src/Umbraco.Core/Models/PublishedContent/PublishedContentTypeFactory.cs
+++ b/src/Umbraco.Core/Models/PublishedContent/PublishedContentTypeFactory.cs
@@ -26,37 +26,46 @@ namespace Umbraco.Core.Models.PublishedContent
}
///
- public PublishedContentType CreateContentType(IContentTypeComposition contentType)
+ public IPublishedContentType CreateContentType(IContentTypeComposition contentType)
{
return new PublishedContentType(contentType, this);
}
- // for tests
- internal PublishedContentType CreateContentType(int id, string alias, IEnumerable propertyTypes, ContentVariation variations = ContentVariation.Nothing, bool isElement = false)
+ ///
+ /// This method is for tests and is not intended to be used directly from application code.
+ ///
+ /// Values are assumed to be consisted and are not checked.
+ internal IPublishedContentType CreateContentType(int id, string alias, Func> propertyTypes, ContentVariation variations = ContentVariation.Nothing, bool isElement = false)
{
return new PublishedContentType(id, alias, PublishedItemType.Content, Enumerable.Empty(), propertyTypes, variations, isElement);
}
- // for tests
- internal PublishedContentType CreateContentType(int id, string alias, IEnumerable compositionAliases, IEnumerable propertyTypes, ContentVariation variations = ContentVariation.Nothing, bool isElement = false)
+ ///
+ /// This method is for tests and is not intended to be used directly from application code.
+ ///
+ /// Values are assumed to be consisted and are not checked.
+ internal IPublishedContentType CreateContentType(int id, string alias, IEnumerable compositionAliases, Func> propertyTypes, ContentVariation variations = ContentVariation.Nothing, bool isElement = false)
{
return new PublishedContentType(id, alias, PublishedItemType.Content, compositionAliases, propertyTypes, variations, isElement);
}
///
- public PublishedPropertyType CreatePropertyType(PublishedContentType contentType, PropertyType propertyType)
+ public IPublishedPropertyType CreatePropertyType(IPublishedContentType contentType, PropertyType propertyType)
{
return new PublishedPropertyType(contentType, propertyType, _propertyValueConverters, _publishedModelFactory, this);
}
///
- public PublishedPropertyType CreatePropertyType(PublishedContentType contentType, string propertyTypeAlias, int dataTypeId, ContentVariation variations = ContentVariation.Nothing)
+ public IPublishedPropertyType CreatePropertyType(IPublishedContentType contentType, string propertyTypeAlias, int dataTypeId, ContentVariation variations = ContentVariation.Nothing)
{
return new PublishedPropertyType(contentType, propertyTypeAlias, dataTypeId, true, variations, _propertyValueConverters, _publishedModelFactory, this);
}
- // for tests
- internal PublishedPropertyType CreatePropertyType(string propertyTypeAlias, int dataTypeId, bool umbraco = false, ContentVariation variations = ContentVariation.Nothing)
+ ///
+ /// This method is for tests and is not intended to be used directly from application code.
+ ///
+ /// Values are assumed to be consisted and are not checked.
+ internal IPublishedPropertyType CreatePropertyType(string propertyTypeAlias, int dataTypeId, bool umbraco = false, ContentVariation variations = ContentVariation.Nothing)
{
return new PublishedPropertyType(propertyTypeAlias, dataTypeId, umbraco, variations, _propertyValueConverters, _publishedModelFactory, this);
}
diff --git a/src/Umbraco.Core/Models/PublishedContent/PublishedContentWrapped.cs b/src/Umbraco.Core/Models/PublishedContent/PublishedContentWrapped.cs
index 8bf8cec244..fb41c95419 100644
--- a/src/Umbraco.Core/Models/PublishedContent/PublishedContentWrapped.cs
+++ b/src/Umbraco.Core/Models/PublishedContent/PublishedContentWrapped.cs
@@ -41,7 +41,7 @@ namespace Umbraco.Core.Models.PublishedContent
#region ContentType
///
- public virtual PublishedContentType ContentType => _content.ContentType;
+ public virtual IPublishedContentType ContentType => _content.ContentType;
#endregion
@@ -96,12 +96,6 @@ namespace Umbraco.Core.Models.PublishedContent
///
public virtual string Url => _content.Url;
- ///
- public virtual string GetUrl(string culture = null) => _content.GetUrl(culture);
-
- ///
- public PublishedCultureInfo GetCulture(string culture = null) => _content.GetCulture(culture);
-
///
public IReadOnlyDictionary Cultures => _content.Cultures;
@@ -124,6 +118,9 @@ namespace Umbraco.Core.Models.PublishedContent
///
public virtual IEnumerable Children => _content.Children;
+ ///
+ public virtual IEnumerable ChildrenForAllCultures => _content.ChildrenForAllCultures;
+
#endregion
#region Properties
diff --git a/src/Umbraco.Core/Models/PublishedContent/PublishedElementWrapped.cs b/src/Umbraco.Core/Models/PublishedContent/PublishedElementWrapped.cs
index 1989ac2caf..481b9bd5d2 100644
--- a/src/Umbraco.Core/Models/PublishedContent/PublishedElementWrapped.cs
+++ b/src/Umbraco.Core/Models/PublishedContent/PublishedElementWrapped.cs
@@ -28,7 +28,7 @@ namespace Umbraco.Core.Models.PublishedContent
public IPublishedElement Unwrap() => _content;
///
- public PublishedContentType ContentType => _content.ContentType;
+ public IPublishedContentType ContentType => _content.ContentType;
///
public Guid Key => _content.Key;
diff --git a/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyBase.cs b/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyBase.cs
index 5f374f8bc8..e11d2391ec 100644
--- a/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyBase.cs
+++ b/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyBase.cs
@@ -12,7 +12,7 @@ namespace Umbraco.Core.Models.PublishedContent
///
/// Initializes a new instance of the class.
///
- protected PublishedPropertyBase(PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel)
+ protected PublishedPropertyBase(IPublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel)
{
PropertyType = propertyType ?? throw new ArgumentNullException(nameof(propertyType));
ReferenceCacheLevel = referenceCacheLevel;
@@ -42,7 +42,7 @@ namespace Umbraco.Core.Models.PublishedContent
///
/// Gets the property type.
///
- public PublishedPropertyType PropertyType { get; }
+ public IPublishedPropertyType PropertyType { get; }
///
/// Gets the property reference cache level.
diff --git a/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyType.cs b/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyType.cs
index 68892fd79a..0c2e62770e 100644
--- a/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyType.cs
+++ b/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyType.cs
@@ -10,10 +10,8 @@ namespace Umbraco.Core.Models.PublishedContent
///
/// Instances of the class are immutable, ie
/// if the property type changes, then a new class needs to be created.
- public class PublishedPropertyType
+ public class PublishedPropertyType : IPublishedPropertyType
{
- // TODO: API design review, should this be an interface?
-
private readonly IPublishedModelFactory _publishedModelFactory;
private readonly PropertyValueConverterCollection _propertyValueConverters;
private readonly object _locker = new object();
@@ -32,7 +30,7 @@ namespace Umbraco.Core.Models.PublishedContent
///
/// The new published property type belongs to the published content type.
///
- public PublishedPropertyType(PublishedContentType contentType, PropertyType propertyType, PropertyValueConverterCollection propertyValueConverters, IPublishedModelFactory publishedModelFactory, IPublishedContentTypeFactory factory)
+ public PublishedPropertyType(IPublishedContentType contentType, PropertyType propertyType, PropertyValueConverterCollection propertyValueConverters, IPublishedModelFactory publishedModelFactory, IPublishedContentTypeFactory factory)
: this(propertyType.Alias, propertyType.DataTypeId, true, propertyType.Variations, propertyValueConverters, publishedModelFactory, factory)
{
ContentType = contentType ?? throw new ArgumentNullException(nameof(contentType));
@@ -45,7 +43,7 @@ namespace Umbraco.Core.Models.PublishedContent
/// Values are assumed to be consisted and are not checked.
/// The new published property type belongs to the published content type.
///
- public PublishedPropertyType(PublishedContentType contentType, string propertyTypeAlias, int dataTypeId, bool isUserProperty, ContentVariation variations, PropertyValueConverterCollection propertyValueConverters, IPublishedModelFactory publishedModelFactory, IPublishedContentTypeFactory factory)
+ public PublishedPropertyType(IPublishedContentType contentType, string propertyTypeAlias, int dataTypeId, bool isUserProperty, ContentVariation variations, PropertyValueConverterCollection propertyValueConverters, IPublishedModelFactory publishedModelFactory, IPublishedContentTypeFactory factory)
: this(propertyTypeAlias, dataTypeId, isUserProperty, variations, propertyValueConverters, publishedModelFactory, factory)
{
ContentType = contentType ?? throw new ArgumentNullException(nameof(contentType));
@@ -75,37 +73,22 @@ namespace Umbraco.Core.Models.PublishedContent
#region Property type
- ///
- /// Gets the published content type containing the property type.
- ///
- public PublishedContentType ContentType { get; internal set; } // internally set by PublishedContentType constructor
+ ///
+ public IPublishedContentType ContentType { get; internal set; } // internally set by PublishedContentType constructor
- ///
- /// Gets the data type.
- ///
+ ///
public PublishedDataType DataType { get; }
- ///
- /// Gets property type alias.
- ///
+ ///
public string Alias { get; }
- ///
- /// Gets the property editor alias.
- ///
+ ///
public string EditorAlias => DataType.EditorAlias;
- ///
- /// Gets a value indicating whether the property is a user content property.
- ///
- /// A non-user content property is a property that has been added to a
- /// published content type by Umbraco but does not corresponds to a user-defined
- /// published property.
+ ///
public bool IsUserProperty { get; }
- ///
- /// Gets the content variations of the property type.
- ///
+ ///
public ContentVariation Variations { get; }
#endregion
@@ -193,10 +176,7 @@ namespace Umbraco.Core.Models.PublishedContent
_modelClrType = _converter == null ? typeof (object) : _converter.GetPropertyValueType(this);
}
- ///
- /// Determines whether a value is an actual value, or not a value.
- ///
- /// Used by property.HasValue and, for instance, in fallback scenarios.
+ ///
public bool? IsValue(object value, PropertyValueLevel level)
{
if (!_initialized) Initialize();
@@ -209,9 +189,7 @@ namespace Umbraco.Core.Models.PublishedContent
return value != null && (!(value is string) || string.IsNullOrWhiteSpace((string) value) == false);
}
- ///
- /// Gets the property cache level.
- ///
+ ///
public PropertyCacheLevel CacheLevel
{
get
@@ -221,13 +199,7 @@ namespace Umbraco.Core.Models.PublishedContent
}
}
- ///
- /// Converts the source value into the intermediate value.
- ///
- /// The published element owning the property.
- /// The source value.
- /// A value indicating whether content should be considered draft.
- /// The intermediate value.
+ ///
public object ConvertSourceToInter(IPublishedElement owner, object source, bool preview)
{
if (!_initialized) Initialize();
@@ -238,14 +210,7 @@ namespace Umbraco.Core.Models.PublishedContent
: source;
}
- ///
- /// Converts the intermediate value into the object value.
- ///
- /// The published element owning the property.
- /// The reference cache level.
- /// The intermediate value.
- /// A value indicating whether content should be considered draft.
- /// The object value.
+ ///
public object ConvertInterToObject(IPublishedElement owner, PropertyCacheLevel referenceCacheLevel, object inter, bool preview)
{
if (!_initialized) Initialize();
@@ -256,17 +221,7 @@ namespace Umbraco.Core.Models.PublishedContent
: inter;
}
- ///
- /// Converts the intermediate value into the XPath value.
- ///
- /// The published element owning the property.
- /// The reference cache level.
- /// The intermediate value.
- /// A value indicating whether content should be considered draft.
- /// The XPath value.
- ///
- /// The XPath value can be either a string or an XPathNavigator.
- ///
+ ///
public object ConvertInterToXPath(IPublishedElement owner, PropertyCacheLevel referenceCacheLevel, object inter, bool preview)
{
if (!_initialized) Initialize();
@@ -282,13 +237,7 @@ namespace Umbraco.Core.Models.PublishedContent
return inter.ToString().Trim();
}
- ///
- /// Gets the property model CLR type.
- ///
- ///
- /// The model CLR type may be a type, or may contain types.
- /// For the actual CLR type, see .
- ///
+ ///
public Type ModelClrType
{
get
@@ -298,14 +247,7 @@ namespace Umbraco.Core.Models.PublishedContent
}
}
- ///
- /// Gets the property CLR type.
- ///
- ///
- /// Returns the actual CLR type which does not contain types.
- /// Mapping from may throw if some instances
- /// could not be mapped to actual CLR types.
- ///
+ ///
public Type ClrType
{
get
diff --git a/src/Umbraco.Core/Models/PublishedContent/RawValueProperty.cs b/src/Umbraco.Core/Models/PublishedContent/RawValueProperty.cs
index 7469222ab0..10f999532f 100644
--- a/src/Umbraco.Core/Models/PublishedContent/RawValueProperty.cs
+++ b/src/Umbraco.Core/Models/PublishedContent/RawValueProperty.cs
@@ -38,7 +38,7 @@ namespace Umbraco.Core.Models.PublishedContent
public override object GetXPathValue(string culture = null, string segment = null)
=> string.IsNullOrEmpty(culture) & string.IsNullOrEmpty(segment) ? _xpathValue.Value : null;
- public RawValueProperty(PublishedPropertyType propertyType, IPublishedElement content, object sourceValue, bool isPreviewing = false)
+ public RawValueProperty(IPublishedPropertyType propertyType, IPublishedElement content, object sourceValue, bool isPreviewing = false)
: base(propertyType, PropertyCacheLevel.Unknown) // cache level is ignored
{
if (propertyType.Variations != ContentVariation.Nothing)
diff --git a/src/Umbraco.Web/Routing/UrlProviderMode.cs b/src/Umbraco.Core/Models/PublishedContent/UrlMode.cs
similarity index 63%
rename from src/Umbraco.Web/Routing/UrlProviderMode.cs
rename to src/Umbraco.Core/Models/PublishedContent/UrlMode.cs
index ac29aed3fb..4cd6a680f4 100644
--- a/src/Umbraco.Web/Routing/UrlProviderMode.cs
+++ b/src/Umbraco.Core/Models/PublishedContent/UrlMode.cs
@@ -1,14 +1,14 @@
-namespace Umbraco.Web.Routing
+namespace Umbraco.Core.Models.PublishedContent
{
///
- /// Specifies the type of urls that the url provider should produce, Auto is the default
+ /// Specifies the type of urls that the url provider should produce, Auto is the default.
///
- ///
- /// The Relative option can lead to invalid results when combined with hostnames, but it is the only way to reproduce
- /// the true, pre-4.10, always-relative behavior of Umbraco.
- ///
- public enum UrlProviderMode
+ public enum UrlMode
{
+ ///
+ /// Indicates that the url provider should do what it has been configured to do.
+ ///
+ Default = 0,
///
/// Indicates that the url provider should produce relative urls exclusively.
diff --git a/src/Umbraco.Core/Models/UserExtensions.cs b/src/Umbraco.Core/Models/UserExtensions.cs
index 0f83cf78a4..cf7df4fb86 100644
--- a/src/Umbraco.Core/Models/UserExtensions.cs
+++ b/src/Umbraco.Core/Models/UserExtensions.cs
@@ -193,19 +193,6 @@ namespace Umbraco.Core.Models
return ContentPermissionsHelper.HasPathAccess(entity.Path, user.CalculateMediaStartNodeIds(entityService), Constants.System.RecycleBinMedia);
}
- internal static bool IsInBranchOfStartNode(this IUser user, IUmbracoEntity entity, IEntityService entityService, int recycleBinId, out bool hasPathAccess)
- {
- switch (recycleBinId)
- {
- case Constants.System.RecycleBinMedia:
- return ContentPermissionsHelper.IsInBranchOfStartNode(entity.Path, user.CalculateMediaStartNodeIds(entityService), user.GetMediaStartNodePaths(entityService), out hasPathAccess);
- case Constants.System.RecycleBinContent:
- return ContentPermissionsHelper.IsInBranchOfStartNode(entity.Path, user.CalculateContentStartNodeIds(entityService), user.GetContentStartNodePaths(entityService), out hasPathAccess);
- default:
- throw new NotSupportedException("Path access is only determined on content or media");
- }
- }
-
///
/// Determines whether this user has access to view sensitive data
///
diff --git a/src/Umbraco.Core/Persistence/Factories/PropertyGroupFactory.cs b/src/Umbraco.Core/Persistence/Factories/PropertyGroupFactory.cs
index c134748047..db8e2b20d9 100644
--- a/src/Umbraco.Core/Persistence/Factories/PropertyGroupFactory.cs
+++ b/src/Umbraco.Core/Persistence/Factories/PropertyGroupFactory.cs
@@ -54,6 +54,7 @@ namespace Umbraco.Core.Persistence.Factories
propertyType.Alias = typeDto.Alias;
propertyType.DataTypeId = typeDto.DataTypeId;
+ propertyType.DataTypeKey = typeDto.DataTypeDto.NodeDto.UniqueId;
propertyType.Description = typeDto.Description;
propertyType.Id = typeDto.Id;
propertyType.Key = typeDto.UniqueId;
diff --git a/src/Umbraco.Core/Persistence/Mappers/AuditItemMapper.cs b/src/Umbraco.Core/Persistence/Mappers/AuditItemMapper.cs
index 853cd9f99e..48e7afdc7e 100644
--- a/src/Umbraco.Core/Persistence/Mappers/AuditItemMapper.cs
+++ b/src/Umbraco.Core/Persistence/Mappers/AuditItemMapper.cs
@@ -18,7 +18,8 @@ namespace Umbraco.Core.Persistence.Mappers
DefineMap(nameof(AuditItem.Id), nameof(LogDto.NodeId));
DefineMap(nameof(AuditItem.CreateDate), nameof(LogDto.Datestamp));
DefineMap(nameof(AuditItem.UserId), nameof(LogDto.UserId));
- DefineMap(nameof(AuditItem.AuditType), nameof(LogDto.Header));
+ // we cannot map that one - because AuditType is an enum but Header is a string
+ //DefineMap(nameof(AuditItem.AuditType), nameof(LogDto.Header));
DefineMap(nameof(AuditItem.Comment), nameof(LogDto.Comment));
}
}
diff --git a/src/Umbraco.Core/Persistence/Querying/ModelToSqlExpressionVisitor.cs b/src/Umbraco.Core/Persistence/Querying/ModelToSqlExpressionVisitor.cs
index 03d82a345f..c87937e41e 100644
--- a/src/Umbraco.Core/Persistence/Querying/ModelToSqlExpressionVisitor.cs
+++ b/src/Umbraco.Core/Persistence/Querying/ModelToSqlExpressionVisitor.cs
@@ -85,6 +85,17 @@ namespace Umbraco.Core.Persistence.Querying
// I'm just unsure right now due to time constraints how to make it correct. It won't matter right now and has been working already with this bug but I've
// only just discovered what it is actually doing.
+ // TODO
+ // in most cases we want to convert the value to a plain object,
+ // but for in some rare cases, we may want to do it differently,
+ // for instance a Models.AuditType (an enum) may in some cases
+ // need to be converted to its string value.
+ // but - we cannot have specific code here, really - and how would
+ // we configure this? is it even possible?
+ /*
+ var toString = typeof(object).GetMethod("ToString");
+ var member = Expression.Call(m, toString);
+ */
var member = Expression.Convert(m, typeof(object));
var lambda = Expression.Lambda>(member);
var getter = lambda.Compile();
diff --git a/src/Umbraco.Core/Persistence/Repositories/IAuditRepository.cs b/src/Umbraco.Core/Persistence/Repositories/IAuditRepository.cs
index 7c8a82bb85..b2dd6a3297 100644
--- a/src/Umbraco.Core/Persistence/Repositories/IAuditRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/IAuditRepository.cs
@@ -33,5 +33,7 @@ namespace Umbraco.Core.Persistence.Repositories
Direction orderDirection,
AuditType[] auditTypeFilter,
IQuery customFilter);
+
+ IEnumerable Get(AuditType type, IQuery query);
}
}
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/AuditEntryRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/AuditEntryRepository.cs
index 1486935e2a..c3d34cc3e9 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/AuditEntryRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/AuditEntryRepository.cs
@@ -100,7 +100,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
///
protected override void PersistNewItem(IAuditEntry entity)
{
- ((EntityBase) entity).AddingEntity();
+ entity.AddingEntity();
var dto = AuditEntryFactory.BuildDto(entity);
Database.Insert(dto);
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/AuditRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/AuditRepository.cs
index cda89fd89a..c25328b10c 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/AuditRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/AuditRepository.cs
@@ -74,6 +74,18 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
return dtos.Select(x => new AuditItem(x.NodeId, Enum.Parse(x.Header), x.UserId ?? Constants.Security.UnknownUserId, x.EntityType, x.Comment, x.Parameters)).ToList();
}
+ public IEnumerable Get(AuditType type, IQuery query)
+ {
+ var sqlClause = GetBaseQuery(false)
+ .Where(x => x.Header == type.ToString());
+ var translator = new SqlTranslator(sqlClause, query);
+ var sql = translator.Translate();
+
+ var dtos = Database.Fetch(sql);
+
+ return dtos.Select(x => new AuditItem(x.NodeId, Enum.Parse(x.Header), x.UserId ?? Constants.Security.UnknownUserId, x.EntityType, x.Comment, x.Parameters)).ToList();
+ }
+
protected override Sql GetBaseQuery(bool isCount)
{
var sql = SqlContext.Sql();
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/ConsentRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/ConsentRepository.cs
index 8df9bf686d..57d5dfa864 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/ConsentRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/ConsentRepository.cs
@@ -69,7 +69,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
///
protected override void PersistNewItem(IConsent entity)
{
- ((EntityBase) entity).AddingEntity();
+ entity.AddingEntity();
var dto = ConsentFactory.BuildDto(entity);
Database.Insert(dto);
@@ -80,7 +80,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
///
protected override void PersistUpdatedItem(IConsent entity)
{
- ((EntityBase) entity).UpdatingEntity();
+ entity.UpdatingEntity();
var dto = ConsentFactory.BuildDto(entity);
Database.Update(dto);
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/ContentTypeCommonRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/ContentTypeCommonRepository.cs
index ccafb9f771..593f1b4f32 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/ContentTypeCommonRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/ContentTypeCommonRepository.cs
@@ -143,7 +143,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
templateDtoIx++;
if (!templates.TryGetValue(allowedDto.TemplateNodeId, out var template)) continue;
allowedTemplates.Add(template);
-
+
if (allowedDto.IsDefault)
defaultTemplateId = template.Id;
}
@@ -188,10 +188,11 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
var groupDtos = Database.Fetch(sql1);
var sql2 = Sql()
- .Select(r => r.Select(x => x.DataTypeDto))
+ .Select(r => r.Select(x => x.DataTypeDto, r1 => r1.Select(x => x.NodeDto)))
.AndSelect()
.From()
.InnerJoin().On((pt, dt) => pt.DataTypeId == dt.NodeId)
+ .InnerJoin().On((dt, n) => dt.NodeId == n.NodeId)
.InnerJoin().On((pt, ct) => pt.ContentTypeId == ct.NodeId)
.LeftJoin().On((pt, ptg) => pt.PropertyTypeGroupId == ptg.Id)
.LeftJoin().On((pt, mpt) => pt.Id == mpt.PropertyTypeId)
@@ -290,6 +291,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
{
Description = dto.Description,
DataTypeId = dto.DataTypeId,
+ DataTypeKey = dto.DataTypeDto.NodeDto.UniqueId,
Id = dto.Id,
Key = dto.UniqueId,
Mandatory = dto.Mandatory,
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/ContentTypeRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/ContentTypeRepository.cs
index 98ddcdcb17..9d77eb0990 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/ContentTypeRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/ContentTypeRepository.cs
@@ -5,6 +5,7 @@ using NPoco;
using Umbraco.Core.Cache;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
+using Umbraco.Core.Models.Entities;
using Umbraco.Core.Persistence.Dtos;
using Umbraco.Core.Persistence.Querying;
using Umbraco.Core.Persistence.SqlSyntax;
@@ -230,7 +231,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
throw ex;
}
- ((ContentType)entity).AddingEntity();
+ entity.AddingEntity();
PersistNewBaseContentType(entity);
PersistTemplates(entity, false);
@@ -270,7 +271,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
ValidateAlias(entity);
//Updates Modified date
- ((ContentType)entity).UpdatingEntity();
+ entity.UpdatingEntity();
//Look up parent to get and set the correct Path if ParentId has changed
if (entity.IsPropertyDirty("ParentId"))
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/ContentTypeRepositoryBase.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/ContentTypeRepositoryBase.cs
index 591fa2b660..22c9244d8f 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/ContentTypeRepositoryBase.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/ContentTypeRepositoryBase.cs
@@ -1013,8 +1013,9 @@ AND umbracoNode.id <> @id",
if (propertyType.PropertyEditorAlias.IsNullOrWhiteSpace() == false)
{
var sql = Sql()
- .SelectAll()
+ .Select(dt => dt.Select(x => x.NodeDto))
.From()
+ .InnerJoin().On((dt, n) => dt.NodeId == n.NodeId)
.Where("propertyEditorAlias = @propertyEditorAlias", new { propertyEditorAlias = propertyType.PropertyEditorAlias })
.OrderBy(typeDto => typeDto.NodeId);
var datatype = Database.FirstOrDefault(sql);
@@ -1022,6 +1023,7 @@ AND umbracoNode.id <> @id",
if (datatype != null)
{
propertyType.DataTypeId = datatype.NodeId;
+ propertyType.DataTypeKey = datatype.NodeDto.UniqueId;
}
else
{
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/DataTypeRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/DataTypeRepository.cs
index 6dca479a92..45aa7603a3 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/DataTypeRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/DataTypeRepository.cs
@@ -9,6 +9,7 @@ using Umbraco.Core.Events;
using Umbraco.Core.Exceptions;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
+using Umbraco.Core.Models.Entities;
using Umbraco.Core.Persistence.Dtos;
using Umbraco.Core.Persistence.Factories;
using Umbraco.Core.Persistence.Querying;
@@ -106,7 +107,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
protected override void PersistNewItem(IDataType entity)
{
- ((DataType)entity).AddingEntity();
+ entity.AddingEntity();
//ensure a datatype has a unique name before creating it
entity.Name = EnsureUniqueNodeName(entity.Name);
@@ -174,7 +175,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
}
//Updates Modified date
- ((DataType)entity).UpdatingEntity();
+ entity.UpdatingEntity();
//Look up parent to get and set the correct Path if ParentId has changed
if (entity.IsPropertyDirty("ParentId"))
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/DictionaryRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/DictionaryRepository.cs
index be1e28fcc1..0b58663952 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/DictionaryRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/DictionaryRepository.cs
@@ -148,7 +148,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
protected override void PersistUpdatedItem(IDictionaryItem entity)
{
- ((EntityBase)entity).UpdatingEntity();
+ entity.UpdatingEntity();
foreach (var translation in entity.Translations)
translation.Value = translation.Value.ToValidXmlString();
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/DocumentRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/DocumentRepository.cs
index 6c08e05995..30a2927cc8 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/DocumentRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/DocumentRepository.cs
@@ -6,6 +6,7 @@ using Umbraco.Core.Cache;
using Umbraco.Core.Exceptions;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
+using Umbraco.Core.Models.Entities;
using Umbraco.Core.Models.Membership;
using Umbraco.Core.Persistence.Dtos;
using Umbraco.Core.Persistence.Factories;
@@ -205,7 +206,10 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
"DELETE FROM " + Constants.DatabaseSchema.Tables.ContentVersionCultureVariation + " WHERE versionId IN (SELECT id FROM " + Constants.DatabaseSchema.Tables.ContentVersion + " WHERE nodeId = @id)",
"DELETE FROM " + Constants.DatabaseSchema.Tables.ContentVersion + " WHERE nodeId = @id",
"DELETE FROM " + Constants.DatabaseSchema.Tables.Content + " WHERE nodeId = @id",
+ "DELETE FROM " + Constants.DatabaseSchema.Tables.AccessRule + " WHERE accessId IN (SELECT id FROM " + Constants.DatabaseSchema.Tables.Access + " WHERE nodeId = @id OR loginNodeId = @id OR noAccessNodeId = @id)",
"DELETE FROM " + Constants.DatabaseSchema.Tables.Access + " WHERE nodeId = @id",
+ "DELETE FROM " + Constants.DatabaseSchema.Tables.Access + " WHERE loginNodeId = @id",
+ "DELETE FROM " + Constants.DatabaseSchema.Tables.Access + " WHERE noAccessNodeId = @id",
"DELETE FROM " + Constants.DatabaseSchema.Tables.Node + " WHERE id = @id"
};
return list;
@@ -260,21 +264,16 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
protected override void PersistNewItem(IContent entity)
{
- // TODO: https://github.com/umbraco/Umbraco-CMS/issues/4234 - sort out IContent vs Content
- // however, it's not just so we have access to AddingEntity
- // there are tons of things at the end of the methods, that can only work with a true Content
- // and basically, the repository requires a Content, not an IContent
- var content = (Content)entity;
+ entity.AddingEntity();
- content.AddingEntity();
- var publishing = content.PublishedState == PublishedState.Publishing;
+ var publishing = entity.PublishedState == PublishedState.Publishing;
// ensure that the default template is assigned
if (entity.TemplateId.HasValue == false)
entity.TemplateId = entity.ContentType.DefaultTemplate?.Id;
// sanitize names
- SanitizeNames(content, publishing);
+ SanitizeNames(entity, publishing);
// ensure that strings don't contain characters that are invalid in xml
// TODO: do we really want to keep doing this here?
@@ -324,11 +323,11 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
contentVersionDto.NodeId = nodeDto.NodeId;
contentVersionDto.Current = !publishing;
Database.Insert(contentVersionDto);
- content.VersionId = contentVersionDto.Id;
+ entity.VersionId = contentVersionDto.Id;
// persist the document version dto
var documentVersionDto = dto.DocumentVersionDto;
- documentVersionDto.Id = content.VersionId;
+ documentVersionDto.Id = entity.VersionId;
if (publishing)
documentVersionDto.Published = true;
Database.Insert(documentVersionDto);
@@ -336,62 +335,62 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
// and again in case we're publishing immediately
if (publishing)
{
- content.PublishedVersionId = content.VersionId;
+ entity.PublishedVersionId = entity.VersionId;
contentVersionDto.Id = 0;
contentVersionDto.Current = true;
- contentVersionDto.Text = content.Name;
+ contentVersionDto.Text = entity.Name;
Database.Insert(contentVersionDto);
- content.VersionId = contentVersionDto.Id;
+ entity.VersionId = contentVersionDto.Id;
- documentVersionDto.Id = content.VersionId;
+ documentVersionDto.Id = entity.VersionId;
documentVersionDto.Published = false;
Database.Insert(documentVersionDto);
}
// persist the property data
- var propertyDataDtos = PropertyFactory.BuildDtos(content.ContentType.Variations, content.VersionId, content.PublishedVersionId, entity.Properties, LanguageRepository, out var edited, out var editedCultures);
+ var propertyDataDtos = PropertyFactory.BuildDtos(entity.ContentType.Variations, entity.VersionId, entity.PublishedVersionId, entity.Properties, LanguageRepository, out var edited, out var editedCultures);
foreach (var propertyDataDto in propertyDataDtos)
Database.Insert(propertyDataDto);
// if !publishing, we may have a new name != current publish name,
// also impacts 'edited'
- if (!publishing && content.PublishName != content.Name)
+ if (!publishing && entity.PublishName != entity.Name)
edited = true;
// persist the document dto
// at that point, when publishing, the entity still has its old Published value
// so we need to explicitly update the dto to persist the correct value
- if (content.PublishedState == PublishedState.Publishing)
+ if (entity.PublishedState == PublishedState.Publishing)
dto.Published = true;
dto.NodeId = nodeDto.NodeId;
- content.Edited = dto.Edited = !dto.Published || edited; // if not published, always edited
+ entity.Edited = dto.Edited = !dto.Published || edited; // if not published, always edited
Database.Insert(dto);
//insert the schedule
- PersistContentSchedule(content, false);
+ PersistContentSchedule(entity, false);
// persist the variations
- if (content.ContentType.VariesByCulture())
+ if (entity.ContentType.VariesByCulture())
{
// bump dates to align cultures to version
if (publishing)
- content.AdjustDates(contentVersionDto.VersionDate);
+ entity.AdjustDates(contentVersionDto.VersionDate);
// names also impact 'edited'
// ReSharper disable once UseDeconstruction
- foreach (var cultureInfo in content.CultureInfos)
- if (cultureInfo.Name != content.GetPublishName(cultureInfo.Culture))
+ foreach (var cultureInfo in entity.CultureInfos)
+ if (cultureInfo.Name != entity.GetPublishName(cultureInfo.Culture))
(editedCultures ?? (editedCultures = new HashSet(StringComparer.OrdinalIgnoreCase))).Add(cultureInfo.Culture);
// insert content variations
- Database.BulkInsertRecords(GetContentVariationDtos(content, publishing));
+ Database.BulkInsertRecords(GetContentVariationDtos(entity, publishing));
// insert document variations
- Database.BulkInsertRecords(GetDocumentVariationDtos(content, publishing, editedCultures));
+ Database.BulkInsertRecords(GetDocumentVariationDtos(entity, publishing, editedCultures));
}
// refresh content
- content.SetCultureEdited(editedCultures);
+ entity.SetCultureEdited(editedCultures);
// trigger here, before we reset Published etc
OnUowRefreshedEntity(new ScopedEntityEventArgs(AmbientScope, entity));
@@ -399,23 +398,23 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
// flip the entity's published property
// this also flips its published state
// note: what depends on variations (eg PublishNames) is managed directly by the content
- if (content.PublishedState == PublishedState.Publishing)
+ if (entity.PublishedState == PublishedState.Publishing)
{
- content.Published = true;
- content.PublishTemplateId = content.TemplateId;
- content.PublisherId = content.WriterId;
- content.PublishName = content.Name;
- content.PublishDate = content.UpdateDate;
+ entity.Published = true;
+ entity.PublishTemplateId = entity.TemplateId;
+ entity.PublisherId = entity.WriterId;
+ entity.PublishName = entity.Name;
+ entity.PublishDate = entity.UpdateDate;
SetEntityTags(entity, _tagRepository);
}
- else if (content.PublishedState == PublishedState.Unpublishing)
+ else if (entity.PublishedState == PublishedState.Unpublishing)
{
- content.Published = false;
- content.PublishTemplateId = null;
- content.PublisherId = null;
- content.PublishName = null;
- content.PublishDate = null;
+ entity.Published = false;
+ entity.PublishTemplateId = null;
+ entity.PublisherId = null;
+ entity.PublishName = null;
+ entity.PublishDate = null;
ClearEntityTags(entity, _tagRepository);
}
@@ -437,34 +436,33 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
protected override void PersistUpdatedItem(IContent entity)
{
- // however, it's not just so we have access to AddingEntity
- // there are tons of things at the end of the methods, that can only work with a true Content
- // and basically, the repository requires a Content, not an IContent
- var content = (Content)entity;
+ var entityBase = entity as EntityBase;
+ var isEntityDirty = entityBase != null && entityBase.IsDirty();
// check if we need to make any database changes at all
- if ((content.PublishedState == PublishedState.Published || content.PublishedState == PublishedState.Unpublished)
- && !content.IsEntityDirty() && !content.IsAnyUserPropertyDirty())
+ if ((entity.PublishedState == PublishedState.Published || entity.PublishedState == PublishedState.Unpublished)
+ && !isEntityDirty && !entity.IsAnyUserPropertyDirty())
return; // no change to save, do nothing, don't even update dates
// whatever we do, we must check that we are saving the current version
- var version = Database.Fetch(SqlContext.Sql().Select().From().Where(x => x.Id == content.VersionId)).FirstOrDefault();
+ var version = Database.Fetch(SqlContext.Sql().Select().From().Where(x => x.Id == entity.VersionId)).FirstOrDefault();
if (version == null || !version.Current)
throw new InvalidOperationException("Cannot save a non-current version.");
// update
- content.UpdatingEntity();
- var publishing = content.PublishedState == PublishedState.Publishing;
+ entity.UpdatingEntity();
+
+ var publishing = entity.PublishedState == PublishedState.Publishing;
// check if we need to create a new version
- if (publishing && content.PublishedVersionId > 0)
+ if (publishing && entity.PublishedVersionId > 0)
{
// published version is not published anymore
- Database.Execute(Sql().Update(u => u.Set(x => x.Published, false)).Where(x => x.Id == content.PublishedVersionId));
+ Database.Execute(Sql().Update(u => u.Set(x => x.Published, false)).Where(x => x.Id == entity.PublishedVersionId));
}
// sanitize names
- SanitizeNames(content, publishing);
+ SanitizeNames(entity, publishing);
// ensure that strings don't contain characters that are invalid in xml
// TODO: do we really want to keep doing this here?
@@ -504,13 +502,13 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
// and, if publishing, insert new content & document version dtos
if (publishing)
{
- content.PublishedVersionId = content.VersionId;
+ entity.PublishedVersionId = entity.VersionId;
contentVersionDto.Id = 0; // want a new id
contentVersionDto.Current = true; // current version
- contentVersionDto.Text = content.Name;
+ contentVersionDto.Text = entity.Name;
Database.Insert(contentVersionDto);
- content.VersionId = documentVersionDto.Id = contentVersionDto.Id; // get the new id
+ entity.VersionId = documentVersionDto.Id = contentVersionDto.Id; // get the new id
documentVersionDto.Published = false; // non-published version
Database.Insert(documentVersionDto);
@@ -518,31 +516,31 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
// replace the property data (rather than updating)
// only need to delete for the version that existed, the new version (if any) has no property data yet
- var versionToDelete = publishing ? content.PublishedVersionId : content.VersionId;
+ var versionToDelete = publishing ? entity.PublishedVersionId : entity.VersionId;
var deletePropertyDataSql = Sql().Delete().Where(x => x.VersionId == versionToDelete);
Database.Execute(deletePropertyDataSql);
// insert property data
- var propertyDataDtos = PropertyFactory.BuildDtos(content.ContentType.Variations, content.VersionId, publishing ? content.PublishedVersionId : 0,
+ var propertyDataDtos = PropertyFactory.BuildDtos(entity.ContentType.Variations, entity.VersionId, publishing ? entity.PublishedVersionId : 0,
entity.Properties, LanguageRepository, out var edited, out var editedCultures);
foreach (var propertyDataDto in propertyDataDtos)
Database.Insert(propertyDataDto);
// if !publishing, we may have a new name != current publish name,
// also impacts 'edited'
- if (!publishing && content.PublishName != content.Name)
+ if (!publishing && entity.PublishName != entity.Name)
edited = true;
- if (content.ContentType.VariesByCulture())
+ if (entity.ContentType.VariesByCulture())
{
// bump dates to align cultures to version
if (publishing)
- content.AdjustDates(contentVersionDto.VersionDate);
+ entity.AdjustDates(contentVersionDto.VersionDate);
// names also impact 'edited'
// ReSharper disable once UseDeconstruction
- foreach (var cultureInfo in content.CultureInfos)
- if (cultureInfo.Name != content.GetPublishName(cultureInfo.Culture))
+ foreach (var cultureInfo in entity.CultureInfos)
+ if (cultureInfo.Name != entity.GetPublishName(cultureInfo.Culture))
{
edited = true;
(editedCultures ?? (editedCultures = new HashSet(StringComparer.OrdinalIgnoreCase))).Add(cultureInfo.Culture);
@@ -560,7 +558,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
Database.Execute(deleteContentVariations);
// replace the document version variations (rather than updating)
- var deleteDocumentVariations = Sql().Delete().Where(x => x.NodeId == content.Id);
+ var deleteDocumentVariations = Sql().Delete().Where(x => x.NodeId == entity.Id);
Database.Execute(deleteDocumentVariations);
// TODO: NPoco InsertBulk issue?
@@ -570,32 +568,32 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
// (same in PersistNewItem above)
// insert content variations
- Database.BulkInsertRecords(GetContentVariationDtos(content, publishing));
+ Database.BulkInsertRecords(GetContentVariationDtos(entity, publishing));
// insert document variations
- Database.BulkInsertRecords(GetDocumentVariationDtos(content, publishing, editedCultures));
+ Database.BulkInsertRecords(GetDocumentVariationDtos(entity, publishing, editedCultures));
}
// refresh content
- content.SetCultureEdited(editedCultures);
+ entity.SetCultureEdited(editedCultures);
// update the document dto
// at that point, when un/publishing, the entity still has its old Published value
// so we need to explicitly update the dto to persist the correct value
- if (content.PublishedState == PublishedState.Publishing)
+ if (entity.PublishedState == PublishedState.Publishing)
dto.Published = true;
- else if (content.PublishedState == PublishedState.Unpublishing)
+ else if (entity.PublishedState == PublishedState.Unpublishing)
dto.Published = false;
- content.Edited = dto.Edited = !dto.Published || edited; // if not published, always edited
+ entity.Edited = dto.Edited = !dto.Published || edited; // if not published, always edited
Database.Update(dto);
//update the schedule
- if (content.IsPropertyDirty("ContentSchedule"))
- PersistContentSchedule(content, true);
+ if (entity.IsPropertyDirty("ContentSchedule"))
+ PersistContentSchedule(entity, true);
// if entity is publishing, update tags, else leave tags there
// means that implicitly unpublished, or trashed, entities *still* have tags in db
- if (content.PublishedState == PublishedState.Publishing)
+ if (entity.PublishedState == PublishedState.Publishing)
SetEntityTags(entity, _tagRepository);
// trigger here, before we reset Published etc
@@ -603,23 +601,23 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
// flip the entity's published property
// this also flips its published state
- if (content.PublishedState == PublishedState.Publishing)
+ if (entity.PublishedState == PublishedState.Publishing)
{
- content.Published = true;
- content.PublishTemplateId = content.TemplateId;
- content.PublisherId = content.WriterId;
- content.PublishName = content.Name;
- content.PublishDate = content.UpdateDate;
+ entity.Published = true;
+ entity.PublishTemplateId = entity.TemplateId;
+ entity.PublisherId = entity.WriterId;
+ entity.PublishName = entity.Name;
+ entity.PublishDate = entity.UpdateDate;
SetEntityTags(entity, _tagRepository);
}
- else if (content.PublishedState == PublishedState.Unpublishing)
+ else if (entity.PublishedState == PublishedState.Unpublishing)
{
- content.Published = false;
- content.PublishTemplateId = null;
- content.PublisherId = null;
- content.PublishName = null;
- content.PublishDate = null;
+ entity.Published = false;
+ entity.PublishTemplateId = null;
+ entity.PublisherId = null;
+ entity.PublishName = null;
+ entity.PublishDate = null;
ClearEntityTags(entity, _tagRepository);
}
@@ -1335,7 +1333,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
#region Utilities
- private void SanitizeNames(Content content, bool publishing)
+ private void SanitizeNames(IContent content, bool publishing)
{
// a content item *must* have an invariant name, and invariant published name
// else we just cannot write the invariant rows (node, content version...) to the database
@@ -1400,7 +1398,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
x.NodeId != SqlTemplate.Arg("id"))
.OrderBy(x => x.LanguageId));
- private void EnsureVariantNamesAreUnique(Content content, bool publishing)
+ private void EnsureVariantNamesAreUnique(IContent content, bool publishing)
{
if (!EnsureUniqueNaming || !content.ContentType.VariesByCulture() || content.CultureInfos.Count == 0) return;
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/DomainRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/DomainRepository.cs
index 69523a860a..9aa28fb18a 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/DomainRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/DomainRepository.cs
@@ -6,6 +6,7 @@ using NPoco;
using Umbraco.Core.Cache;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
+using Umbraco.Core.Models.Entities;
using Umbraco.Core.Persistence.Dtos;
using Umbraco.Core.Persistence.Querying;
using Umbraco.Core.Scoping;
@@ -101,7 +102,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
if (languageExists == 0) throw new NullReferenceException("No language exists with id " + entity.LanguageId.Value);
}
- ((UmbracoDomain)entity).AddingEntity();
+ entity.AddingEntity();
var factory = new DomainModelFactory();
var dto = factory.BuildDto(entity);
@@ -120,7 +121,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
protected override void PersistUpdatedItem(IDomain entity)
{
- ((UmbracoDomain)entity).UpdatingEntity();
+ entity.UpdatingEntity();
var exists = Database.ExecuteScalar("SELECT COUNT(*) FROM umbracoDomain WHERE domainName = @domainName AND umbracoDomain.id <> @id",
new { domainName = entity.DomainName, id = entity.Id });
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/ExternalLoginRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/ExternalLoginRepository.cs
index 0fa48e5521..f708590ea8 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/ExternalLoginRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/ExternalLoginRepository.cs
@@ -139,7 +139,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
protected override void PersistNewItem(IIdentityUserLogin entity)
{
- ((EntityBase)entity).AddingEntity();
+ entity.AddingEntity();
var dto = ExternalLoginFactory.BuildDto(entity);
@@ -151,7 +151,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
protected override void PersistUpdatedItem(IIdentityUserLogin entity)
{
- ((EntityBase)entity).UpdatingEntity();
+ entity.UpdatingEntity();
var dto = ExternalLoginFactory.BuildDto(entity);
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/LanguageRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/LanguageRepository.cs
index 5a62c25df7..8429532b01 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/LanguageRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/LanguageRepository.cs
@@ -129,7 +129,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
if (entity.IsoCode.IsNullOrWhiteSpace() || entity.CultureName.IsNullOrWhiteSpace())
throw new InvalidOperationException("Cannot save a language without an ISO code and a culture name.");
- ((EntityBase) entity).AddingEntity();
+ entity.AddingEntity();
// deal with entity becoming the new default entity
if (entity.IsDefault)
@@ -156,7 +156,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
if (entity.IsoCode.IsNullOrWhiteSpace() || entity.CultureName.IsNullOrWhiteSpace())
throw new InvalidOperationException("Cannot save a language without an ISO code and a culture name.");
- ((EntityBase) entity).UpdatingEntity();
+ entity.UpdatingEntity();
if (entity.IsDefault)
{
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/MacroRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/MacroRepository.cs
index 565917e078..f0044e225d 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/MacroRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/MacroRepository.cs
@@ -132,7 +132,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
protected override void PersistNewItem(IMacro entity)
{
- ((EntityBase)entity).AddingEntity();
+ entity.AddingEntity();
var dto = MacroFactory.BuildDto(entity);
@@ -152,7 +152,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
protected override void PersistUpdatedItem(IMacro entity)
{
- ((EntityBase)entity).UpdatingEntity();
+ entity.UpdatingEntity();
;
var dto = MacroFactory.BuildDto(entity);
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/MediaRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/MediaRepository.cs
index c679a3cbd8..19706f0c03 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/MediaRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/MediaRepository.cs
@@ -7,6 +7,7 @@ using Umbraco.Core.Cache;
using Umbraco.Core.Exceptions;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
+using Umbraco.Core.Models.Entities;
using Umbraco.Core.Persistence.Dtos;
using Umbraco.Core.Persistence.Factories;
using Umbraco.Core.Persistence.Querying;
@@ -216,7 +217,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
protected override void PersistNewItem(IMedia entity)
{
var media = (Models.Media) entity;
- media.AddingEntity();
+ entity.AddingEntity();
// ensure unique name on the same level
entity.Name = EnsureUniqueNodeName(entity.ParentId, entity.Name);
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/MediaTypeRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/MediaTypeRepository.cs
index 281255e755..1abc75cf3a 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/MediaTypeRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/MediaTypeRepository.cs
@@ -5,6 +5,7 @@ using NPoco;
using Umbraco.Core.Cache;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
+using Umbraco.Core.Models.Entities;
using Umbraco.Core.Persistence.Dtos;
using Umbraco.Core.Persistence.Querying;
using Umbraco.Core.Scoping;
@@ -102,7 +103,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
protected override void PersistNewItem(IMediaType entity)
{
- ((MediaType)entity).AddingEntity();
+ entity.AddingEntity();
PersistNewBaseContentType(entity);
@@ -114,7 +115,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
ValidateAlias(entity);
//Updates Modified date
- ((MediaType)entity).UpdatingEntity();
+ entity.UpdatingEntity();
//Look up parent to get and set the correct Path if ParentId has changed
if (entity.IsPropertyDirty("ParentId"))
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/MemberGroupRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/MemberGroupRepository.cs
index ff7a79f98e..c138550de5 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/MemberGroupRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/MemberGroupRepository.cs
@@ -6,6 +6,7 @@ using Umbraco.Core.Cache;
using Umbraco.Core.Events;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
+using Umbraco.Core.Models.Entities;
using Umbraco.Core.Persistence.Dtos;
using Umbraco.Core.Persistence.Factories;
using Umbraco.Core.Persistence.Querying;
@@ -91,8 +92,8 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
protected override void PersistNewItem(IMemberGroup entity)
{
//Save to db
+ entity.AddingEntity();
var group = (MemberGroup)entity;
- group.AddingEntity();
var dto = MemberGroupFactory.BuildDto(group);
var o = Database.IsNew(dto) ? Convert.ToInt32(Database.Insert(dto)) : Database.Update(dto);
group.Id = dto.NodeId; //Set Id on entity to ensure an Id is set
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/MemberRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/MemberRepository.cs
index fdf75d8a4c..1605f4f672 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/MemberRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/MemberRepository.cs
@@ -6,6 +6,7 @@ using NPoco;
using Umbraco.Core.Cache;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
+using Umbraco.Core.Models.Entities;
using Umbraco.Core.Persistence.Dtos;
using Umbraco.Core.Persistence.Factories;
using Umbraco.Core.Persistence.Querying;
@@ -232,8 +233,13 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
protected override void PersistNewItem(IMember entity)
{
+ if (entity.ProviderUserKey == null)
+ {
+ entity.ProviderUserKey = entity.Key;
+ }
+ entity.AddingEntity();
+
var member = (Member) entity;
- member.AddingEntity();
// ensure that strings don't contain characters that are invalid in xml
// TODO: do we really want to keep doing this here?
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/MemberTypeRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/MemberTypeRepository.cs
index a32ec1b422..d96854743e 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/MemberTypeRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/MemberTypeRepository.cs
@@ -5,6 +5,7 @@ using NPoco;
using Umbraco.Core.Cache;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
+using Umbraco.Core.Models.Entities;
using Umbraco.Core.Persistence.Dtos;
using Umbraco.Core.Persistence.Factories;
using Umbraco.Core.Persistence.Querying;
@@ -131,12 +132,12 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
{
ValidateAlias(entity);
- ((MemberType)entity).AddingEntity();
+ entity.AddingEntity();
//set a default icon if one is not specified
if (entity.Icon.IsNullOrWhiteSpace())
{
- entity.Icon = "icon-user";
+ entity.Icon = Constants.Icons.Member;
}
//By Convention we add 9 standard PropertyTypes to an Umbraco MemberType
@@ -165,7 +166,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
ValidateAlias(entity);
//Updates Modified date
- ((MemberType)entity).UpdatingEntity();
+ entity.UpdatingEntity();
//Look up parent to get and set the correct Path if ParentId has changed
if (entity.IsPropertyDirty("ParentId"))
@@ -224,6 +225,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
{
//this reset's its current data type reference which will be re-assigned based on the property editor assigned on the next line
propertyType.DataTypeId = 0;
+ propertyType.DataTypeKey = default;
}
}
}
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/PublicAccessRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/PublicAccessRepository.cs
index bd2580b38f..1dc7aa478d 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/PublicAccessRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/PublicAccessRepository.cs
@@ -5,6 +5,7 @@ using NPoco;
using Umbraco.Core.Cache;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
+using Umbraco.Core.Models.Entities;
using Umbraco.Core.Persistence.Dtos;
using Umbraco.Core.Persistence.Factories;
using Umbraco.Core.Persistence.Querying;
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/RelationRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/RelationRepository.cs
index c5ba24f385..4b4af505b8 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/RelationRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/RelationRepository.cs
@@ -134,7 +134,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
protected override void PersistNewItem(IRelation entity)
{
- ((EntityBase)entity).AddingEntity();
+ entity.AddingEntity();
var factory = new RelationFactory(entity.RelationType);
var dto = factory.BuildDto(entity);
@@ -147,7 +147,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
protected override void PersistUpdatedItem(IRelation entity)
{
- ((EntityBase)entity).UpdatingEntity();
+ entity.UpdatingEntity();
var factory = new RelationFactory(entity.RelationType);
var dto = factory.BuildDto(entity);
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/RelationTypeRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/RelationTypeRepository.cs
index 4faf78bd0a..075d4aa769 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/RelationTypeRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/RelationTypeRepository.cs
@@ -133,7 +133,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
protected override void PersistNewItem(IRelationType entity)
{
- ((EntityBase)entity).AddingEntity();
+ entity.AddingEntity();
var dto = RelationTypeFactory.BuildDto(entity);
@@ -145,7 +145,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
protected override void PersistUpdatedItem(IRelationType entity)
{
- ((EntityBase)entity).UpdatingEntity();
+ entity.UpdatingEntity();
var dto = RelationTypeFactory.BuildDto(entity);
Database.Update(dto);
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/ServerRegistrationRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/ServerRegistrationRepository.cs
index 6b2dfddaeb..1497c2857c 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/ServerRegistrationRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/ServerRegistrationRepository.cs
@@ -5,6 +5,7 @@ using NPoco;
using Umbraco.Core.Cache;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
+using Umbraco.Core.Models.Entities;
using Umbraco.Core.Persistence.Dtos;
using Umbraco.Core.Persistence.Factories;
using Umbraco.Core.Persistence.Querying;
@@ -96,7 +97,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
protected override void PersistNewItem(IServerRegistration entity)
{
- ((ServerRegistration)entity).AddingEntity();
+ entity.AddingEntity();
var dto = ServerRegistrationFactory.BuildDto(entity);
@@ -108,7 +109,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
protected override void PersistUpdatedItem(IServerRegistration entity)
{
- ((ServerRegistration)entity).UpdatingEntity();
+ entity.UpdatingEntity();
var dto = ServerRegistrationFactory.BuildDto(entity);
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/SimilarNodeName.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/SimilarNodeName.cs
index 9f27b6b9e3..99e824757d 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/SimilarNodeName.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/SimilarNodeName.cs
@@ -99,7 +99,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
if (uniqueing)
{
- if (name.NumPos > 0 && name.Name.StartsWith(nodeName) && name.NumVal == uniqueNumber)
+ if (name.NumPos > 0 && name.Name.InvariantStartsWith(nodeName) && name.NumVal == uniqueNumber)
uniqueNumber++;
else
break;
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/TagRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/TagRepository.cs
index fb836dccac..87564b9ac9 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/TagRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/TagRepository.cs
@@ -85,7 +85,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
///
protected override void PersistNewItem(ITag entity)
{
- ((EntityBase)entity).AddingEntity();
+ entity.AddingEntity();
var dto = TagFactory.BuildDto(entity);
var id = Convert.ToInt32(Database.Insert(dto));
@@ -97,7 +97,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
///
protected override void PersistUpdatedItem(ITag entity)
{
- ((EntityBase)entity).UpdatingEntity();
+ entity.UpdatingEntity();
var dto = TagFactory.BuildDto(entity);
Database.Update(dto);
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/TupleExtensions.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/TupleExtensions.cs
index eae9251552..c40060456c 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/TupleExtensions.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/TupleExtensions.cs
@@ -11,9 +11,9 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
return t.Item1.Zip(t.Item2, relator);
}
- public static IEnumerable Map(this Tuple, List, List> t, Func relator)
- {
- return t.Item1.Zip(t.Item2, t.Item3, relator);
- }
+// public static IEnumerable Map(this Tuple, List, List> t, Func relator)
+// {
+// return t.Item1.Zip(t.Item2, t.Item3, relator);
+// }
}
}
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/UserGroupRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/UserGroupRepository.cs
index 3b247950e4..0701a0996e 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/UserGroupRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/UserGroupRepository.cs
@@ -290,7 +290,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
protected override void PersistNewItem(IUserGroup entity)
{
- ((UserGroup) entity).AddingEntity();
+ entity.AddingEntity();
var userGroupDto = UserGroupFactory.BuildDto(entity);
@@ -304,7 +304,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
protected override void PersistUpdatedItem(IUserGroup entity)
{
- ((UserGroup) entity).UpdatingEntity();
+ entity.UpdatingEntity();
var userGroupDto = UserGroupFactory.BuildDto(entity);
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/UserRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/UserRepository.cs
index 91a20c5bdd..96abc37662 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/UserRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/UserRepository.cs
@@ -445,7 +445,7 @@ ORDER BY colName";
return;
}
- ((User) entity).AddingEntity();
+ entity.AddingEntity();
// ensure security stamp if missing
if (entity.SecurityStamp.IsNullOrWhiteSpace())
@@ -495,7 +495,7 @@ ORDER BY colName";
protected override void PersistUpdatedItem(IUser entity)
{
// updates Modified date
- ((User) entity).UpdatingEntity();
+ entity.UpdatingEntity();
// ensure security stamp if missing
if (entity.SecurityStamp.IsNullOrWhiteSpace())
diff --git a/src/Umbraco.Core/PropertyEditors/IIgnoreUserStartNodesConfig.cs b/src/Umbraco.Core/PropertyEditors/IIgnoreUserStartNodesConfig.cs
new file mode 100644
index 0000000000..bef3f42f46
--- /dev/null
+++ b/src/Umbraco.Core/PropertyEditors/IIgnoreUserStartNodesConfig.cs
@@ -0,0 +1,10 @@
+namespace Umbraco.Core.PropertyEditors
+{
+ ///
+ /// Marker interface for any editor configuration that supports Ignoring user start nodes
+ ///
+ internal interface IIgnoreUserStartNodesConfig
+ {
+ bool IgnoreUserStartNodes { get; set; }
+ }
+}
diff --git a/src/Umbraco.Core/PropertyEditors/IPropertyValueConverter.cs b/src/Umbraco.Core/PropertyEditors/IPropertyValueConverter.cs
index f6a7cbf32f..0a9cf632bc 100644
--- a/src/Umbraco.Core/PropertyEditors/IPropertyValueConverter.cs
+++ b/src/Umbraco.Core/PropertyEditors/IPropertyValueConverter.cs
@@ -15,7 +15,7 @@ namespace Umbraco.Core.PropertyEditors
///
/// The property type.
/// A value indicating whether the converter supports a property type.
- bool IsConverter(PublishedPropertyType propertyType);
+ bool IsConverter(IPublishedPropertyType propertyType);
///
/// Determines whether a value is an actual value, or not a value.
@@ -36,14 +36,14 @@ namespace Umbraco.Core.PropertyEditors
/// The CLR type of values returned by the converter.
/// Some of the CLR types may be generated, therefore this method cannot directly return
/// a Type object (which may not exist yet). In which case it needs to return a ModelType instance.
- Type GetPropertyValueType(PublishedPropertyType propertyType);
+ Type GetPropertyValueType(IPublishedPropertyType propertyType);
///
/// Gets the property cache level.
///
/// The property type.
/// The property cache level.
- PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType);
+ PropertyCacheLevel GetPropertyCacheLevel(IPublishedPropertyType propertyType);
///
/// Converts a property source value to an intermediate value.
@@ -64,7 +64,7 @@ namespace Umbraco.Core.PropertyEditors
/// strings, and xml-whitespace strings appropriately, ie it should know whether to preserve
/// white spaces.
///
- object ConvertSourceToIntermediate(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview);
+ object ConvertSourceToIntermediate(IPublishedElement owner, IPublishedPropertyType propertyType, object source, bool preview);
///
/// Converts a property intermediate value to an Object value.
@@ -83,7 +83,7 @@ namespace Umbraco.Core.PropertyEditors
/// passed to eg a PublishedFragment constructor. It is used by the fragment and the properties to manage
/// the cache levels of property values. It is not meant to be used by the converter.
///
- object ConvertIntermediateToObject(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview);
+ object ConvertIntermediateToObject(IPublishedElement owner, IPublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview);
///
/// Converts a property intermediate value to an XPath value.
@@ -107,6 +107,6 @@ namespace Umbraco.Core.PropertyEditors
/// passed to eg a PublishedFragment constructor. It is used by the fragment and the properties to manage
/// the cache levels of property values. It is not meant to be used by the converter.
///
- object ConvertIntermediateToXPath(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview);
+ object ConvertIntermediateToXPath(IPublishedElement owner, IPublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview);
}
}
diff --git a/src/Umbraco.Core/PropertyEditors/PropertyValueConverterBase.cs b/src/Umbraco.Core/PropertyEditors/PropertyValueConverterBase.cs
index 48bfc49ed9..3b6ebc610c 100644
--- a/src/Umbraco.Core/PropertyEditors/PropertyValueConverterBase.cs
+++ b/src/Umbraco.Core/PropertyEditors/PropertyValueConverterBase.cs
@@ -8,7 +8,7 @@ namespace Umbraco.Core.PropertyEditors
///
public abstract class PropertyValueConverterBase : IPropertyValueConverter
{
- public virtual bool IsConverter(PublishedPropertyType propertyType)
+ public virtual bool IsConverter(IPublishedPropertyType propertyType)
=> false;
public virtual bool? IsValue(object value, PropertyValueLevel level)
@@ -30,19 +30,19 @@ namespace Umbraco.Core.PropertyEditors
return value != null && (!(value is string) || string.IsNullOrWhiteSpace((string) value) == false);
}
- public virtual Type GetPropertyValueType(PublishedPropertyType propertyType)
+ public virtual Type GetPropertyValueType(IPublishedPropertyType propertyType)
=> typeof (object);
- public virtual PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType)
+ public virtual PropertyCacheLevel GetPropertyCacheLevel(IPublishedPropertyType propertyType)
=> PropertyCacheLevel.Snapshot;
- public virtual object ConvertSourceToIntermediate(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview)
+ public virtual object ConvertSourceToIntermediate(IPublishedElement owner, IPublishedPropertyType propertyType, object source, bool preview)
=> source;
- public virtual object ConvertIntermediateToObject(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview)
+ public virtual object ConvertIntermediateToObject(IPublishedElement owner, IPublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview)
=> inter;
- public virtual object ConvertIntermediateToXPath(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview)
+ public virtual object ConvertIntermediateToXPath(IPublishedElement owner, IPublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview)
=> inter?.ToString() ?? string.Empty;
}
}
diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/CheckboxListValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/CheckboxListValueConverter.cs
index 3d69c37b8b..dd2dfb49e7 100644
--- a/src/Umbraco.Core/PropertyEditors/ValueConverters/CheckboxListValueConverter.cs
+++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/CheckboxListValueConverter.cs
@@ -9,16 +9,16 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
[DefaultPropertyValueConverter]
public class CheckboxListValueConverter : PropertyValueConverterBase
{
- public override bool IsConverter(PublishedPropertyType propertyType)
+ public override bool IsConverter(IPublishedPropertyType propertyType)
=> propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.Aliases.CheckBoxList);
- public override Type GetPropertyValueType(PublishedPropertyType propertyType)
+ public override Type GetPropertyValueType(IPublishedPropertyType propertyType)
=> typeof (IEnumerable);
- public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType)
+ public override PropertyCacheLevel GetPropertyCacheLevel(IPublishedPropertyType propertyType)
=> PropertyCacheLevel.Element;
- public override object ConvertIntermediateToObject(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel cacheLevel, object source, bool preview)
+ public override object ConvertIntermediateToObject(IPublishedElement owner, IPublishedPropertyType propertyType, PropertyCacheLevel cacheLevel, object source, bool preview)
{
var sourceString = source?.ToString() ?? string.Empty;
diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/ColorPickerValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/ColorPickerValueConverter.cs
index 9f260fc973..46dae3e4f0 100644
--- a/src/Umbraco.Core/PropertyEditors/ValueConverters/ColorPickerValueConverter.cs
+++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/ColorPickerValueConverter.cs
@@ -8,16 +8,16 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
[DefaultPropertyValueConverter]
public class ColorPickerValueConverter : PropertyValueConverterBase
{
- public override bool IsConverter(PublishedPropertyType propertyType)
+ public override bool IsConverter(IPublishedPropertyType propertyType)
=> propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.Aliases.ColorPicker);
- public override Type GetPropertyValueType(PublishedPropertyType propertyType)
+ public override Type GetPropertyValueType(IPublishedPropertyType propertyType)
=> UseLabel(propertyType) ? typeof(PickedColor) : typeof(string);
- public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType)
+ public override PropertyCacheLevel GetPropertyCacheLevel(IPublishedPropertyType propertyType)
=> PropertyCacheLevel.Element;
- public override object ConvertSourceToIntermediate(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview)
+ public override object ConvertSourceToIntermediate(IPublishedElement owner, IPublishedPropertyType propertyType, object source, bool preview)
{
var useLabel = UseLabel(propertyType);
@@ -39,7 +39,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
return ssource;
}
- private bool UseLabel(PublishedPropertyType propertyType)
+ private bool UseLabel(IPublishedPropertyType propertyType)
{
return ConfigurationEditor.ConfigurationAs(propertyType.DataType.Configuration).UseLabel;
}
diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/DatePickerValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/DatePickerValueConverter.cs
index ffe9feb653..0206528bf7 100644
--- a/src/Umbraco.Core/PropertyEditors/ValueConverters/DatePickerValueConverter.cs
+++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/DatePickerValueConverter.cs
@@ -8,16 +8,16 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
[DefaultPropertyValueConverter]
public class DatePickerValueConverter : PropertyValueConverterBase
{
- public override bool IsConverter(PublishedPropertyType propertyType)
+ public override bool IsConverter(IPublishedPropertyType propertyType)
=> propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.Aliases.DateTime);
- public override Type GetPropertyValueType(PublishedPropertyType propertyType)
+ public override Type GetPropertyValueType(IPublishedPropertyType propertyType)
=> typeof (DateTime);
- public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType)
+ public override PropertyCacheLevel GetPropertyCacheLevel(IPublishedPropertyType propertyType)
=> PropertyCacheLevel.Element;
- public override object ConvertSourceToIntermediate(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview)
+ public override object ConvertSourceToIntermediate(IPublishedElement owner, IPublishedPropertyType propertyType, object source, bool preview)
{
if (source == null) return DateTime.MinValue;
@@ -39,7 +39,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
// default ConvertSourceToObject just returns source ie a DateTime value
- public override object ConvertIntermediateToXPath(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview)
+ public override object ConvertIntermediateToXPath(IPublishedElement owner, IPublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview)
{
// source should come from ConvertSource and be a DateTime already
return XmlConvert.ToString((DateTime) inter, XmlDateTimeSerializationMode.Unspecified);
diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/DecimalValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/DecimalValueConverter.cs
index 6f7888aee3..7d6e7c0ce9 100644
--- a/src/Umbraco.Core/PropertyEditors/ValueConverters/DecimalValueConverter.cs
+++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/DecimalValueConverter.cs
@@ -7,16 +7,16 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
[DefaultPropertyValueConverter]
public class DecimalValueConverter : PropertyValueConverterBase
{
- public override bool IsConverter(PublishedPropertyType propertyType)
+ public override bool IsConverter(IPublishedPropertyType propertyType)
=> Constants.PropertyEditors.Aliases.Decimal.Equals(propertyType.EditorAlias);
- public override Type GetPropertyValueType(PublishedPropertyType propertyType)
+ public override Type GetPropertyValueType(IPublishedPropertyType propertyType)
=> typeof (decimal);
- public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType)
+ public override PropertyCacheLevel GetPropertyCacheLevel(IPublishedPropertyType propertyType)
=> PropertyCacheLevel.Element;
- public override object ConvertSourceToIntermediate(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview)
+ public override object ConvertSourceToIntermediate(IPublishedElement owner, IPublishedPropertyType propertyType, object source, bool preview)
{
if (source == null)
{
diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/EmailAddressValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/EmailAddressValueConverter.cs
index e4ef3a50a3..88061a559e 100644
--- a/src/Umbraco.Core/PropertyEditors/ValueConverters/EmailAddressValueConverter.cs
+++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/EmailAddressValueConverter.cs
@@ -6,16 +6,16 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
[DefaultPropertyValueConverter]
public class EmailAddressValueConverter : PropertyValueConverterBase
{
- public override bool IsConverter(PublishedPropertyType propertyType)
+ public override bool IsConverter(IPublishedPropertyType propertyType)
=> propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.Aliases.EmailAddress);
- public override Type GetPropertyValueType(PublishedPropertyType propertyType)
+ public override Type GetPropertyValueType(IPublishedPropertyType propertyType)
=> typeof (string);
- public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType)
+ public override PropertyCacheLevel GetPropertyCacheLevel(IPublishedPropertyType propertyType)
=> PropertyCacheLevel.Element;
- public override object ConvertIntermediateToObject(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel cacheLevel, object source, bool preview)
+ public override object ConvertIntermediateToObject(IPublishedElement owner, IPublishedPropertyType propertyType, PropertyCacheLevel cacheLevel, object source, bool preview)
{
return source?.ToString() ?? string.Empty;
}
diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/GridValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/GridValueConverter.cs
index 29f6de0271..b3685457ec 100644
--- a/src/Umbraco.Core/PropertyEditors/ValueConverters/GridValueConverter.cs
+++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/GridValueConverter.cs
@@ -28,16 +28,16 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
_config = config;
}
- public override bool IsConverter(PublishedPropertyType propertyType)
+ public override bool IsConverter(IPublishedPropertyType propertyType)
=> propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.Aliases.Grid);
- public override Type GetPropertyValueType(PublishedPropertyType propertyType)
+ public override Type GetPropertyValueType(IPublishedPropertyType propertyType)
=> typeof (JToken);
- public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType)
+ public override PropertyCacheLevel GetPropertyCacheLevel(IPublishedPropertyType propertyType)
=> PropertyCacheLevel.Element;
- public override object ConvertSourceToIntermediate(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview)
+ public override object ConvertSourceToIntermediate(IPublishedElement owner, IPublishedPropertyType propertyType, object source, bool preview)
{
if (source == null) return null;
var sourceString = source.ToString();
diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/ImageCropperValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/ImageCropperValueConverter.cs
index 79cb748960..6f5bd571b7 100644
--- a/src/Umbraco.Core/PropertyEditors/ValueConverters/ImageCropperValueConverter.cs
+++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/ImageCropperValueConverter.cs
@@ -14,19 +14,19 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
public class ImageCropperValueConverter : PropertyValueConverterBase
{
///
- public override bool IsConverter(PublishedPropertyType propertyType)
+ public override bool IsConverter(IPublishedPropertyType propertyType)
=> propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.Aliases.ImageCropper);
///
- public override Type GetPropertyValueType(PublishedPropertyType propertyType)
+ public override Type GetPropertyValueType(IPublishedPropertyType propertyType)
=> typeof (ImageCropperValue);
///
- public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType)
+ public override PropertyCacheLevel GetPropertyCacheLevel(IPublishedPropertyType propertyType)
=> PropertyCacheLevel.Element;
///
- public override object ConvertSourceToIntermediate(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview)
+ public override object ConvertSourceToIntermediate(IPublishedElement owner, IPublishedPropertyType propertyType, object source, bool preview)
{
if (source == null) return null;
var sourceString = source.ToString();
diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/IntegerValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/IntegerValueConverter.cs
index e0abf17a7e..ca8f23bca2 100644
--- a/src/Umbraco.Core/PropertyEditors/ValueConverters/IntegerValueConverter.cs
+++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/IntegerValueConverter.cs
@@ -6,16 +6,16 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
[DefaultPropertyValueConverter]
public class IntegerValueConverter : PropertyValueConverterBase
{
- public override bool IsConverter(PublishedPropertyType propertyType)
+ public override bool IsConverter(IPublishedPropertyType propertyType)
=> Constants.PropertyEditors.Aliases.Integer.Equals(propertyType.EditorAlias);
- public override Type GetPropertyValueType(PublishedPropertyType propertyType)
+ public override Type GetPropertyValueType(IPublishedPropertyType propertyType)
=> typeof (int);
- public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType)
+ public override PropertyCacheLevel GetPropertyCacheLevel(IPublishedPropertyType propertyType)
=> PropertyCacheLevel.Element;
- public override object ConvertSourceToIntermediate(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview)
+ public override object ConvertSourceToIntermediate(IPublishedElement owner, IPublishedPropertyType propertyType, object source, bool preview)
{
return source.TryConvertTo().Result;
}
diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/JsonValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/JsonValueConverter.cs
index e04893716a..12e6238705 100644
--- a/src/Umbraco.Core/PropertyEditors/ValueConverters/JsonValueConverter.cs
+++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/JsonValueConverter.cs
@@ -31,19 +31,19 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
///
///
///
- public override bool IsConverter(PublishedPropertyType propertyType)
+ public override bool IsConverter(IPublishedPropertyType propertyType)
{
return _propertyEditors.TryGet(propertyType.EditorAlias, out var editor)
&& editor.GetValueEditor().ValueType.InvariantEquals(ValueTypes.Json);
}
- public override Type GetPropertyValueType(PublishedPropertyType propertyType)
+ public override Type GetPropertyValueType(IPublishedPropertyType propertyType)
=> typeof (JToken);
- public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType)
+ public override PropertyCacheLevel GetPropertyCacheLevel(IPublishedPropertyType propertyType)
=> PropertyCacheLevel.Element;
- public override object ConvertSourceToIntermediate(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview)
+ public override object ConvertSourceToIntermediate(IPublishedElement owner, IPublishedPropertyType propertyType, object source, bool preview)
{
if (source == null) return null;
var sourceString = source.ToString();
diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/LabelValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/LabelValueConverter.cs
index 05a5f15aaf..84baf226cf 100644
--- a/src/Umbraco.Core/PropertyEditors/ValueConverters/LabelValueConverter.cs
+++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/LabelValueConverter.cs
@@ -16,10 +16,10 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
[DefaultPropertyValueConverter]
public class LabelValueConverter : PropertyValueConverterBase
{
- public override bool IsConverter(PublishedPropertyType propertyType)
+ public override bool IsConverter(IPublishedPropertyType propertyType)
=> Constants.PropertyEditors.Aliases.Label.Equals(propertyType.EditorAlias);
- public override Type GetPropertyValueType(PublishedPropertyType propertyType)
+ public override Type GetPropertyValueType(IPublishedPropertyType propertyType)
{
var valueType = ConfigurationEditor.ConfigurationAs(propertyType.DataType.Configuration);
switch (valueType.ValueType)
@@ -40,10 +40,10 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
}
}
- public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType)
+ public override PropertyCacheLevel GetPropertyCacheLevel(IPublishedPropertyType propertyType)
=> PropertyCacheLevel.Element;
- public override object ConvertSourceToIntermediate(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview)
+ public override object ConvertSourceToIntermediate(IPublishedElement owner, IPublishedPropertyType propertyType, object source, bool preview)
{
var valueType = ConfigurationEditor.ConfigurationAs(propertyType.DataType.Configuration);
switch (valueType.ValueType)
diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/MarkdownEditorValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/MarkdownEditorValueConverter.cs
index aeacf33eef..a062561ab1 100644
--- a/src/Umbraco.Core/PropertyEditors/ValueConverters/MarkdownEditorValueConverter.cs
+++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/MarkdownEditorValueConverter.cs
@@ -7,17 +7,17 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
[DefaultPropertyValueConverter]
public class MarkdownEditorValueConverter : PropertyValueConverterBase
{
- public override bool IsConverter(PublishedPropertyType propertyType)
+ public override bool IsConverter(IPublishedPropertyType propertyType)
=> Constants.PropertyEditors.Aliases.MarkdownEditor.Equals(propertyType.EditorAlias);
- public override Type GetPropertyValueType(PublishedPropertyType propertyType)
+ public override Type GetPropertyValueType(IPublishedPropertyType propertyType)
=> typeof (IHtmlString);
// PropertyCacheLevel.Content is ok here because that converter does not parse {locallink} nor executes macros
- public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType)
+ public override PropertyCacheLevel GetPropertyCacheLevel(IPublishedPropertyType propertyType)
=> PropertyCacheLevel.Element;
- public override object ConvertSourceToIntermediate(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview)
+ public override object ConvertSourceToIntermediate(IPublishedElement owner, IPublishedPropertyType propertyType, object source, bool preview)
{
// in xml a string is: string
// in the database a string is: string
@@ -25,13 +25,13 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
return source;
}
- public override object ConvertIntermediateToObject(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview)
+ public override object ConvertIntermediateToObject(IPublishedElement owner, IPublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview)
{
// source should come from ConvertSource and be a string (or null) already
return new HtmlString(inter == null ? string.Empty : (string) inter);
}
- public override object ConvertIntermediateToXPath(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview)
+ public override object ConvertIntermediateToXPath(IPublishedElement owner, IPublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview)
{
// source should come from ConvertSource and be a string (or null) already
return inter?.ToString() ?? string.Empty;
diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/MemberGroupPickerValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/MemberGroupPickerValueConverter.cs
index bdd09ea33b..cd7f48f510 100644
--- a/src/Umbraco.Core/PropertyEditors/ValueConverters/MemberGroupPickerValueConverter.cs
+++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/MemberGroupPickerValueConverter.cs
@@ -6,16 +6,16 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
[DefaultPropertyValueConverter]
public class MemberGroupPickerValueConverter : PropertyValueConverterBase
{
- public override bool IsConverter(PublishedPropertyType propertyType)
+ public override bool IsConverter(IPublishedPropertyType propertyType)
=> propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.Aliases.MemberGroupPicker);
- public override Type GetPropertyValueType(PublishedPropertyType propertyType)
+ public override Type GetPropertyValueType(IPublishedPropertyType propertyType)
=> typeof (string);
- public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType)
+ public override PropertyCacheLevel GetPropertyCacheLevel(IPublishedPropertyType propertyType)
=> PropertyCacheLevel.Element;
- public override object ConvertSourceToIntermediate(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview)
+ public override object ConvertSourceToIntermediate(IPublishedElement owner, IPublishedPropertyType propertyType, object source, bool preview)
{
return source?.ToString() ?? string.Empty;
}
diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/MultipleTextStringValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/MultipleTextStringValueConverter.cs
index 1d5f0b1ca3..15e7ce4caf 100644
--- a/src/Umbraco.Core/PropertyEditors/ValueConverters/MultipleTextStringValueConverter.cs
+++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/MultipleTextStringValueConverter.cs
@@ -9,18 +9,18 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
[DefaultPropertyValueConverter]
public class MultipleTextStringValueConverter : PropertyValueConverterBase
{
- public override bool IsConverter(PublishedPropertyType propertyType)
+ public override bool IsConverter(IPublishedPropertyType propertyType)
=> Constants.PropertyEditors.Aliases.MultipleTextstring.Equals(propertyType.EditorAlias);
- public override Type GetPropertyValueType(PublishedPropertyType propertyType)
+ public override Type GetPropertyValueType(IPublishedPropertyType propertyType)
=> typeof (IEnumerable);
- public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType)
+ public override PropertyCacheLevel GetPropertyCacheLevel(IPublishedPropertyType propertyType)
=> PropertyCacheLevel.Element;
private static readonly string[] NewLineDelimiters = { "\r\n", "\r", "\n" };
- public override object ConvertSourceToIntermediate(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview)
+ public override object ConvertSourceToIntermediate(IPublishedElement owner, IPublishedPropertyType propertyType, object source, bool preview)
{
// data is (both in database and xml):
//
@@ -58,7 +58,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
: values.ToArray();
}
- public override object ConvertIntermediateToXPath(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview)
+ public override object ConvertIntermediateToXPath(IPublishedElement owner, IPublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview)
{
var d = new XmlDocument();
var e = d.CreateElement("values");
diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/MustBeStringValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/MustBeStringValueConverter.cs
index c9528c3e8b..b9c61bb169 100644
--- a/src/Umbraco.Core/PropertyEditors/ValueConverters/MustBeStringValueConverter.cs
+++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/MustBeStringValueConverter.cs
@@ -22,16 +22,16 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
Constants.PropertyEditors.Aliases.MultiNodeTreePicker
};
- public override bool IsConverter(PublishedPropertyType propertyType)
+ public override bool IsConverter(IPublishedPropertyType propertyType)
=> Aliases.Contains(propertyType.EditorAlias);
- public override Type GetPropertyValueType(PublishedPropertyType propertyType)
+ public override Type GetPropertyValueType(IPublishedPropertyType propertyType)
=> typeof (string);
- public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType)
+ public override PropertyCacheLevel GetPropertyCacheLevel(IPublishedPropertyType propertyType)
=> PropertyCacheLevel.Element;
- public override object ConvertSourceToIntermediate(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview)
+ public override object ConvertSourceToIntermediate(IPublishedElement owner, IPublishedPropertyType propertyType, object source, bool preview)
{
return source?.ToString();
}
diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/RadioButtonListValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/RadioButtonListValueConverter.cs
index b99cc7e0e3..61adc9a93e 100644
--- a/src/Umbraco.Core/PropertyEditors/ValueConverters/RadioButtonListValueConverter.cs
+++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/RadioButtonListValueConverter.cs
@@ -6,16 +6,16 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
[DefaultPropertyValueConverter]
public class RadioButtonListValueConverter : PropertyValueConverterBase
{
- public override bool IsConverter(PublishedPropertyType propertyType)
+ public override bool IsConverter(IPublishedPropertyType propertyType)
=> propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.Aliases.RadioButtonList);
- public override Type GetPropertyValueType(PublishedPropertyType propertyType)
+ public override Type GetPropertyValueType(IPublishedPropertyType propertyType)
=> typeof (string);
- public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType)
+ public override PropertyCacheLevel GetPropertyCacheLevel(IPublishedPropertyType propertyType)
=> PropertyCacheLevel.Element;
- public override object ConvertSourceToIntermediate(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview)
+ public override object ConvertSourceToIntermediate(IPublishedElement owner, IPublishedPropertyType propertyType, object source, bool preview)
{
var attempt = source.TryConvertTo();
diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/SliderValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/SliderValueConverter.cs
index 31ab47223f..11502687b7 100644
--- a/src/Umbraco.Core/PropertyEditors/ValueConverters/SliderValueConverter.cs
+++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/SliderValueConverter.cs
@@ -18,16 +18,16 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
_dataTypeService = dataTypeService ?? throw new ArgumentNullException(nameof(dataTypeService));
}
- public override bool IsConverter(PublishedPropertyType propertyType)
+ public override bool IsConverter(IPublishedPropertyType propertyType)
=> propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.Aliases.Slider);
- public override Type GetPropertyValueType(PublishedPropertyType propertyType)
+ public override Type GetPropertyValueType(IPublishedPropertyType propertyType)
=> IsRangeDataType(propertyType.DataType.Id) ? typeof (Range) : typeof (decimal);
- public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType)
+ public override PropertyCacheLevel GetPropertyCacheLevel(IPublishedPropertyType propertyType)
=> PropertyCacheLevel.Element;
- public override object ConvertIntermediateToObject(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel cacheLevel, object source, bool preview)
+ public override object ConvertIntermediateToObject(IPublishedElement owner, IPublishedPropertyType propertyType, PropertyCacheLevel cacheLevel, object source, bool preview)
{
if (source == null)
return null;
diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/TagsValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/TagsValueConverter.cs
index 9b857c2dff..b54c693c14 100644
--- a/src/Umbraco.Core/PropertyEditors/ValueConverters/TagsValueConverter.cs
+++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/TagsValueConverter.cs
@@ -19,16 +19,16 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
_dataTypeService = dataTypeService ?? throw new ArgumentNullException(nameof(dataTypeService));
}
- public override bool IsConverter(PublishedPropertyType propertyType)
+ public override bool IsConverter(IPublishedPropertyType propertyType)
=> propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.Aliases.Tags);
- public override Type GetPropertyValueType(PublishedPropertyType propertyType)
+ public override Type GetPropertyValueType(IPublishedPropertyType propertyType)
=> typeof (IEnumerable);
- public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType)
+ public override PropertyCacheLevel GetPropertyCacheLevel(IPublishedPropertyType propertyType)
=> PropertyCacheLevel.Element;
- public override object ConvertSourceToIntermediate(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview)
+ public override object ConvertSourceToIntermediate(IPublishedElement owner, IPublishedPropertyType propertyType, object source, bool preview)
{
if (source == null) return Array.Empty();
@@ -43,7 +43,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
return source.ToString().Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries);
}
- public override object ConvertIntermediateToObject(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel cacheLevel, object source, bool preview)
+ public override object ConvertIntermediateToObject(IPublishedElement owner, IPublishedPropertyType propertyType, PropertyCacheLevel cacheLevel, object source, bool preview)
{
return (string[]) source;
}
diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/TextStringValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/TextStringValueConverter.cs
index 2368a1d034..7caa9a90cc 100644
--- a/src/Umbraco.Core/PropertyEditors/ValueConverters/TextStringValueConverter.cs
+++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/TextStringValueConverter.cs
@@ -13,16 +13,16 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
Constants.PropertyEditors.Aliases.TextArea
};
- public override bool IsConverter(PublishedPropertyType propertyType)
+ public override bool IsConverter(IPublishedPropertyType propertyType)
=> PropertyTypeAliases.Contains(propertyType.EditorAlias);
- public override Type GetPropertyValueType(PublishedPropertyType propertyType)
+ public override Type GetPropertyValueType(IPublishedPropertyType propertyType)
=> typeof (string);
- public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType)
+ public override PropertyCacheLevel GetPropertyCacheLevel(IPublishedPropertyType propertyType)
=> PropertyCacheLevel.Element;
- public override object ConvertSourceToIntermediate(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview)
+ public override object ConvertSourceToIntermediate(IPublishedElement owner, IPublishedPropertyType propertyType, object source, bool preview)
{
// in xml a string is: string
// in the database a string is: string
@@ -30,13 +30,13 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
return source;
}
- public override object ConvertIntermediateToObject(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview)
+ public override object ConvertIntermediateToObject(IPublishedElement owner, IPublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview)
{
// source should come from ConvertSource and be a string (or null) already
return inter ?? string.Empty;
}
- public override object ConvertIntermediateToXPath(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview)
+ public override object ConvertIntermediateToXPath(IPublishedElement owner, IPublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview)
{
// source should come from ConvertSource and be a string (or null) already
return inter;
diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/TinyMceValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/TinyMceValueConverter.cs
index 46f660d829..9938af671d 100644
--- a/src/Umbraco.Core/PropertyEditors/ValueConverters/TinyMceValueConverter.cs
+++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/TinyMceValueConverter.cs
@@ -10,17 +10,17 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
[DefaultPropertyValueConverter]
public class TinyMceValueConverter : PropertyValueConverterBase
{
- public override bool IsConverter(PublishedPropertyType propertyType)
+ public override bool IsConverter(IPublishedPropertyType propertyType)
=> propertyType.EditorAlias == Constants.PropertyEditors.Aliases.TinyMce;
- public override Type GetPropertyValueType(PublishedPropertyType propertyType)
+ public override Type GetPropertyValueType(IPublishedPropertyType propertyType)
=> typeof (IHtmlString);
// PropertyCacheLevel.Content is ok here because that converter does not parse {locallink} nor executes macros
- public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType)
+ public override PropertyCacheLevel GetPropertyCacheLevel(IPublishedPropertyType propertyType)
=> PropertyCacheLevel.Element;
- public override object ConvertSourceToIntermediate(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview)
+ public override object ConvertSourceToIntermediate(IPublishedElement owner, IPublishedPropertyType propertyType, object source, bool preview)
{
// in xml a string is: string
// in the database a string is: string
@@ -28,13 +28,13 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
return source;
}
- public override object ConvertIntermediateToObject(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview)
+ public override object ConvertIntermediateToObject(IPublishedElement owner, IPublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview)
{
// source should come from ConvertSource and be a string (or null) already
return new HtmlString(inter == null ? string.Empty : (string)inter);
}
- public override object ConvertIntermediateToXPath(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview)
+ public override object ConvertIntermediateToXPath(IPublishedElement owner, IPublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview)
{
// source should come from ConvertSource and be a string (or null) already
return inter;
diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/UploadPropertyConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/UploadPropertyConverter.cs
index cfa247edaa..407ed13ddf 100644
--- a/src/Umbraco.Core/PropertyEditors/ValueConverters/UploadPropertyConverter.cs
+++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/UploadPropertyConverter.cs
@@ -9,16 +9,16 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
[DefaultPropertyValueConverter]
public class UploadPropertyConverter : PropertyValueConverterBase
{
- public override bool IsConverter(PublishedPropertyType propertyType)
+ public override bool IsConverter(IPublishedPropertyType propertyType)
=> propertyType.EditorAlias.Equals(Constants.PropertyEditors.Aliases.UploadField);
- public override Type GetPropertyValueType(PublishedPropertyType propertyType)
+ public override Type GetPropertyValueType(IPublishedPropertyType propertyType)
=> typeof (string);
- public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType)
+ public override PropertyCacheLevel GetPropertyCacheLevel(IPublishedPropertyType propertyType)
=> PropertyCacheLevel.Element;
- public override object ConvertIntermediateToObject(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel cacheLevel, object source, bool preview)
+ public override object ConvertIntermediateToObject(IPublishedElement owner, IPublishedPropertyType propertyType, PropertyCacheLevel cacheLevel, object source, bool preview)
{
return source?.ToString() ?? "";
}
diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/YesNoValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/YesNoValueConverter.cs
index 8ad09733f8..153462ccf5 100644
--- a/src/Umbraco.Core/PropertyEditors/ValueConverters/YesNoValueConverter.cs
+++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/YesNoValueConverter.cs
@@ -6,16 +6,16 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
[DefaultPropertyValueConverter]
public class YesNoValueConverter : PropertyValueConverterBase
{
- public override bool IsConverter(PublishedPropertyType propertyType)
+ public override bool IsConverter(IPublishedPropertyType propertyType)
=> propertyType.EditorAlias == Constants.PropertyEditors.Aliases.Boolean;
- public override Type GetPropertyValueType(PublishedPropertyType propertyType)
+ public override Type GetPropertyValueType(IPublishedPropertyType propertyType)
=> typeof (bool);
- public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType)
+ public override PropertyCacheLevel GetPropertyCacheLevel(IPublishedPropertyType propertyType)
=> PropertyCacheLevel.Element;
- public override object ConvertSourceToIntermediate(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview)
+ public override object ConvertSourceToIntermediate(IPublishedElement owner, IPublishedPropertyType propertyType, object source, bool preview)
{
// in xml a boolean is: string
// in the database a boolean is: string "1" or "0" or empty
@@ -49,7 +49,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
// default ConvertSourceToObject just returns source ie a boolean value
- public override object ConvertIntermediateToXPath(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview)
+ public override object ConvertIntermediateToXPath(IPublishedElement owner, IPublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview)
{
// source should come from ConvertSource and be a boolean already
return (bool)inter ? "1" : "0";
diff --git a/src/Umbraco.Core/PublishedContentExtensions.cs b/src/Umbraco.Core/PublishedContentExtensions.cs
new file mode 100644
index 0000000000..f220f307d6
--- /dev/null
+++ b/src/Umbraco.Core/PublishedContentExtensions.cs
@@ -0,0 +1,128 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Umbraco.Core.Composing;
+using Umbraco.Core.Models.PublishedContent;
+
+namespace Umbraco.Core
+{
+ public static class PublishedContentExtensions
+ {
+ private static IVariationContextAccessor VariationContextAccessor => Current.VariationContextAccessor;
+
+ ///
+ /// Determines whether the content has a culture.
+ ///
+ /// Culture is case-insensitive.
+ public static bool HasCulture(this IPublishedContent content, string culture)
+ => content.Cultures.ContainsKey(culture ?? string.Empty);
+
+ ///
+ /// Determines whether the content is invariant, or has a culture.
+ ///
+ /// Culture is case-insensitive.
+ public static bool IsInvariantOrHasCulture(this IPublishedContent content, string culture)
+ => !content.ContentType.VariesByCulture() || content.Cultures.ContainsKey(culture ?? "");
+
+ ///
+ /// Filters a sequence of to return invariant items, and items that are published for the specified culture.
+ ///
+ /// The content items.
+ /// The specific culture to filter for. If null is used the current culture is used. (Default is null).
+ internal static IEnumerable WhereIsInvariantOrHasCulture(this IEnumerable contents, string culture = null)
+ where T : class, IPublishedContent
+ {
+ if (contents == null) throw new ArgumentNullException(nameof(contents));
+
+ culture = culture ?? Current.VariationContextAccessor.VariationContext?.Culture ?? "";
+
+ // either does not vary by culture, or has the specified culture
+ return contents.Where(x => !x.ContentType.VariesByCulture() || HasCulture(x, culture));
+ }
+
+ ///
+ /// Gets the name of the content item.
+ ///
+ /// The content item.
+ /// The specific culture to get the name for. If null is used the current culture is used (Default is null).
+ public static string Name(this IPublishedContent content, string culture = null)
+ {
+ // invariant has invariant value (whatever the requested culture)
+ if (!content.ContentType.VariesByCulture())
+ return content.Cultures.TryGetValue("", out var invariantInfos) ? invariantInfos.Name : null;
+
+ // handle context culture for variant
+ if (culture == null)
+ culture = VariationContextAccessor?.VariationContext?.Culture ?? "";
+
+ // get
+ return culture != "" && content.Cultures.TryGetValue(culture, out var infos) ? infos.Name : null;
+ }
+
+
+ ///
+ /// Gets the url segment of the content item.
+ ///
+ /// The content item.
+ /// The specific culture to get the url segment for. If null is used the current culture is used (Default is null).
+ public static string UrlSegment(this IPublishedContent content, string culture = null)
+ {
+ // invariant has invariant value (whatever the requested culture)
+ if (!content.ContentType.VariesByCulture())
+ return content.Cultures.TryGetValue("", out var invariantInfos) ? invariantInfos.UrlSegment : null;
+
+ // handle context culture for variant
+ if (culture == null)
+ culture = VariationContextAccessor?.VariationContext?.Culture ?? "";
+
+ // get
+ return culture != "" && content.Cultures.TryGetValue(culture, out var infos) ? infos.UrlSegment : null;
+ }
+
+ ///
+ /// Gets the culture date of the content item.
+ ///
+ /// The content item.
+ /// The specific culture to get the name for. If null is used the current culture is used (Default is null).
+ public static DateTime CultureDate(this IPublishedContent content, string culture = null)
+ {
+ // invariant has invariant value (whatever the requested culture)
+ if (!content.ContentType.VariesByCulture())
+ return content.UpdateDate;
+
+ // handle context culture for variant
+ if (culture == null)
+ culture = VariationContextAccessor?.VariationContext?.Culture ?? "";
+
+ // get
+ return culture != "" && content.Cultures.TryGetValue(culture, out var infos) ? infos.Date : DateTime.MinValue;
+ }
+
+
+ ///
+ /// Gets the children of the content item.
+ ///
+ /// The content item.
+ /// The specific culture to get the url children for. If null is used the current culture is used (Default is null).
+ ///
+ /// Gets children that are available for the specified culture.
+ /// Children are sorted by their sortOrder.
+ /// The '*' culture and supported and returns everything.
+ ///
+ public static IEnumerable Children(this IPublishedContent content, string culture = null)
+ {
+ // invariant has invariant value (whatever the requested culture)
+ if (!content.ContentType.VariesByCulture() && culture != "*")
+ culture = "";
+
+ // handle context culture for variant
+ if (culture == null)
+ culture = VariationContextAccessor?.VariationContext?.Culture ?? "";
+
+ var children = content.ChildrenForAllCultures;
+ return culture == "*"
+ ? children
+ : children.Where(x => x.IsInvariantOrHasCulture(culture));
+ }
+ }
+}
diff --git a/src/Umbraco.Core/PublishedModelFactoryExtensions.cs b/src/Umbraco.Core/PublishedModelFactoryExtensions.cs
index 4e026490a4..de6eeb6a42 100644
--- a/src/Umbraco.Core/PublishedModelFactoryExtensions.cs
+++ b/src/Umbraco.Core/PublishedModelFactoryExtensions.cs
@@ -9,7 +9,14 @@ namespace Umbraco.Core
public static class PublishedModelFactoryExtensions
{
///
- /// Executes an action with a safe live factory/
+ /// Returns true if the current is an implementation of
+ ///
+ ///
+ ///
+ public static bool IsLiveFactory(this IPublishedModelFactory factory) => factory is ILivePublishedModelFactory;
+
+ ///
+ /// Executes an action with a safe live factory
///
///
/// If the factory is a live factory, ensures it is refreshed and locked while executing the action.
@@ -20,6 +27,7 @@ namespace Umbraco.Core
{
lock (liveFactory.SyncRoot)
{
+ //Call refresh on the live factory to re-compile the models
liveFactory.Refresh();
action();
}
diff --git a/src/Umbraco.Core/Runtime/CoreInitialComposer.cs b/src/Umbraco.Core/Runtime/CoreInitialComposer.cs
index f32a46f3f8..1f004846d0 100644
--- a/src/Umbraco.Core/Runtime/CoreInitialComposer.cs
+++ b/src/Umbraco.Core/Runtime/CoreInitialComposer.cs
@@ -58,7 +58,7 @@ namespace Umbraco.Core.Runtime
composition.RegisterUnique();
// register our predefined validators
- composition.WithCollectionBuilder()
+ composition.ManifestValueValidators()
.Add()
.Add()
.Add()
@@ -66,6 +66,9 @@ namespace Umbraco.Core.Runtime
.Add()
.Add();
+ // register the manifest filter collection builder (collection is empty by default)
+ composition.ManifestFilters();
+
// properties and parameters derive from data editors
composition.WithCollectionBuilder()
.Add(() => composition.TypeLoader.GetDataEditors());
diff --git a/src/Umbraco.Core/Services/Changes/TreeChangeExtensions.cs b/src/Umbraco.Core/Services/Changes/TreeChangeExtensions.cs
index b3d15bd612..a5f5efdba9 100644
--- a/src/Umbraco.Core/Services/Changes/TreeChangeExtensions.cs
+++ b/src/Umbraco.Core/Services/Changes/TreeChangeExtensions.cs
@@ -2,9 +2,9 @@
namespace Umbraco.Core.Services.Changes
{
- internal static class TreeChangeExtensions
+ public static class TreeChangeExtensions
{
- public static TreeChange.EventArgs ToEventArgs(this IEnumerable> changes)
+ internal static TreeChange.EventArgs ToEventArgs(this IEnumerable> changes)
{
return new TreeChange.EventArgs(changes);
}
diff --git a/src/Umbraco.Core/Services/ContentServiceExtensions.cs b/src/Umbraco.Core/Services/ContentServiceExtensions.cs
index 1175df81dc..dfe02ba690 100644
--- a/src/Umbraco.Core/Services/ContentServiceExtensions.cs
+++ b/src/Umbraco.Core/Services/ContentServiceExtensions.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Text.RegularExpressions;
using Umbraco.Core.Models;
using Umbraco.Core.Models.Membership;
@@ -11,6 +12,42 @@ namespace Umbraco.Core.Services
///
public static class ContentServiceExtensions
{
+ #region RTE Anchor values
+
+ private static readonly Regex AnchorRegex = new Regex("", RegexOptions.Compiled);
+
+ internal static IEnumerable GetAnchorValuesFromRTEs(this IContentService contentService, int id, string culture = "*")
+ {
+ var result = new List();
+ var content = contentService.GetById(id);
+
+ foreach (var contentProperty in content.Properties)
+ {
+ if (contentProperty.PropertyType.PropertyEditorAlias.InvariantEquals(Constants.PropertyEditors.Aliases.TinyMce))
+ {
+ var value = contentProperty.GetValue(culture)?.ToString();
+ if (!string.IsNullOrEmpty(value))
+ {
+ result.AddRange(contentService.GetAnchorValuesFromRTEContent(value));
+ }
+ }
+ }
+ return result;
+ }
+
+
+ internal static IEnumerable GetAnchorValuesFromRTEContent(this IContentService contentService, string rteContent)
+ {
+ var result = new List();
+ var matches = AnchorRegex.Matches(rteContent);
+ foreach (Match match in matches)
+ {
+ result.Add(match.Value.Split('\"')[1]);
+ }
+ return result;
+ }
+ #endregion
+
public static IEnumerable GetByIds(this IContentService contentService, IEnumerable ids)
{
var guids = new List();
diff --git a/src/Umbraco.Core/Services/DateTypeServiceExtensions.cs b/src/Umbraco.Core/Services/DateTypeServiceExtensions.cs
new file mode 100644
index 0000000000..3b72a6f258
--- /dev/null
+++ b/src/Umbraco.Core/Services/DateTypeServiceExtensions.cs
@@ -0,0 +1,21 @@
+using System;
+using Umbraco.Core.Models;
+using Umbraco.Core.PropertyEditors;
+
+namespace Umbraco.Core.Services
+{
+ internal static class DateTypeServiceExtensions
+ {
+ public static bool IsDataTypeIgnoringUserStartNodes(this IDataTypeService dataTypeService, Guid key)
+ {
+ if (DataTypeExtensions.IsBuildInDataType(key)) return false; //built in ones can never be ignoring start nodes
+
+ var dataType = dataTypeService.GetDataType(key);
+
+ if (dataType != null && dataType.Configuration is IIgnoreUserStartNodesConfig ignoreStartNodesConfig)
+ return ignoreStartNodesConfig.IgnoreUserStartNodes;
+
+ return false;
+ }
+ }
+}
diff --git a/src/Umbraco.Core/Services/IContentService.cs b/src/Umbraco.Core/Services/IContentService.cs
index 48e577a8f0..6f9ca58821 100644
--- a/src/Umbraco.Core/Services/IContentService.cs
+++ b/src/Umbraco.Core/Services/IContentService.cs
@@ -526,5 +526,6 @@ namespace Umbraco.Core.Services
OperationResult Rollback(int id, int versionId, string culture = "*", int userId = Constants.Security.SuperUserId);
#endregion
+
}
}
diff --git a/src/Umbraco.Core/Services/IDataTypeService.cs b/src/Umbraco.Core/Services/IDataTypeService.cs
index 3dc530e250..bb56e110cd 100644
--- a/src/Umbraco.Core/Services/IDataTypeService.cs
+++ b/src/Umbraco.Core/Services/IDataTypeService.cs
@@ -4,6 +4,7 @@ using Umbraco.Core.Models;
namespace Umbraco.Core.Services
{
+
///
/// Defines the DataType Service, which is an easy access to operations involving
///
diff --git a/src/Umbraco.Core/Services/Implement/AuditService.cs b/src/Umbraco.Core/Services/Implement/AuditService.cs
index 46c851a789..5eb08f2dea 100644
--- a/src/Umbraco.Core/Services/Implement/AuditService.cs
+++ b/src/Umbraco.Core/Services/Implement/AuditService.cs
@@ -51,8 +51,8 @@ namespace Umbraco.Core.Services.Implement
using (var scope = ScopeProvider.CreateScope())
{
var result = sinceDate.HasValue == false
- ? _auditRepository.Get(Query().Where(x => x.UserId == userId && x.AuditType == type))
- : _auditRepository.Get(Query().Where(x => x.UserId == userId && x.AuditType == type && x.CreateDate >= sinceDate.Value));
+ ? _auditRepository.Get(type, Query().Where(x => x.UserId == userId))
+ : _auditRepository.Get(type, Query().Where(x => x.UserId == userId && x.CreateDate >= sinceDate.Value));
scope.Complete();
return result;
}
@@ -63,8 +63,8 @@ namespace Umbraco.Core.Services.Implement
using (var scope = ScopeProvider.CreateScope())
{
var result = sinceDate.HasValue == false
- ? _auditRepository.Get(Query().Where(x => x.AuditType == type))
- : _auditRepository.Get(Query().Where(x => x.AuditType == type && x.CreateDate >= sinceDate.Value));
+ ? _auditRepository.Get(type, Query())
+ : _auditRepository.Get(type, Query().Where(x => x.CreateDate >= sinceDate.Value));
scope.Complete();
return result;
}
diff --git a/src/Umbraco.Core/Services/Implement/ContentService.cs b/src/Umbraco.Core/Services/Implement/ContentService.cs
index 5cc1a584b1..e49dcf4a12 100644
--- a/src/Umbraco.Core/Services/Implement/ContentService.cs
+++ b/src/Umbraco.Core/Services/Implement/ContentService.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Linq;
+using System.Text.RegularExpressions;
using Umbraco.Core.Events;
using Umbraco.Core.Exceptions;
using Umbraco.Core.Logging;
@@ -31,6 +32,7 @@ namespace Umbraco.Core.Services.Implement
private IQuery _queryNotTrashed;
//TODO: The non-lazy object should be injected
private readonly Lazy _propertyValidationService = new Lazy(() => new PropertyValidationService());
+
#region Constructors
@@ -1695,12 +1697,11 @@ namespace Umbraco.Core.Services.Implement
}
const int pageSize = 500;
- var page = 0;
var total = long.MaxValue;
- while (page * pageSize < total)
+ while (total > 0)
{
//get descendants - ordered from deepest to shallowest
- var descendants = GetPagedDescendants(content.Id, page, pageSize, out total, ordering: Ordering.By("Path", Direction.Descending));
+ var descendants = GetPagedDescendants(content.Id, 0, pageSize, out total, ordering: Ordering.By("Path", Direction.Descending));
foreach (var c in descendants)
DoDelete(c);
}
@@ -1926,11 +1927,10 @@ namespace Umbraco.Core.Services.Implement
paths[content.Id] = (parent == null ? (parentId == Constants.System.RecycleBinContent ? "-1,-20" : Constants.System.RootString) : parent.Path) + "," + content.Id;
const int pageSize = 500;
- var page = 0;
var total = long.MaxValue;
- while (page * pageSize < total)
+ while (total > 0)
{
- var descendants = GetPagedDescendantsLocked(originalPath, page++, pageSize, out total, null, Ordering.By("Path", Direction.Ascending));
+ var descendants = GetPagedDescendantsLocked(originalPath, 0, pageSize, out total, null, Ordering.By("Path", Direction.Ascending));
foreach (var descendant in descendants)
{
moves.Add(Tuple.Create(descendant, descendant.Path)); // capture original path
@@ -3026,5 +3026,8 @@ namespace Umbraco.Core.Services.Implement
}
#endregion
+
+
+
}
}
diff --git a/src/Umbraco.Core/Services/Implement/MediaService.cs b/src/Umbraco.Core/Services/Implement/MediaService.cs
index 2ff39f7f7d..ab075c4ade 100644
--- a/src/Umbraco.Core/Services/Implement/MediaService.cs
+++ b/src/Umbraco.Core/Services/Implement/MediaService.cs
@@ -201,7 +201,7 @@ namespace Umbraco.Core.Services.Implement
var mediaType = GetMediaType(mediaTypeAlias);
if (mediaType == null)
- throw new ArgumentException("No media type with that alias.", nameof(mediaTypeAlias)); // causes rollback // causes rollback
+ throw new ArgumentException("No media type with that alias.", nameof(mediaTypeAlias)); // causes rollback
var media = new Models.Media(name, parent, mediaType);
CreateMedia(scope, media, parent, userId, false);
@@ -227,13 +227,13 @@ namespace Umbraco.Core.Services.Implement
// locking the media tree secures media types too
scope.WriteLock(Constants.Locks.MediaTree);
- var mediaType = GetMediaType(mediaTypeAlias); // + locks // + locks
+ var mediaType = GetMediaType(mediaTypeAlias); // + locks
if (mediaType == null)
- throw new ArgumentException("No media type with that alias.", nameof(mediaTypeAlias)); // causes rollback // causes rollback
+ throw new ArgumentException("No media type with that alias.", nameof(mediaTypeAlias)); // causes rollback
- var parent = parentId > 0 ? GetById(parentId) : null; // + locks // + locks
+ var parent = parentId > 0 ? GetById(parentId) : null; // + locks
if (parentId > 0 && parent == null)
- throw new ArgumentException("No media with that id.", nameof(parentId)); // causes rollback // causes rollback
+ throw new ArgumentException("No media with that id.", nameof(parentId)); // causes rollback
var media = parentId > 0 ? new Models.Media(name, parent, mediaType) : new Models.Media(name, parentId, mediaType);
CreateMedia(scope, media, parent, userId, true);
@@ -261,9 +261,9 @@ namespace Umbraco.Core.Services.Implement
// locking the media tree secures media types too
scope.WriteLock(Constants.Locks.MediaTree);
- var mediaType = GetMediaType(mediaTypeAlias); // + locks // + locks
+ var mediaType = GetMediaType(mediaTypeAlias); // + locks
if (mediaType == null)
- throw new ArgumentException("No media type with that alias.", nameof(mediaTypeAlias)); // causes rollback // causes rollback
+ throw new ArgumentException("No media type with that alias.", nameof(mediaTypeAlias)); // causes rollback
var media = new Models.Media(name, parent, mediaType);
CreateMedia(scope, media, parent, userId, true);
@@ -645,8 +645,6 @@ namespace Umbraco.Core.Services.Implement
}
// poor man's validation?
- // poor man's validation?
-
if (string.IsNullOrWhiteSpace(media.Name))
throw new ArgumentException("Media has no name.", nameof(media));
@@ -934,7 +932,7 @@ namespace Umbraco.Core.Services.Implement
var parent = parentId == Constants.System.Root ? null : GetById(parentId);
if (parentId != Constants.System.Root && (parent == null || parent.Trashed))
- throw new InvalidOperationException("Parent does not exist or is trashed."); // causes rollback // causes rollback
+ throw new InvalidOperationException("Parent does not exist or is trashed."); // causes rollback
var moveEventInfo = new MoveEventInfo(media, media.Path, parentId);
var moveEventArgs = new MoveEventArgs(true, evtMsgs, moveEventInfo);
@@ -947,12 +945,6 @@ namespace Umbraco.Core.Services.Implement
// if media was trashed, and since we're not moving to the recycle bin,
// indicate that the trashed status should be changed to false, else just
// leave it unchanged
- // if media was trashed, and since we're not moving to the recycle bin,
-
- // indicate that the trashed status should be changed to false, else just
-
- // leave it unchanged
-
var trashed = media.Trashed ? false : (bool?) null;
PerformMoveLocked(media, parentId, parent, userId, moves, trashed);
@@ -1042,17 +1034,11 @@ namespace Umbraco.Core.Services.Implement
{
scope.WriteLock(Constants.Locks.MediaTree);
+ // no idea what those events are for, keep a simplified version
+
// v7 EmptyingRecycleBin and EmptiedRecycleBin events are greatly simplified since
// each deleted items will have its own deleting/deleted events. so, files and such
// are managed by Delete, and not here.
-
- // no idea what those events are for, keep a simplified version
- // v7 EmptyingRecycleBin and EmptiedRecycleBin events are greatly simplified since
- // each deleted items will have its own deleting/deleted events. so, files and such
-
- // emptying the recycle bin means deleting whatever is in there - do it properly!
- // are managed by Delete, and not here.
- // no idea what those events are for, keep a simplified version
var args = new RecycleBinEventArgs(nodeObjectType, evtMsgs);
if (scope.Events.DispatchCancelable(EmptyingRecycleBin, this, args))
@@ -1113,11 +1099,6 @@ namespace Umbraco.Core.Services.Implement
{
// if the current sort order equals that of the media we don't
// need to update it, so just increment the sort order and continue.
- // if the current sort order equals that of the media we don't
-
- // else update
- // need to update it, so just increment the sort order and continue.
- // save
if (media.SortOrder == sortOrder)
{
sortOrder++;
diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj
index 65962dae7c..59f691251b 100755
--- a/src/Umbraco.Core/Umbraco.Core.csproj
+++ b/src/Umbraco.Core/Umbraco.Core.csproj
@@ -13,7 +13,7 @@
true
- full
+ portable
false
bin\Debug\
TRACE;DEBUG
@@ -23,7 +23,7 @@
latest
- pdbonly
+ portable
true
bin\Release\
TRACE
@@ -55,6 +55,11 @@
+
+ 1.0.0-beta2-19324-01
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+
1.3.0
@@ -216,6 +221,9 @@
+
+
+
@@ -231,6 +239,7 @@
+
@@ -246,7 +255,6 @@
-
@@ -288,6 +296,11 @@
+
+
+
+
+
@@ -316,6 +329,7 @@
+
@@ -447,12 +461,6 @@
-
-
-
-
-
-
@@ -1229,4 +1237,4 @@
-
\ No newline at end of file
+
diff --git a/src/Umbraco.Examine/Umbraco.Examine.csproj b/src/Umbraco.Examine/Umbraco.Examine.csproj
index 166f2f1025..2b4f518259 100644
--- a/src/Umbraco.Examine/Umbraco.Examine.csproj
+++ b/src/Umbraco.Examine/Umbraco.Examine.csproj
@@ -13,7 +13,7 @@
true
- full
+ portable
false
bin\Debug\
DEBUG;TRACE
@@ -23,7 +23,7 @@
latest
- pdbonly
+ portable
true
bin\Release\
TRACE
@@ -49,6 +49,11 @@
+
+ 1.0.0-beta2-19324-01
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+
diff --git a/src/Umbraco.ModelsBuilder/Umbraco.ModelsBuilder.csproj b/src/Umbraco.ModelsBuilder/Umbraco.ModelsBuilder.csproj
index b9a5890d57..60ef944a8c 100644
--- a/src/Umbraco.ModelsBuilder/Umbraco.ModelsBuilder.csproj
+++ b/src/Umbraco.ModelsBuilder/Umbraco.ModelsBuilder.csproj
@@ -14,7 +14,7 @@
true
- full
+ portable
false
bin\Debug\
DEBUG;TRACE
@@ -22,7 +22,7 @@
4
- pdbonly
+ portable
true
bin\Release\
TRACE
@@ -103,6 +103,11 @@
2.8.0
+
+ 1.0.0-beta2-19324-01
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+
diff --git a/src/Umbraco.Tests/Cache/PublishedCache/PublishedContentCacheTests.cs b/src/Umbraco.Tests/Cache/PublishedCache/PublishedContentCacheTests.cs
index fbf828ad20..be160a483c 100644
--- a/src/Umbraco.Tests/Cache/PublishedCache/PublishedContentCacheTests.cs
+++ b/src/Umbraco.Tests/Cache/PublishedCache/PublishedContentCacheTests.cs
@@ -68,9 +68,9 @@ namespace Umbraco.Tests.Cache.PublishedCache
var appCache = new DictionaryAppCache();
var domainCache = new DomainCache(ServiceContext.DomainService, DefaultCultureAccessor);
var publishedShapshot = new PublishedSnapshot(
- new PublishedContentCache(xmlStore, domainCache, appCache, globalSettings, new SiteDomainHelper(), umbracoContextAccessor, ContentTypesCache, null, null),
+ new PublishedContentCache(xmlStore, domainCache, appCache, globalSettings, ContentTypesCache, null, null),
new PublishedMediaCache(xmlStore, ServiceContext.MediaService, ServiceContext.UserService, appCache, ContentTypesCache, Factory.GetInstance(), umbracoContextAccessor),
- new PublishedMemberCache(null, appCache, Current.Services.MemberService, ContentTypesCache, umbracoContextAccessor),
+ new PublishedMemberCache(null, appCache, Current.Services.MemberService, ContentTypesCache),
domainCache);
var publishedSnapshotService = new Mock();
publishedSnapshotService.Setup(x => x.CreatePublishedSnapshot(It.IsAny())).Returns(publishedShapshot);
@@ -85,7 +85,7 @@ namespace Umbraco.Tests.Cache.PublishedCache
globalSettings,
new TestVariationContextAccessor());
- _cache = _umbracoContext.ContentCache;
+ _cache = _umbracoContext.Content;
}
[Test]
diff --git a/src/Umbraco.Tests/Cache/PublishedCache/PublishedMediaCacheTests.cs b/src/Umbraco.Tests/Cache/PublishedCache/PublishedMediaCacheTests.cs
index 08eeb8ef4d..f3d9f895ef 100644
--- a/src/Umbraco.Tests/Cache/PublishedCache/PublishedMediaCacheTests.cs
+++ b/src/Umbraco.Tests/Cache/PublishedCache/PublishedMediaCacheTests.cs
@@ -323,8 +323,7 @@ namespace Umbraco.Tests.Cache.PublishedCache
// no xpath
null,
// not from examine
- false,
- _umbracoContextAccessor),
+ false),
//callback to get the children
(dd, n) => children,
// callback to get a property
@@ -334,8 +333,7 @@ namespace Umbraco.Tests.Cache.PublishedCache
// no xpath
null,
// not from examine
- false,
- _umbracoContextAccessor);
+ false);
return dicDoc;
}
diff --git a/src/Umbraco.Tests/LegacyXmlPublishedCache/DictionaryPublishedContent.cs b/src/Umbraco.Tests/LegacyXmlPublishedCache/DictionaryPublishedContent.cs
index d3cbf1f183..db8dc38d6d 100644
--- a/src/Umbraco.Tests/LegacyXmlPublishedCache/DictionaryPublishedContent.cs
+++ b/src/Umbraco.Tests/LegacyXmlPublishedCache/DictionaryPublishedContent.cs
@@ -8,7 +8,6 @@ using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Core.Logging;
using Umbraco.Core.Models.PublishedContent;
-using Umbraco.Web;
using Umbraco.Web.Composing;
using Umbraco.Web.Models;
using Umbraco.Web.PublishedCache;
@@ -40,9 +39,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
IAppCache appCache,
PublishedContentTypeCache contentTypeCache,
XPathNavigator nav,
- bool fromExamine,
- IUmbracoContextAccessor umbracoContextAccessor)
- :base(umbracoContextAccessor)
+ bool fromExamine)
{
if (valueDictionary == null) throw new ArgumentNullException(nameof(valueDictionary));
if (getParent == null) throw new ArgumentNullException(nameof(getParent));
@@ -158,8 +155,6 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
public override string Name => _name;
- public override PublishedCultureInfo GetCulture(string culture = null) => null;
-
private static readonly Lazy> NoCultures = new Lazy>(() => new Dictionary());
public override IReadOnlyDictionary Cultures => NoCultures.Value;
@@ -189,12 +184,14 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
public override IEnumerable Children => _getChildren.Value;
+ public override IEnumerable ChildrenForAllCultures => Children;
+
public override IPublishedProperty GetProperty(string alias)
{
return _getProperty(this, alias);
}
- public override PublishedContentType ContentType => _contentType;
+ public override IPublishedContentType ContentType => _contentType;
private readonly List _keysAdded = new List();
private int _id;
@@ -215,7 +212,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
//private Guid _version;
private int _level;
private readonly ICollection _properties;
- private readonly PublishedContentType _contentType;
+ private readonly IPublishedContentType _contentType;
private void ValidateAndSetProperty(IReadOnlyDictionary valueDictionary, Action setProperty, params string[] potentialKeys)
{
diff --git a/src/Umbraco.Tests/LegacyXmlPublishedCache/DomainCache.cs b/src/Umbraco.Tests/LegacyXmlPublishedCache/DomainCache.cs
index cde2077551..abaa239598 100644
--- a/src/Umbraco.Tests/LegacyXmlPublishedCache/DomainCache.cs
+++ b/src/Umbraco.Tests/LegacyXmlPublishedCache/DomainCache.cs
@@ -27,13 +27,18 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
}
///
- public IEnumerable GetAssigned(int contentId, bool includeWildcards)
+ public IEnumerable GetAssigned(int documentId, bool includeWildcards = false)
{
- return _domainService.GetAssignedDomains(contentId, includeWildcards)
+ return _domainService.GetAssignedDomains(documentId, includeWildcards)
.Where(x => x.RootContentId.HasValue && x.LanguageIsoCode.IsNullOrWhiteSpace() == false)
.Select(x => new Domain(x.Id, x.DomainName, x.RootContentId.Value, CultureInfo.GetCultureInfo(x.LanguageIsoCode), x.IsWildcard));
}
+ ///
+ public bool HasAssigned(int documentId, bool includeWildcards = false)
+ => documentId > 0 && GetAssigned(documentId, includeWildcards).Any();
+
+ ///
public string DefaultCulture { get; }
}
}
diff --git a/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedContentCache.cs b/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedContentCache.cs
index 2a144f3aaa..8ce6b10983 100644
--- a/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedContentCache.cs
+++ b/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedContentCache.cs
@@ -9,7 +9,6 @@ using Umbraco.Core.Cache;
using Umbraco.Core.Configuration;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Core.Xml;
-using Umbraco.Web;
using Umbraco.Web.PublishedCache;
using Umbraco.Web.Routing;
@@ -19,10 +18,8 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
{
private readonly IAppCache _appCache;
private readonly IGlobalSettings _globalSettings;
- private readonly IUmbracoContextAccessor _umbracoContextAccessor;
private readonly RoutesCache _routesCache;
private readonly IDomainCache _domainCache;
- private readonly DomainHelper _domainHelper;
private readonly PublishedContentTypeCache _contentTypeCache;
// initialize a PublishedContentCache instance with
@@ -35,8 +32,6 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
IDomainCache domainCache, // an IDomainCache implementation
IAppCache appCache, // an IAppCache that should be at request-level
IGlobalSettings globalSettings,
- ISiteDomainHelper siteDomainHelper,
- IUmbracoContextAccessor umbracoContextAccessor,
PublishedContentTypeCache contentTypeCache, // a PublishedContentType cache
RoutesCache routesCache, // a RoutesCache
string previewToken) // a preview token string (or null if not previewing)
@@ -44,11 +39,9 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
{
_appCache = appCache;
_globalSettings = globalSettings;
- _umbracoContextAccessor = umbracoContextAccessor;
_routesCache = routesCache; // may be null for unit-testing
_contentTypeCache = contentTypeCache;
_domainCache = domainCache;
- _domainHelper = new DomainHelper(_domainCache, siteDomainHelper);
_xmlStore = xmlStore;
_xml = _xmlStore.Xml; // capture - because the cache has to remain consistent
@@ -107,7 +100,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
// that would be returned - the "deepest" route - and that is the route we want to cache, *not* the
// longer one - so make sure we don't cache the wrong route
- var deepest = DomainHelper.ExistsDomainInPath(_domainCache.GetAll(false), content.Path, domainRootNodeId) == false;
+ var deepest = DomainUtilities.ExistsDomainInPath(_domainCache.GetAll(false), content.Path, domainRootNodeId) == false;
if (deepest)
_routesCache.Store(content.Id, route, true); // trusted route
@@ -267,16 +260,16 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
// or we reach the content root, collecting urls in the way
var pathParts = new List();
var n = node;
- var hasDomains = _domainHelper.NodeHasDomains(n.Id);
+ var hasDomains = _domainCache.HasAssigned(n.Id);
while (hasDomains == false && n != null) // n is null at root
{
// get the url
- var urlName = n.UrlSegment;
+ var urlName = n.UrlSegment();
pathParts.Add(urlName);
// move to parent node
n = n.Parent;
- hasDomains = n != null && _domainHelper.NodeHasDomains(n.Id);
+ hasDomains = n != null && _domainCache.HasAssigned(n.Id);
}
// no domain, respect HideTopLevelNodeFromPath for legacy purposes
@@ -320,13 +313,13 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
private IPublishedContent ConvertToDocument(XmlNode xmlNode, bool isPreviewing)
{
- return xmlNode == null ? null : XmlPublishedContent.Get(xmlNode, isPreviewing, _appCache, _contentTypeCache,_umbracoContextAccessor);
+ return xmlNode == null ? null : XmlPublishedContent.Get(xmlNode, isPreviewing, _appCache, _contentTypeCache);
}
private IEnumerable ConvertToDocuments(XmlNodeList xmlNodes, bool isPreviewing)
{
return xmlNodes.Cast()
- .Select(xmlNode => XmlPublishedContent.Get(xmlNode, isPreviewing, _appCache, _contentTypeCache, _umbracoContextAccessor));
+ .Select(xmlNode => XmlPublishedContent.Get(xmlNode, isPreviewing, _appCache, _contentTypeCache));
}
#endregion
@@ -389,7 +382,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
return GetXml(preview).CreateNavigator().MoveToId(contentId.ToString(CultureInfo.InvariantCulture));
}
- public override IEnumerable GetAtRoot(bool preview)
+ public override IEnumerable GetAtRoot(bool preview, string culture = null)
{
return ConvertToDocuments(GetXml(preview).SelectNodes(XPathStrings.RootDocuments), preview);
}
@@ -539,12 +532,12 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
#region Content types
- public override PublishedContentType GetContentType(int id)
+ public override IPublishedContentType GetContentType(int id)
{
return _contentTypeCache.Get(PublishedItemType.Content, id);
}
- public override PublishedContentType GetContentType(string alias)
+ public override IPublishedContentType GetContentType(string alias)
{
return _contentTypeCache.Get(PublishedItemType.Content, alias);
}
diff --git a/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedMediaCache.cs b/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedMediaCache.cs
index 0c7ee98c6d..999d7f040d 100644
--- a/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedMediaCache.cs
+++ b/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedMediaCache.cs
@@ -105,7 +105,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
return GetUmbracoMedia(contentId) != null;
}
- public override IEnumerable GetAtRoot(bool preview)
+ public override IEnumerable GetAtRoot(bool preview, string culture = null)
{
var searchProvider = GetSearchProviderSafe();
@@ -612,17 +612,17 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
#region Content types
- public override PublishedContentType GetContentType(int id)
+ public override IPublishedContentType GetContentType(int id)
{
return _contentTypeCache.Get(PublishedItemType.Media, id);
}
- public override PublishedContentType GetContentType(string alias)
+ public override IPublishedContentType GetContentType(string alias)
{
return _contentTypeCache.Get(PublishedItemType.Media, alias);
}
- public override IEnumerable GetByContentType(PublishedContentType contentType)
+ public override IEnumerable GetByContentType(IPublishedContentType contentType)
{
throw new NotSupportedException();
}
@@ -674,8 +674,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
_appCache,
_contentTypeCache,
cacheValues.XPath, // though, outside of tests, that should be null
- cacheValues.FromExamine,
- _umbracoContextAccessor
+ cacheValues.FromExamine
);
return content.CreateModel();
}
diff --git a/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedMemberCache.cs b/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedMemberCache.cs
index c882488f20..19328c241e 100644
--- a/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedMemberCache.cs
+++ b/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedMemberCache.cs
@@ -6,7 +6,6 @@ using Umbraco.Core.Models;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Core.Security;
using Umbraco.Core.Services;
-using Umbraco.Web;
using Umbraco.Web.PublishedCache;
using Umbraco.Web.Security;
@@ -18,16 +17,13 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
private readonly IAppCache _requestCache;
private readonly XmlStore _xmlStore;
private readonly PublishedContentTypeCache _contentTypeCache;
- private readonly IUmbracoContextAccessor _umbracoContextAccessor;
- public PublishedMemberCache(XmlStore xmlStore, IAppCache requestCache, IMemberService memberService,
- PublishedContentTypeCache contentTypeCache, IUmbracoContextAccessor umbracoContextAccessor)
+ public PublishedMemberCache(XmlStore xmlStore, IAppCache requestCache, IMemberService memberService, PublishedContentTypeCache contentTypeCache)
{
_requestCache = requestCache;
_memberService = memberService;
_xmlStore = xmlStore;
_contentTypeCache = contentTypeCache;
- _umbracoContextAccessor = umbracoContextAccessor;
}
public IPublishedContent GetByProviderKey(object key)
@@ -44,7 +40,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
var result = _memberService.GetByProviderKey(key);
if (result == null) return null;
var type = _contentTypeCache.Get(PublishedItemType.Member, result.ContentTypeId);
- return new PublishedMember(result, type, _umbracoContextAccessor).CreateModel();
+ return new PublishedMember(result, type).CreateModel();
});
}
@@ -62,7 +58,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
var result = _memberService.GetById(memberId);
if (result == null) return null;
var type = _contentTypeCache.Get(PublishedItemType.Member, result.ContentTypeId);
- return new PublishedMember(result, type, _umbracoContextAccessor).CreateModel();
+ return new PublishedMember(result, type).CreateModel();
});
}
@@ -80,7 +76,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
var result = _memberService.GetByUsername(username);
if (result == null) return null;
var type = _contentTypeCache.Get(PublishedItemType.Member, result.ContentTypeId);
- return new PublishedMember(result, type, _umbracoContextAccessor).CreateModel();
+ return new PublishedMember(result, type).CreateModel();
});
}
@@ -98,14 +94,14 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
var result = _memberService.GetByEmail(email);
if (result == null) return null;
var type = _contentTypeCache.Get(PublishedItemType.Member, result.ContentTypeId);
- return new PublishedMember(result, type, _umbracoContextAccessor).CreateModel();
+ return new PublishedMember(result, type).CreateModel();
});
}
public IPublishedContent GetByMember(IMember member)
{
var type = _contentTypeCache.Get(PublishedItemType.Member, member.ContentTypeId);
- return new PublishedMember(member, type, _umbracoContextAccessor).CreateModel();
+ return new PublishedMember(member, type).CreateModel();
}
public XPathNavigator CreateNavigator()
@@ -138,12 +134,12 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
#region Content types
- public PublishedContentType GetContentType(int id)
+ public IPublishedContentType GetContentType(int id)
{
return _contentTypeCache.Get(PublishedItemType.Member, id);
}
- public PublishedContentType GetContentType(string alias)
+ public IPublishedContentType GetContentType(string alias)
{
return _contentTypeCache.Get(PublishedItemType.Member, alias);
}
diff --git a/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedSnapshotService.cs b/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedSnapshotService.cs
index 4a201ae44c..394a33d777 100644
--- a/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedSnapshotService.cs
+++ b/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedSnapshotService.cs
@@ -145,9 +145,9 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
var domainCache = new DomainCache(_domainService, _defaultCultureAccessor);
return new PublishedSnapshot(
- new PublishedContentCache(_xmlStore, domainCache, _requestCache, _globalSettings, _siteDomainHelper,_umbracoContextAccessor, _contentTypeCache, _routesCache, previewToken),
+ new PublishedContentCache(_xmlStore, domainCache, _requestCache, _globalSettings, _contentTypeCache, _routesCache, previewToken),
new PublishedMediaCache(_xmlStore, _mediaService, _userService, _requestCache, _contentTypeCache, _entitySerializer, _umbracoContextAccessor),
- new PublishedMemberCache(_xmlStore, _requestCache, _memberService, _contentTypeCache, _umbracoContextAccessor),
+ new PublishedMemberCache(_xmlStore, _requestCache, _memberService, _contentTypeCache),
domainCache);
}
diff --git a/src/Umbraco.Tests/LegacyXmlPublishedCache/XmlPublishedContent.cs b/src/Umbraco.Tests/LegacyXmlPublishedCache/XmlPublishedContent.cs
index e1819bf0be..3697863cb4 100644
--- a/src/Umbraco.Tests/LegacyXmlPublishedCache/XmlPublishedContent.cs
+++ b/src/Umbraco.Tests/LegacyXmlPublishedCache/XmlPublishedContent.cs
@@ -26,23 +26,19 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
XmlNode xmlNode,
bool isPreviewing,
IAppCache appCache,
- PublishedContentTypeCache contentTypeCache,
- IUmbracoContextAccessor umbracoContextAccessor)
- :base(umbracoContextAccessor)
+ PublishedContentTypeCache contentTypeCache)
{
_xmlNode = xmlNode;
_isPreviewing = isPreviewing;
_appCache = appCache;
_contentTypeCache = contentTypeCache;
- _umbracoContextAccessor = umbracoContextAccessor;
}
private readonly XmlNode _xmlNode;
private readonly bool _isPreviewing;
private readonly IAppCache _appCache; // at snapshot/request level (see PublishedContentCache)
private readonly PublishedContentTypeCache _contentTypeCache;
- private readonly IUmbracoContextAccessor _umbracoContextAccessor;
private readonly object _initializeLock = new object();
@@ -53,7 +49,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
private IEnumerable _children = Enumerable.Empty();
private IPublishedContent _parent;
- private PublishedContentType _contentType;
+ private IPublishedContentType _contentType;
private Dictionary _properties;
private int _id;
@@ -84,6 +80,8 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
}
}
+ public override IEnumerable ChildrenForAllCultures => Children;
+
public override IPublishedProperty GetProperty(string alias)
{
EnsureNodeInitialized();
@@ -147,10 +145,15 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
}
}
- public override PublishedCultureInfo GetCulture(string culture = null) => null;
+ private Dictionary _cultures;
- private static readonly Lazy> NoCultures = new Lazy>(() => new Dictionary());
- public override IReadOnlyDictionary Cultures => NoCultures.Value;
+ private Dictionary GetCultures()
+ {
+ EnsureNodeInitialized();
+ return new Dictionary { { "", new PublishedCultureInfo("", _name, _urlName, _updateDate) } };
+ }
+
+ public override IReadOnlyDictionary Cultures => _cultures ?? (_cultures = GetCultures());
public override string WriterName
{
@@ -254,7 +257,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
}
}
- public override PublishedContentType ContentType
+ public override IPublishedContentType ContentType
{
get
{
@@ -269,7 +272,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
if (parent == null) return;
if (parent.Attributes?.GetNamedItem("isDoc") != null)
- _parent = Get(parent, _isPreviewing, _appCache, _contentTypeCache, _umbracoContextAccessor);
+ _parent = Get(parent, _isPreviewing, _appCache, _contentTypeCache);
_parentInitialized = true;
}
@@ -308,8 +311,8 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
out int id, out Guid key, out int template, out int sortOrder, out string name, out string writerName, out string urlName,
out string creatorName, out int creatorId, out int writerId, out string docTypeAlias, out int docTypeId, out string path,
out DateTime createDate, out DateTime updateDate, out int level, out bool isDraft,
- out PublishedContentType contentType, out Dictionary properties,
- Func getPublishedContentType)
+ out IPublishedContentType contentType, out Dictionary properties,
+ Func getPublishedContentType)
{
//initialize the out params with defaults:
writerName = null;
@@ -426,7 +429,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
var iterator = nav.Select(expr);
_children = iterator.Cast()
- .Select(n => Get(((IHasXmlNode) n).GetNode(), _isPreviewing, _appCache, _contentTypeCache, _umbracoContextAccessor))
+ .Select(n => Get(((IHasXmlNode) n).GetNode(), _isPreviewing, _appCache, _contentTypeCache))
.OrderBy(x => x.SortOrder)
.ToList();
@@ -446,7 +449,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
/// sure that we create only one instance of each for the duration of a request. The
/// returned IPublishedContent is a model, if models are enabled.
public static IPublishedContent Get(XmlNode node, bool isPreviewing, IAppCache appCache,
- PublishedContentTypeCache contentTypeCache, IUmbracoContextAccessor umbracoContextAccessor)
+ PublishedContentTypeCache contentTypeCache)
{
// only 1 per request
@@ -454,7 +457,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
var id = attrs?.GetNamedItem("id").Value;
if (id.IsNullOrWhiteSpace()) throw new InvalidOperationException("Node has no ID attribute.");
var key = CacheKeyPrefix + id; // dont bother with preview, wont change during request in Xml cache
- return (IPublishedContent) appCache.Get(key, () => (new XmlPublishedContent(node, isPreviewing, appCache, contentTypeCache, umbracoContextAccessor)).CreateModel());
+ return (IPublishedContent) appCache.Get(key, () => (new XmlPublishedContent(node, isPreviewing, appCache, contentTypeCache)).CreateModel());
}
public static void ClearRequest()
diff --git a/src/Umbraco.Tests/LegacyXmlPublishedCache/XmlPublishedProperty.cs b/src/Umbraco.Tests/LegacyXmlPublishedCache/XmlPublishedProperty.cs
index 0c90c8d1ff..7d2fa74aa6 100644
--- a/src/Umbraco.Tests/LegacyXmlPublishedCache/XmlPublishedProperty.cs
+++ b/src/Umbraco.Tests/LegacyXmlPublishedCache/XmlPublishedProperty.cs
@@ -50,7 +50,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
public override object GetXPathValue(string culture = null, string segment = null) { throw new NotImplementedException(); }
- public XmlPublishedProperty(PublishedPropertyType propertyType, IPublishedContent content, bool isPreviewing, XmlNode propertyXmlData)
+ public XmlPublishedProperty(IPublishedPropertyType propertyType, IPublishedContent content, bool isPreviewing, XmlNode propertyXmlData)
: this(propertyType, content, isPreviewing)
{
if (propertyXmlData == null)
@@ -58,7 +58,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
_sourceValue = XmlHelper.GetNodeValue(propertyXmlData);
}
- public XmlPublishedProperty(PublishedPropertyType propertyType, IPublishedContent content, bool isPreviewing, string propertyData)
+ public XmlPublishedProperty(IPublishedPropertyType propertyType, IPublishedContent content, bool isPreviewing, string propertyData)
: this(propertyType, content, isPreviewing)
{
if (propertyData == null)
@@ -66,7 +66,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
_sourceValue = propertyData;
}
- public XmlPublishedProperty(PublishedPropertyType propertyType, IPublishedContent content, bool isPreviewing)
+ public XmlPublishedProperty(IPublishedPropertyType propertyType, IPublishedContent content, bool isPreviewing)
: base(propertyType, PropertyCacheLevel.Unknown) // cache level is ignored
{
_sourceValue = string.Empty;
diff --git a/src/Umbraco.Tests/Manifest/ManifestParserTests.cs b/src/Umbraco.Tests/Manifest/ManifestParserTests.cs
index 6605bc4546..1c90f68d62 100644
--- a/src/Umbraco.Tests/Manifest/ManifestParserTests.cs
+++ b/src/Umbraco.Tests/Manifest/ManifestParserTests.cs
@@ -44,7 +44,7 @@ namespace Umbraco.Tests.Manifest
new RequiredValidator(Mock.Of()),
new RegexValidator(Mock.Of(), null)
};
- _parser = new ManifestParser(AppCaches.Disabled, new ManifestValueValidatorCollection(validators), Mock.Of());
+ _parser = new ManifestParser(AppCaches.Disabled, new ManifestValueValidatorCollection(validators), new ManifestFilterCollection(Array.Empty()), Mock.Of());
}
[Test]
diff --git a/src/Umbraco.Tests/Mapping/MappingTests.cs b/src/Umbraco.Tests/Mapping/MappingTests.cs
index 79d383857a..e6a382692c 100644
--- a/src/Umbraco.Tests/Mapping/MappingTests.cs
+++ b/src/Umbraco.Tests/Mapping/MappingTests.cs
@@ -172,6 +172,48 @@ namespace Umbraco.Tests.Mapping
}
}
+ [Test]
+ public void EnumMap()
+ {
+ var definitions = new MapDefinitionCollection(new IMapDefinition[]
+ {
+ new MapperDefinition4(),
+ });
+ var mapper = new UmbracoMapper(definitions);
+
+ var thing5 = new Thing5()
+ {
+ Fruit1 = Thing5Enum.Apple,
+ Fruit2 = Thing5Enum.Banana,
+ Fruit3= Thing5Enum.Cherry
+ };
+
+ var thing6 = mapper.Map(thing5);
+
+ Assert.IsNotNull(thing6);
+ Assert.AreEqual(Thing6Enum.Apple, thing6.Fruit1);
+ Assert.AreEqual(Thing6Enum.Banana, thing6.Fruit2);
+ Assert.AreEqual(Thing6Enum.Cherry, thing6.Fruit3);
+ }
+
+ [Test]
+ public void NullPropertyMap()
+ {
+ var definitions = new MapDefinitionCollection(new IMapDefinition[]
+ {
+ new MapperDefinition5(),
+ });
+ var mapper = new UmbracoMapper(definitions);
+
+ var thing7 = new Thing7();
+
+ var thing8 = mapper.Map(thing7);
+
+ Assert.IsNotNull(thing8);
+ Assert.IsNull(thing8.Things);
+ }
+
+
private class Thing1
{
public string Value { get; set; }
@@ -188,6 +230,44 @@ namespace Umbraco.Tests.Mapping
private class Thing4
{ }
+ private class Thing5
+ {
+ public Thing5Enum Fruit1 { get; set; }
+ public Thing5Enum Fruit2 { get; set; }
+ public Thing5Enum Fruit3 { get; set; }
+ }
+
+ private enum Thing5Enum
+ {
+ Apple = 0,
+ Banana = 1,
+ Cherry = 2
+ }
+
+ private class Thing6
+ {
+ public Thing6Enum Fruit1 { get; set; }
+ public Thing6Enum Fruit2 { get; set; }
+ public Thing6Enum Fruit3 { get; set; }
+ }
+
+ private enum Thing6Enum
+ {
+ Apple = 0,
+ Banana = 1,
+ Cherry = 2
+ }
+
+ private class Thing7
+ {
+ public IEnumerable Things { get; set; }
+ }
+
+ private class Thing8
+ {
+ public IEnumerable Things { get; set; }
+ }
+
private class MapperDefinition1 : IMapDefinition
{
public void DefineMaps(UmbracoMapper mapper)
@@ -224,5 +304,41 @@ namespace Umbraco.Tests.Mapping
mapper.Define();
}
}
+
+ private class MapperDefinition4 : IMapDefinition
+ {
+ public void DefineMaps(UmbracoMapper mapper)
+ {
+ mapper.Define((source, context) => new Thing6(), Map);
+ mapper.Define(
+ (source, context) => (Thing6Enum)source);
+ }
+
+ private void Map(Thing5 source, Thing6 target, MapperContext context)
+ {
+ target.Fruit1 = context.Map(source.Fruit1);
+ target.Fruit2 = context.Map(source.Fruit2);
+ target.Fruit3 = context.Map(source.Fruit3);
+ }
+ }
+
+ private class MapperDefinition5 : IMapDefinition
+ {
+ public void DefineMaps(UmbracoMapper mapper)
+ {
+ mapper.Define((source, context) => new Thing2(), Map1);
+ mapper.Define((source, context) => new Thing8(), Map2);
+ }
+
+ private void Map1(Thing1 source, Thing2 target, MapperContext context)
+ {
+ target.Value = source.Value;
+ }
+
+ private void Map2(Thing7 source, Thing8 target, MapperContext context)
+ {
+ target.Things = context.Map>(source.Things);
+ }
+ }
}
}
diff --git a/src/Umbraco.Tests/Persistence/Repositories/SimilarNodeNameTests.cs b/src/Umbraco.Tests/Persistence/Repositories/SimilarNodeNameTests.cs
index 3c23223c9f..582e5a4815 100644
--- a/src/Umbraco.Tests/Persistence/Repositories/SimilarNodeNameTests.cs
+++ b/src/Umbraco.Tests/Persistence/Repositories/SimilarNodeNameTests.cs
@@ -36,6 +36,8 @@ namespace Umbraco.Tests.Persistence.Repositories
Assert.IsTrue(result > 0, "Expected >0 but was " + result);
}
+
+
[Test]
public void OrderByTest()
{
@@ -75,6 +77,7 @@ namespace Umbraco.Tests.Persistence.Repositories
[TestCase(0, "Alpha", "Alpha (3)")]
[TestCase(0, "Kilo (1)", "Kilo (1) (1)")] // though... we might consider "Kilo (2)"
[TestCase(6, "Kilo (1)", "Kilo (1)")] // because of the id
+ [TestCase(0, "alpha", "alpha (3)")]
[TestCase(0, "", " (1)")]
[TestCase(0, null, " (1)")]
public void Test(int nodeId, string nodeName, string expected)
@@ -95,5 +98,22 @@ namespace Umbraco.Tests.Persistence.Repositories
Assert.AreEqual(expected, SimilarNodeName.GetUniqueName(names, nodeId, nodeName));
}
+
+ [Test]
+ [Explicit("This test fails! We need to fix up the logic")]
+ public void TestMany()
+ {
+ var names = new[]
+ {
+ new SimilarNodeName { Id = 1, Name = "Alpha (2)" },
+ new SimilarNodeName { Id = 2, Name = "Test" },
+ new SimilarNodeName { Id = 3, Name = "Test (1)" },
+ new SimilarNodeName { Id = 4, Name = "Test (2)" },
+ new SimilarNodeName { Id = 22, Name = "Test (1) (1)" },
+ };
+
+ //fixme - this will yield "Test (2)" which is already in use
+ Assert.AreEqual("Test (3)", SimilarNodeName.GetUniqueName(names, 0, "Test"));
+ }
}
}
diff --git a/src/Umbraco.Tests/Plugins/PluginManagerTests.cs b/src/Umbraco.Tests/Plugins/PluginManagerTests.cs
index 809354bd74..44879eae2f 100644
--- a/src/Umbraco.Tests/Plugins/PluginManagerTests.cs
+++ b/src/Umbraco.Tests/Plugins/PluginManagerTests.cs
@@ -327,7 +327,7 @@ AnotherContentFinder
public void Resolves_RestExtensions()
{
var types = _manager.ResolveRestExtensions();
- Assert.AreEqual(3, types.Count());
+ Assert.AreEqual(2, types.Count());
}
[Test]
diff --git a/src/Umbraco.Tests/Published/ConvertersTests.cs b/src/Umbraco.Tests/Published/ConvertersTests.cs
index 0fce8ebfc3..671129848c 100644
--- a/src/Umbraco.Tests/Published/ConvertersTests.cs
+++ b/src/Umbraco.Tests/Published/ConvertersTests.cs
@@ -4,16 +4,14 @@ using System.Linq;
using Moq;
using NUnit.Framework;
using Umbraco.Core;
-using Umbraco.Core.Cache;
using Umbraco.Core.Composing;
-using Umbraco.Core.Configuration;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Core.PropertyEditors;
using Umbraco.Tests.Components;
+using Umbraco.Tests.PublishedContent;
using Umbraco.Tests.TestHelpers;
-using Umbraco.Tests.TestHelpers.Stubs;
using Umbraco.Web;
using Umbraco.Web.PublishedCache;
@@ -37,10 +35,12 @@ namespace Umbraco.Tests.Published
var contentTypeFactory = new PublishedContentTypeFactory(Mock.Of(), converters, dataTypeService);
- var elementType1 = contentTypeFactory.CreateContentType(1000, "element1", new[]
+ IEnumerable CreatePropertyTypes(IPublishedContentType contentType)
{
- contentTypeFactory.CreatePropertyType("prop1", 1),
- });
+ yield return contentTypeFactory.CreatePropertyType(contentType, "prop1", 1);
+ }
+
+ var elementType1 = contentTypeFactory.CreateContentType(1000, "element1", CreatePropertyTypes);
var element1 = new PublishedElement(elementType1, Guid.NewGuid(), new Dictionary { { "prop1", "1234" } }, false);
@@ -70,22 +70,22 @@ namespace Umbraco.Tests.Published
}
}
- public bool IsConverter(PublishedPropertyType propertyType)
+ public bool IsConverter(IPublishedPropertyType propertyType)
=> propertyType.EditorAlias.InvariantEquals("Umbraco.Void");
- public Type GetPropertyValueType(PublishedPropertyType propertyType)
+ public Type GetPropertyValueType(IPublishedPropertyType propertyType)
=> typeof (int);
- public PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType)
+ public PropertyCacheLevel GetPropertyCacheLevel(IPublishedPropertyType propertyType)
=> PropertyCacheLevel.Element;
- public object ConvertSourceToIntermediate(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview)
+ public object ConvertSourceToIntermediate(IPublishedElement owner, IPublishedPropertyType propertyType, object source, bool preview)
=> int.TryParse(source as string, out int i) ? i : 0;
- public object ConvertIntermediateToObject(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview)
+ public object ConvertIntermediateToObject(IPublishedElement owner, IPublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview)
=> (int) inter;
- public object ConvertIntermediateToXPath(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview)
+ public object ConvertIntermediateToXPath(IPublishedElement owner, IPublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview)
=> ((int) inter).ToString();
}
@@ -115,15 +115,17 @@ namespace Umbraco.Tests.Published
var contentTypeFactory = new PublishedContentTypeFactory(Mock.Of(), converters, dataTypeService);
- var elementType1 = contentTypeFactory.CreateContentType(1000, "element1", new[]
+ IEnumerable CreatePropertyTypes(IPublishedContentType contentType)
{
- contentTypeFactory.CreatePropertyType("prop1", 1),
- });
+ yield return contentTypeFactory.CreatePropertyType(contentType, "prop1", 1);
+ }
+
+ var elementType1 = contentTypeFactory.CreateContentType(1000, "element1", CreatePropertyTypes);
var element1 = new PublishedElement(elementType1, Guid.NewGuid(), new Dictionary { { "prop1", "1234" } }, false);
- var cntType1 = contentTypeFactory.CreateContentType(1001, "cnt1", Array.Empty());
- var cnt1 = new TestPublishedContent(cntType1, 1234, Guid.NewGuid(), new Dictionary(), false);
+ var cntType1 = contentTypeFactory.CreateContentType(1001, "cnt1", t => Enumerable.Empty());
+ var cnt1 = new SolidPublishedContent(cntType1) { Id = 1234 };
cacheContent[cnt1.Id] = cnt1;
Assert.AreSame(cnt1, element1.Value("prop1"));
@@ -143,26 +145,26 @@ namespace Umbraco.Tests.Published
public bool? IsValue(object value, PropertyValueLevel level)
=> value != null && (!(value is string) || string.IsNullOrWhiteSpace((string) value) == false);
- public bool IsConverter(PublishedPropertyType propertyType)
+ public bool IsConverter(IPublishedPropertyType propertyType)
=> propertyType.EditorAlias.InvariantEquals("Umbraco.Void");
- public Type GetPropertyValueType(PublishedPropertyType propertyType)
+ public Type GetPropertyValueType(IPublishedPropertyType propertyType)
// the first version would be the "generic" version, but say we want to be more precise
// and return: whatever Clr type is generated for content type with alias "cnt1" -- which
// we cannot really typeof() at the moment because it has not been generated, hence ModelType.
// => typeof (IPublishedContent);
=> ModelType.For("cnt1");
- public PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType)
+ public PropertyCacheLevel GetPropertyCacheLevel(IPublishedPropertyType propertyType)
=> _cacheLevel;
- public object ConvertSourceToIntermediate(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview)
+ public object ConvertSourceToIntermediate(IPublishedElement owner, IPublishedPropertyType propertyType, object source, bool preview)
=> int.TryParse(source as string, out int i) ? i : -1;
- public object ConvertIntermediateToObject(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview)
+ public object ConvertIntermediateToObject(IPublishedElement owner, IPublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview)
=> _publishedSnapshotAccessor.PublishedSnapshot.Content.GetById((int) inter);
- public object ConvertIntermediateToXPath(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview)
+ public object ConvertIntermediateToXPath(IPublishedElement owner, IPublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview)
=> ((int) inter).ToString();
}
@@ -208,30 +210,28 @@ namespace Umbraco.Tests.Published
var contentTypeFactory = new PublishedContentTypeFactory(factory, converters, dataTypeService);
- var elementType1 = contentTypeFactory.CreateContentType(1000, "element1", new[]
+ IEnumerable CreatePropertyTypes(IPublishedContentType contentType, int i)
{
- contentTypeFactory.CreatePropertyType("prop1", 1),
- });
+ yield return contentTypeFactory.CreatePropertyType(contentType, "prop" + i, i);
+ }
- var elementType2 = contentTypeFactory.CreateContentType(1001, "element2", new[]
- {
- contentTypeFactory.CreatePropertyType("prop2", 2),
- });
-
- var contentType1 = contentTypeFactory.CreateContentType(1002, "content1", new[]
- {
- contentTypeFactory.CreatePropertyType("prop1", 1),
- });
-
- var contentType2 = contentTypeFactory.CreateContentType(1003, "content2", new[]
- {
- contentTypeFactory.CreatePropertyType("prop2", 2),
- });
+ var elementType1 = contentTypeFactory.CreateContentType(1000, "element1", t => CreatePropertyTypes(t, 1));
+ var elementType2 = contentTypeFactory.CreateContentType(1001, "element2", t => CreatePropertyTypes(t, 2));
+ var contentType1 = contentTypeFactory.CreateContentType(1002, "content1", t => CreatePropertyTypes(t, 1));
+ var contentType2 = contentTypeFactory.CreateContentType(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 cnt1 = new TestPublishedContent(contentType1, 1003, Guid.NewGuid(), new Dictionary { { "prop1", "val1" } }, false);
- var cnt2 = new TestPublishedContent(contentType2, 1004, Guid.NewGuid(), new Dictionary { { "prop2", "1003" } }, false);
+ var cnt1 = new SolidPublishedContent(contentType1)
+ {
+ Id = 1003,
+ 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" } }
+ };
cacheContent[cnt1.Id] = cnt1.CreateModel();
cacheContent[cnt2.Id] = cnt2.CreateModel();
@@ -267,13 +267,13 @@ namespace Umbraco.Tests.Published
public class SimpleConverter3A : PropertyValueConverterBase
{
- public override bool IsConverter(PublishedPropertyType propertyType)
+ public override bool IsConverter(IPublishedPropertyType propertyType)
=> propertyType.EditorAlias == "Umbraco.Void";
- public override Type GetPropertyValueType(PublishedPropertyType propertyType)
+ public override Type GetPropertyValueType(IPublishedPropertyType propertyType)
=> typeof (string);
- public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType)
+ public override PropertyCacheLevel GetPropertyCacheLevel(IPublishedPropertyType propertyType)
=> PropertyCacheLevel.Element;
}
@@ -286,22 +286,22 @@ namespace Umbraco.Tests.Published
_publishedSnapshotAccessor = publishedSnapshotAccessor;
}
- public override bool IsConverter(PublishedPropertyType propertyType)
+ public override bool IsConverter(IPublishedPropertyType propertyType)
=> propertyType.EditorAlias == "Umbraco.Void.2";
- public override Type GetPropertyValueType(PublishedPropertyType propertyType)
+ public override Type GetPropertyValueType(IPublishedPropertyType propertyType)
=> typeof (IEnumerable<>).MakeGenericType(ModelType.For("content1"));
- public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType)
+ public override PropertyCacheLevel GetPropertyCacheLevel(IPublishedPropertyType propertyType)
=> PropertyCacheLevel.Elements;
- public override object ConvertSourceToIntermediate(IPublishedElement owner, PublishedPropertyType 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, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview)
+ 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();
}
diff --git a/src/Umbraco.Tests/Published/NestedContentTests.cs b/src/Umbraco.Tests/Published/NestedContentTests.cs
index 8f3b9a1df9..9385b8955a 100644
--- a/src/Umbraco.Tests/Published/NestedContentTests.cs
+++ b/src/Umbraco.Tests/Published/NestedContentTests.cs
@@ -11,6 +11,7 @@ using Umbraco.Core.Logging;
using Umbraco.Core.Models;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Core.PropertyEditors;
+using Umbraco.Tests.PublishedContent;
using Umbraco.Tests.TestHelpers;
using Umbraco.Web;
using Umbraco.Web.Models;
@@ -23,7 +24,7 @@ namespace Umbraco.Tests.Published
[TestFixture]
public class NestedContentTests
{
- private (PublishedContentType, PublishedContentType) CreateContentTypes()
+ private (IPublishedContentType, IPublishedContentType) CreateContentTypes()
{
Current.Reset();
@@ -125,13 +126,24 @@ namespace Umbraco.Tests.Published
var factory = new PublishedContentTypeFactory(publishedModelFactory.Object, converters, dataTypeService);
- var propertyType1 = factory.CreatePropertyType("property1", 1);
- var propertyType2 = factory.CreatePropertyType("property2", 2);
- var propertyTypeN1 = factory.CreatePropertyType("propertyN1", 3);
+ IEnumerable CreatePropertyTypes1(IPublishedContentType contentType)
+ {
+ yield return factory.CreatePropertyType(contentType, "property1", 1);
+ }
- var contentType1 = factory.CreateContentType(1, "content1", new[] { propertyType1 });
- var contentType2 = factory.CreateContentType(2, "content2", new[] { propertyType2 });
- var contentTypeN1 = factory.CreateContentType(2, "contentN1", new[] { propertyTypeN1 }, isElement: true);
+ IEnumerable CreatePropertyTypes2(IPublishedContentType contentType)
+ {
+ yield return factory.CreatePropertyType(contentType, "property2", 2);
+ }
+
+ IEnumerable CreatePropertyTypesN1(IPublishedContentType contentType)
+ {
+ yield return factory.CreatePropertyType(contentType, "propertyN1", 3);
+ }
+
+ var contentType1 = factory.CreateContentType(1, "content1", CreatePropertyTypes1);
+ var contentType2 = factory.CreateContentType(2, "content2", CreatePropertyTypes2);
+ var contentTypeN1 = factory.CreateContentType(2, "contentN1", CreatePropertyTypesN1, isElement: true);
// mocked content cache returns content types
contentCache
@@ -156,12 +168,16 @@ namespace Umbraco.Tests.Published
var key = Guid.NewGuid();
var keyA = Guid.NewGuid();
- var content = new TestPublishedContent(contentType1, key, new[]
+ var content = new SolidPublishedContent(contentType1)
{
- new TestPublishedProperty(contentType1.GetPropertyType("property1"), $@"[
+ Key = key,
+ Properties = new []
+ {
+ new TestPublishedProperty(contentType1.GetPropertyType("property1"), $@"[
{{ ""key"": ""{keyA}"", ""propertyN1"": ""foo"", ""ncContentTypeAlias"": ""contentN1"" }}
]")
- }, Mock.Of());
+ }
+ };
var value = content.Value("property1");
// nested single converter returns proper TestModel value
@@ -183,14 +199,17 @@ namespace Umbraco.Tests.Published
var key = Guid.NewGuid();
var keyA = Guid.NewGuid();
var keyB = Guid.NewGuid();
- var content = new TestPublishedContent(contentType2, key, new[]
+ var content = new SolidPublishedContent(contentType2)
{
- new TestPublishedProperty(contentType2.GetPropertyType("property2"), $@"[
+ Key = key,
+ Properties = new[]
+ {
+ new TestPublishedProperty(contentType2.GetPropertyType("property2"), $@"[
{{ ""key"": ""{keyA}"", ""propertyN1"": ""foo"", ""ncContentTypeAlias"": ""contentN1"" }},
{{ ""key"": ""{keyB}"", ""propertyN1"": ""bar"", ""ncContentTypeAlias"": ""contentN1"" }}
]")
- },
- Mock.Of());
+ }
+ };
var value = content.Value("property2");
// nested many converter returns proper IEnumerable value
@@ -219,14 +238,14 @@ namespace Umbraco.Tests.Published
private readonly bool _hasValue;
private IPublishedElement _owner;
- public TestPublishedProperty(PublishedPropertyType propertyType, object source)
+ public TestPublishedProperty(IPublishedPropertyType propertyType, object source)
: base(propertyType, PropertyCacheLevel.Element) // initial reference cache level always is .Content
{
_sourceValue = source;
_hasValue = source != null && (!(source is string ssource) || !string.IsNullOrWhiteSpace(ssource));
}
- public TestPublishedProperty(PublishedPropertyType propertyType, IPublishedElement element, bool preview, PropertyCacheLevel referenceCacheLevel, object source)
+ public TestPublishedProperty(IPublishedPropertyType propertyType, IPublishedElement element, bool preview, PropertyCacheLevel referenceCacheLevel, object source)
: base(propertyType, referenceCacheLevel)
{
_sourceValue = source;
@@ -247,52 +266,5 @@ namespace Umbraco.Tests.Published
public override object GetValue(string culture = null, string segment = null) => PropertyType.ConvertInterToObject(_owner, ReferenceCacheLevel, InterValue, _preview);
public override object GetXPathValue(string culture = null, string segment = null) => throw new WontImplementException();
}
-
- class TestPublishedContent : PublishedContentBase
- {
- public TestPublishedContent(PublishedContentType contentType, Guid key, IEnumerable properties, IUmbracoContextAccessor umbracoContextAccessor): base(umbracoContextAccessor)
- {
- ContentType = contentType;
- Key = key;
- var propertiesA = properties.ToArray();
- Properties = propertiesA;
- foreach (var property in propertiesA)
- property.SetOwner(this);
- }
-
- // ReSharper disable UnassignedGetOnlyAutoProperty
- public override PublishedItemType ItemType { get; }
- public override bool IsDraft(string culture = null) => false;
- public override bool IsPublished(string culture = null) => true;
- public override IPublishedContent Parent { get; }
- public override IEnumerable Children { get; }
- public override PublishedContentType ContentType { get; }
- // ReSharper restore UnassignedGetOnlyAutoProperty
-
- // ReSharper disable UnassignedGetOnlyAutoProperty
- public override int Id { get; }
- public override int? TemplateId { get; }
- public override int SortOrder { get; }
- public override string Name { get; }
- public override PublishedCultureInfo GetCulture(string culture = ".") => throw new NotSupportedException();
- public override IReadOnlyDictionary Cultures => throw new NotSupportedException();
- public override string UrlSegment { get; }
- public override string WriterName { get; }
- public override string CreatorName { get; }
- public override int WriterId { get; }
- public override int CreatorId { get; }
- public override string Path { get; }
- public override DateTime CreateDate { get; }
- public override DateTime UpdateDate { get; }
- public override int Level { get; }
- public override Guid Key { get; }
- // ReSharper restore UnassignedGetOnlyAutoProperty
-
- public override IEnumerable Properties { get; }
- public override IPublishedProperty GetProperty(string alias)
- {
- return Properties.FirstOrDefault(x => x.Alias.InvariantEquals(alias));
- }
- }
}
}
diff --git a/src/Umbraco.Tests/Published/PropertyCacheLevelTests.cs b/src/Umbraco.Tests/Published/PropertyCacheLevelTests.cs
index 76fdd81ec2..9db539d142 100644
--- a/src/Umbraco.Tests/Published/PropertyCacheLevelTests.cs
+++ b/src/Umbraco.Tests/Published/PropertyCacheLevelTests.cs
@@ -35,10 +35,13 @@ namespace Umbraco.Tests.Published
new DataType(new VoidEditor(Mock.Of())) { Id = 1 });
var publishedContentTypeFactory = new PublishedContentTypeFactory(Mock.Of(), converters, dataTypeService);
- var setType1 = publishedContentTypeFactory.CreateContentType(1000, "set1", new[]
+
+ IEnumerable CreatePropertyTypes(IPublishedContentType contentType)
{
- publishedContentTypeFactory.CreatePropertyType("prop1", 1),
- });
+ yield return publishedContentTypeFactory.CreatePropertyType(contentType, "prop1", 1);
+ }
+
+ var setType1 = publishedContentTypeFactory.CreateContentType(1000, "set1", CreatePropertyTypes);
// PublishedElementPropertyBase.GetCacheLevels:
//
@@ -113,10 +116,13 @@ namespace Umbraco.Tests.Published
new DataType(new VoidEditor(Mock.Of())) { Id = 1 });
var publishedContentTypeFactory = new PublishedContentTypeFactory(Mock.Of(), converters, dataTypeService);
- var setType1 = publishedContentTypeFactory.CreateContentType(1000, "set1", new[]
+
+ IEnumerable CreatePropertyTypes(IPublishedContentType contentType)
{
- publishedContentTypeFactory.CreatePropertyType("prop1", 1),
- });
+ yield return publishedContentTypeFactory.CreatePropertyType(contentType, "prop1", 1);
+ }
+
+ var setType1 = publishedContentTypeFactory.CreateContentType(1000, "set1", CreatePropertyTypes);
var elementsCache = new FastDictionaryAppCache();
var snapshotCache = new FastDictionaryAppCache();
@@ -187,10 +193,13 @@ namespace Umbraco.Tests.Published
new DataType(new VoidEditor(Mock.Of())) { Id = 1 });
var publishedContentTypeFactory = new PublishedContentTypeFactory(Mock.Of(), converters, dataTypeService);
- var setType1 = publishedContentTypeFactory.CreateContentType(1000, "set1", new[]
+
+ IEnumerable CreatePropertyTypes(IPublishedContentType contentType)
{
- publishedContentTypeFactory.CreatePropertyType("prop1", 1),
- });
+ yield return publishedContentTypeFactory.CreatePropertyType(contentType, "prop1", 1);
+ }
+
+ var setType1 = publishedContentTypeFactory.CreateContentType(1000, "set1", CreatePropertyTypes);
Assert.Throws(() =>
{
@@ -213,28 +222,28 @@ namespace Umbraco.Tests.Published
public bool? IsValue(object value, PropertyValueLevel level)
=> value != null && (!(value is string) || string.IsNullOrWhiteSpace((string) value) == false);
- public bool IsConverter(PublishedPropertyType propertyType)
+ public bool IsConverter(IPublishedPropertyType propertyType)
=> propertyType.EditorAlias.InvariantEquals("Umbraco.Void");
- public Type GetPropertyValueType(PublishedPropertyType propertyType)
+ public Type GetPropertyValueType(IPublishedPropertyType propertyType)
=> typeof(int);
- public PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType)
+ public PropertyCacheLevel GetPropertyCacheLevel(IPublishedPropertyType propertyType)
=> _cacheLevel;
- public object ConvertSourceToIntermediate(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview)
+ public object ConvertSourceToIntermediate(IPublishedElement owner, IPublishedPropertyType propertyType, object source, bool preview)
{
SourceConverts++;
return int.TryParse(source as string, out int i) ? i : 0;
}
- public object ConvertIntermediateToObject(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview)
+ public object ConvertIntermediateToObject(IPublishedElement owner, IPublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview)
{
InterConverts++;
return (int) inter;
}
- public object ConvertIntermediateToXPath(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview)
+ public object ConvertIntermediateToXPath(IPublishedElement owner, IPublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview)
=> ((int) inter).ToString();
}
}
diff --git a/src/Umbraco.Tests/PublishedContent/NuCacheChildrenTests.cs b/src/Umbraco.Tests/PublishedContent/NuCacheChildrenTests.cs
new file mode 100644
index 0000000000..f3a520ead1
--- /dev/null
+++ b/src/Umbraco.Tests/PublishedContent/NuCacheChildrenTests.cs
@@ -0,0 +1,851 @@
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using Moq;
+using NUnit.Framework;
+using Umbraco.Core;
+using Umbraco.Core.Composing;
+using Umbraco.Core.Configuration;
+using Umbraco.Core.Events;
+using Umbraco.Core.Logging;
+using Umbraco.Core.Models;
+using Umbraco.Core.Models.PublishedContent;
+using Umbraco.Core.Persistence.Repositories;
+using Umbraco.Core.PropertyEditors;
+using Umbraco.Core.Scoping;
+using Umbraco.Core.Services;
+using Umbraco.Core.Services.Changes;
+using Umbraco.Core.Strings;
+using Umbraco.Tests.TestHelpers;
+using Umbraco.Tests.Testing.Objects;
+using Umbraco.Tests.Testing.Objects.Accessors;
+using Umbraco.Web;
+using Umbraco.Web.Cache;
+using Umbraco.Web.PublishedCache;
+using Umbraco.Web.PublishedCache.NuCache;
+using Umbraco.Web.PublishedCache.NuCache.DataSource;
+
+namespace Umbraco.Tests.PublishedContent
+{
+ [TestFixture]
+ public class NuCacheChildrenTests
+ {
+ private IPublishedSnapshotService _snapshotService;
+ private IVariationContextAccessor _variationAccesor;
+ private IPublishedSnapshotAccessor _snapshotAccessor;
+ private ContentType _contentTypeInvariant;
+ private ContentType _contentTypeVariant;
+ private TestDataSource _source;
+
+ private void Init(IEnumerable kits)
+ {
+ Current.Reset();
+
+ var factory = Mock.Of();
+ Current.Factory = factory;
+
+ var configs = new Configs();
+ Mock.Get(factory).Setup(x => x.GetInstance(typeof(Configs))).Returns(configs);
+ var globalSettings = new GlobalSettings();
+ configs.Add(SettingsForTests.GenerateMockUmbracoSettings);
+ configs.Add(() => globalSettings);
+
+ var publishedModelFactory = new NoopPublishedModelFactory();
+ Mock.Get(factory).Setup(x => x.GetInstance(typeof(IPublishedModelFactory))).Returns(publishedModelFactory);
+
+ var runtime = Mock.Of();
+ Mock.Get(runtime).Setup(x => x.Level).Returns(RuntimeLevel.Run);
+
+ // create data types, property types and content types
+ var dataType = new DataType(new VoidEditor("Editor", Mock.Of())) { Id = 3 };
+
+ var dataTypes = new[]
+ {
+ dataType
+ };
+
+ var propertyType = new PropertyType("Umbraco.Void.Editor", ValueStorageType.Nvarchar) { Alias = "prop", DataTypeId = 3, Variations = ContentVariation.Nothing };
+ _contentTypeInvariant = new ContentType(-1) { Id = 2, Alias = "itype", Variations = ContentVariation.Nothing };
+ _contentTypeInvariant.AddPropertyType(propertyType);
+
+ propertyType = new PropertyType("Umbraco.Void.Editor", ValueStorageType.Nvarchar) { Alias = "prop", DataTypeId = 3, Variations = ContentVariation.Culture };
+ _contentTypeVariant = new ContentType(-1) { Id = 3, Alias = "vtype", Variations = ContentVariation.Culture };
+ _contentTypeVariant.AddPropertyType(propertyType);
+
+ var contentTypes = new[]
+ {
+ _contentTypeInvariant,
+ _contentTypeVariant
+ };
+
+ var contentTypeService = Mock.Of();
+ Mock.Get(contentTypeService).Setup(x => x.GetAll()).Returns(contentTypes);
+ Mock.Get(contentTypeService).Setup(x => x.GetAll(It.IsAny())).Returns(contentTypes);
+
+ var contentTypeServiceBaseFactory = Mock.Of();
+ Mock.Get(contentTypeServiceBaseFactory).Setup(x => x.For(It.IsAny())).Returns(contentTypeService);
+
+ var dataTypeService = Mock.Of();
+ Mock.Get(dataTypeService).Setup(x => x.GetAll()).Returns(dataTypes);
+
+ // create a service context
+ var serviceContext = ServiceContext.CreatePartial(
+ dataTypeService: dataTypeService,
+ memberTypeService: Mock.Of(),
+ memberService: Mock.Of(),
+ contentTypeService: contentTypeService,
+ localizationService: Mock.Of()
+ );
+
+ // create a scope provider
+ var scopeProvider = Mock.Of();
+ Mock.Get(scopeProvider)
+ .Setup(x => x.CreateScope(
+ It.IsAny(),
+ It.IsAny(),
+ It.IsAny(),
+ It.IsAny(),
+ It.IsAny(),
+ It.IsAny()))
+ .Returns(Mock.Of);
+
+ // create a published content type factory
+ var contentTypeFactory = new PublishedContentTypeFactory(
+ Mock.Of(),
+ new PropertyValueConverterCollection(Array.Empty()),
+ dataTypeService);
+
+ // create accessors
+ _variationAccesor = new TestVariationContextAccessor();
+ _snapshotAccessor = new TestPublishedSnapshotAccessor();
+
+ // create a data source for NuCache
+ _source = new TestDataSource(kits);
+
+ // at last, create the complete NuCache snapshot service!
+ var options = new PublishedSnapshotService.Options { IgnoreLocalDb = true };
+ _snapshotService = new PublishedSnapshotService(options,
+ null,
+ runtime,
+ serviceContext,
+ contentTypeFactory,
+ null,
+ _snapshotAccessor,
+ _variationAccesor,
+ Mock.Of(),
+ scopeProvider,
+ Mock.Of(),
+ Mock.Of(),
+ Mock.Of(),
+ new TestDefaultCultureAccessor(),
+ _source,
+ globalSettings,
+ Mock.Of(),
+ Mock.Of(),
+ new UrlSegmentProviderCollection(new[] { new DefaultUrlSegmentProvider() }));
+
+ // invariant is the current default
+ _variationAccesor.VariationContext = new VariationContext();
+
+ Mock.Get(factory).Setup(x => x.GetInstance(typeof(IVariationContextAccessor))).Returns(_variationAccesor);
+ }
+
+ private IEnumerable GetInvariantKits()
+ {
+ var paths = new Dictionary { { -1, "-1" } };
+
+ ContentNodeKit CreateKit(int id, int parentId, int sortOrder)
+ {
+ if (!paths.TryGetValue(parentId, out var parentPath))
+ throw new Exception("Unknown parent.");
+
+ var path = paths[id] = parentPath + "," + id;
+ var level = path.Count(x => x == ',');
+ var now = DateTime.Now;
+
+ return new ContentNodeKit
+ {
+ ContentTypeId = _contentTypeInvariant.Id,
+ Node = new ContentNode(id, Guid.NewGuid(), level, path, sortOrder, parentId, DateTime.Now, 0),
+ DraftData = null,
+ PublishedData = new ContentData
+ {
+ Name = "N" + id,
+ Published = true,
+ TemplateId = 0,
+ VersionId = 1,
+ VersionDate = now,
+ WriterId = 0,
+ Properties = new Dictionary(),
+ CultureInfos = new Dictionary()
+ }
+ };
+ }
+
+ yield return CreateKit(1, -1, 1);
+ yield return CreateKit(2, -1, 2);
+ yield return CreateKit(3, -1, 3);
+
+ yield return CreateKit(4, 1, 1);
+ yield return CreateKit(5, 1, 2);
+ yield return CreateKit(6, 1, 3);
+
+ yield return CreateKit(7, 2, 3);
+ yield return CreateKit(8, 2, 2);
+ yield return CreateKit(9, 2, 1);
+
+ yield return CreateKit(10, 3, 1);
+
+ yield return CreateKit(11, 4, 1);
+ yield return CreateKit(12, 4, 2);
+ }
+
+ private IEnumerable GetVariantKits()
+ {
+ var paths = new Dictionary { { -1, "-1" } };
+
+ Dictionary GetCultureInfos(int id, DateTime now)
+ {
+ var en = new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
+ var fr = new[] { 1, 3, 4, 6, 7, 9, 10, 12 };
+
+ var infos = new Dictionary();
+ if (en.Contains(id))
+ infos["en-US"] = new CultureVariation { Name = "N" + id + "-" + "en-US", Date = now, IsDraft = false };
+ if (fr.Contains(id))
+ infos["fr-FR"] = new CultureVariation { Name = "N" + id + "-" + "fr-FR", Date = now, IsDraft = false };
+ return infos;
+ }
+
+ ContentNodeKit CreateKit(int id, int parentId, int sortOrder)
+ {
+ if (!paths.TryGetValue(parentId, out var parentPath))
+ throw new Exception("Unknown parent.");
+
+ var path = paths[id] = parentPath + "," + id;
+ var level = path.Count(x => x == ',');
+ var now = DateTime.Now;
+
+ return new ContentNodeKit
+ {
+ ContentTypeId = _contentTypeVariant.Id,
+ Node = new ContentNode(id, Guid.NewGuid(), level, path, sortOrder, parentId, DateTime.Now, 0),
+ DraftData = null,
+ PublishedData = new ContentData
+ {
+ Name = "N" + id,
+ Published = true,
+ TemplateId = 0,
+ VersionId = 1,
+ VersionDate = now,
+ WriterId = 0,
+ Properties = new Dictionary(),
+ CultureInfos = GetCultureInfos(id, now)
+ }
+ };
+ }
+
+ yield return CreateKit(1, -1, 1);
+ yield return CreateKit(2, -1, 2);
+ yield return CreateKit(3, -1, 3);
+
+ yield return CreateKit(4, 1, 1);
+ yield return CreateKit(5, 1, 2);
+ yield return CreateKit(6, 1, 3);
+
+ yield return CreateKit(7, 2, 3);
+ yield return CreateKit(8, 2, 2);
+ yield return CreateKit(9, 2, 1);
+
+ yield return CreateKit(10, 3, 1);
+
+ yield return CreateKit(11, 4, 1);
+ yield return CreateKit(12, 4, 2);
+ }
+
+ private IEnumerable GetVariantWithDraftKits()
+ {
+ var paths = new Dictionary { { -1, "-1" } };
+
+ Dictionary GetCultureInfos(int id, DateTime now)
+ {
+ var en = new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
+ var fr = new[] { 1, 3, 4, 6, 7, 9, 10, 12 };
+
+ var infos = new Dictionary();
+ if (en.Contains(id))
+ infos["en-US"] = new CultureVariation { Name = "N" + id + "-" + "en-US", Date = now, IsDraft = false };
+ if (fr.Contains(id))
+ infos["fr-FR"] = new CultureVariation { Name = "N" + id + "-" + "fr-FR", Date = now, IsDraft = false };
+ return infos;
+ }
+
+ ContentNodeKit CreateKit(int id, int parentId, int sortOrder)
+ {
+ if (!paths.TryGetValue(parentId, out var parentPath))
+ throw new Exception("Unknown parent.");
+
+ var path = paths[id] = parentPath + "," + id;
+ var level = path.Count(x => x == ',');
+ var now = DateTime.Now;
+
+ ContentData CreateContentData(bool published) => new ContentData
+ {
+ Name = "N" + id,
+ Published = published,
+ TemplateId = 0,
+ VersionId = 1,
+ VersionDate = now,
+ WriterId = 0,
+ Properties = new Dictionary(),
+ CultureInfos = GetCultureInfos(id, now)
+ };
+
+ var withDraft = id%2==0;
+ var withPublished = !withDraft;
+
+ return new ContentNodeKit
+ {
+ ContentTypeId = _contentTypeVariant.Id,
+ Node = new ContentNode(id, Guid.NewGuid(), level, path, sortOrder, parentId, DateTime.Now, 0),
+ DraftData = withDraft ? CreateContentData(false) : null,
+ PublishedData = withPublished ? CreateContentData(true) : null
+ };
+ }
+
+ yield return CreateKit(1, -1, 1);
+ yield return CreateKit(2, -1, 2);
+ yield return CreateKit(3, -1, 3);
+
+ yield return CreateKit(4, 1, 1);
+ yield return CreateKit(5, 1, 2);
+ yield return CreateKit(6, 1, 3);
+
+ yield return CreateKit(7, 2, 3);
+ yield return CreateKit(8, 2, 2);
+ yield return CreateKit(9, 2, 1);
+
+ yield return CreateKit(10, 3, 1);
+
+ yield return CreateKit(11, 4, 1);
+ yield return CreateKit(12, 4, 2);
+ }
+
+ [Test]
+ public void EmptyTest()
+ {
+ Init(Enumerable.Empty());
+
+ var snapshot = _snapshotService.CreatePublishedSnapshot(previewToken: null);
+ _snapshotAccessor.PublishedSnapshot = snapshot;
+
+ var documents = snapshot.Content.GetAtRoot().ToArray();
+ Assert.AreEqual(0, documents.Length);
+ }
+
+ [Test]
+ public void ChildrenTest()
+ {
+ Init(GetInvariantKits());
+
+ var snapshot = _snapshotService.CreatePublishedSnapshot(previewToken: null);
+ _snapshotAccessor.PublishedSnapshot = snapshot;
+
+ var documents = snapshot.Content.GetAtRoot().ToArray();
+ AssertDocuments(documents, "N1", "N2", "N3");
+
+ documents = snapshot.Content.GetById(1).Children().ToArray();
+ AssertDocuments(documents, "N4", "N5", "N6");
+
+ documents = snapshot.Content.GetById(2).Children().ToArray();
+ AssertDocuments(documents, "N9", "N8", "N7");
+
+ documents = snapshot.Content.GetById(3).Children().ToArray();
+ AssertDocuments(documents, "N10");
+
+ documents = snapshot.Content.GetById(4).Children().ToArray();
+ AssertDocuments(documents, "N11", "N12");
+
+ documents = snapshot.Content.GetById(10).Children().ToArray();
+ AssertDocuments(documents);
+ }
+
+ [Test]
+ public void ParentTest()
+ {
+ Init(GetInvariantKits());
+
+ var snapshot = _snapshotService.CreatePublishedSnapshot(previewToken: null);
+ _snapshotAccessor.PublishedSnapshot = snapshot;
+
+ Assert.IsNull(snapshot.Content.GetById(1).Parent);
+ Assert.IsNull(snapshot.Content.GetById(2).Parent);
+ Assert.IsNull(snapshot.Content.GetById(3).Parent);
+
+ Assert.AreEqual(1, snapshot.Content.GetById(4).Parent?.Id);
+ Assert.AreEqual(1, snapshot.Content.GetById(5).Parent?.Id);
+ Assert.AreEqual(1, snapshot.Content.GetById(6).Parent?.Id);
+
+ Assert.AreEqual(2, snapshot.Content.GetById(7).Parent?.Id);
+ Assert.AreEqual(2, snapshot.Content.GetById(8).Parent?.Id);
+ Assert.AreEqual(2, snapshot.Content.GetById(9).Parent?.Id);
+
+ Assert.AreEqual(3, snapshot.Content.GetById(10).Parent?.Id);
+
+ Assert.AreEqual(4, snapshot.Content.GetById(11).Parent?.Id);
+ Assert.AreEqual(4, snapshot.Content.GetById(12).Parent?.Id);
+ }
+
+ [Test]
+ public void MoveToRootTest()
+ {
+ Init(GetInvariantKits());
+
+ // get snapshot
+ var snapshot = _snapshotService.CreatePublishedSnapshot(previewToken: null);
+ _snapshotAccessor.PublishedSnapshot = snapshot;
+
+ // do some changes
+ var kit = _source.Kits[10];
+ _source.Kits[10] = new ContentNodeKit
+ {
+ ContentTypeId = 2,
+ Node = new ContentNode(kit.Node.Id, Guid.NewGuid(), 1, "-1,10", 4, -1, DateTime.Now, 0),
+ DraftData = null,
+ PublishedData = new ContentData
+ {
+ Name = kit.PublishedData.Name,
+ Published = true,
+ TemplateId = 0,
+ VersionId = 1,
+ VersionDate = DateTime.Now,
+ WriterId = 0,
+ Properties = new Dictionary(),
+ CultureInfos = new Dictionary()
+ }
+ };
+
+ // notify
+ _snapshotService.Notify(new[] { new ContentCacheRefresher.JsonPayload(10, TreeChangeTypes.RefreshBranch) }, out _, out _);
+
+ // changes that *I* make are immediately visible on the current snapshot
+ var documents = snapshot.Content.GetAtRoot().ToArray();
+ AssertDocuments(documents, "N1", "N2", "N3", "N10");
+
+ documents = snapshot.Content.GetById(3).Children().ToArray();
+ AssertDocuments(documents);
+
+ Assert.IsNull(snapshot.Content.GetById(10).Parent);
+ }
+
+ [Test]
+ public void MoveFromRootTest()
+ {
+ Init(GetInvariantKits());
+
+ // get snapshot
+ var snapshot = _snapshotService.CreatePublishedSnapshot(previewToken: null);
+ _snapshotAccessor.PublishedSnapshot = snapshot;
+
+ // do some changes
+ var kit = _source.Kits[1];
+ _source.Kits[1] = new ContentNodeKit
+ {
+ ContentTypeId = 2,
+ Node = new ContentNode(kit.Node.Id, Guid.NewGuid(), 1, "-1,3,10,1", 1, 10, DateTime.Now, 0),
+ DraftData = null,
+ PublishedData = new ContentData
+ {
+ Name = kit.PublishedData.Name,
+ Published = true,
+ TemplateId = 0,
+ VersionId = 1,
+ VersionDate = DateTime.Now,
+ WriterId = 0,
+ Properties = new Dictionary(),
+ CultureInfos = new Dictionary()
+ }
+ };
+
+ // notify
+ _snapshotService.Notify(new[] { new ContentCacheRefresher.JsonPayload(1, TreeChangeTypes.RefreshBranch) }, out _, out _);
+
+ // changes that *I* make are immediately visible on the current snapshot
+ var documents = snapshot.Content.GetAtRoot().ToArray();
+ AssertDocuments(documents, "N2", "N3");
+
+ documents = snapshot.Content.GetById(10).Children().ToArray();
+ AssertDocuments(documents, "N1");
+
+ Assert.AreEqual(10, snapshot.Content.GetById(1).Parent?.Id);
+ }
+
+ [Test]
+ public void ReOrderTest()
+ {
+ Init(GetInvariantKits());
+
+ // get snapshot
+ var snapshot = _snapshotService.CreatePublishedSnapshot(previewToken: null);
+ _snapshotAccessor.PublishedSnapshot = snapshot;
+
+ // do some changes
+ var kit = _source.Kits[7];
+ _source.Kits[7] = new ContentNodeKit
+ {
+ ContentTypeId = 2,
+ Node = new ContentNode(kit.Node.Id, Guid.NewGuid(), kit.Node.Level, kit.Node.Path, 1, kit.Node.ParentContentId, DateTime.Now, 0),
+ DraftData = null,
+ PublishedData = new ContentData
+ {
+ Name = kit.PublishedData.Name,
+ Published = true,
+ TemplateId = 0,
+ VersionId = 1,
+ VersionDate = DateTime.Now,
+ WriterId = 0,
+ Properties = new Dictionary