From a3e73b59bf32f57b5c2fd59f86f58e44a7bead74 Mon Sep 17 00:00:00 2001 From: Bjarke Berg Date: Thu, 7 Nov 2019 12:58:56 +0100 Subject: [PATCH] More config movement --- .../Configuration/ConfigsExtensions.cs | 2 - .../Configuration}/ConfigsFactory.cs | 1 - .../Configuration/Grid/GridEditorsConfig.cs | 6 +- src/Umbraco.Core/Manifest/IManifestFilter.cs | 2 +- src/Umbraco.Core/Manifest/IManifestParser.cs | 9 +- src/Umbraco.Core/Manifest/IPackageManifest.cs | 65 ++++++++ .../Manifest/ManifestFilterCollection.cs | 2 +- src/Umbraco.Core/Manifest/ManifestParser.cs | 15 +- src/Umbraco.Core/Manifest/PackageManifest.cs | 140 +++++++++--------- src/Umbraco.Core/Umbraco.Core.csproj | 2 + src/Umbraco.Tests/Published/ModelTypeTests.cs | 2 +- 11 files changed, 156 insertions(+), 90 deletions(-) rename src/{Umbraco.Configuration => Umbraco.Core/Configuration}/ConfigsFactory.cs (90%) create mode 100644 src/Umbraco.Core/Manifest/IPackageManifest.cs diff --git a/src/Umbraco.Core/Configuration/ConfigsExtensions.cs b/src/Umbraco.Core/Configuration/ConfigsExtensions.cs index 4761b14d1e..e54e360021 100644 --- a/src/Umbraco.Core/Configuration/ConfigsExtensions.cs +++ b/src/Umbraco.Core/Configuration/ConfigsExtensions.cs @@ -16,8 +16,6 @@ namespace Umbraco.Core public static class ConfigsExtensions { - - public static void AddCoreConfigs(this Configs configs) { var configDir = new DirectoryInfo(IOHelper.MapPath(SystemDirectories.Config)); diff --git a/src/Umbraco.Configuration/ConfigsFactory.cs b/src/Umbraco.Core/Configuration/ConfigsFactory.cs similarity index 90% rename from src/Umbraco.Configuration/ConfigsFactory.cs rename to src/Umbraco.Core/Configuration/ConfigsFactory.cs index fbfefc132e..c0e80d3798 100644 --- a/src/Umbraco.Configuration/ConfigsFactory.cs +++ b/src/Umbraco.Core/Configuration/ConfigsFactory.cs @@ -13,7 +13,6 @@ namespace Umbraco.Core.Configuration configs.Add("umbracoConfiguration/HealthChecks"); configs.Add(() => new CoreDebug()); - configs.Add("umbracoConfiguration/HealthChecks"); configs.AddCoreConfigs(); return configs; } diff --git a/src/Umbraco.Core/Configuration/Grid/GridEditorsConfig.cs b/src/Umbraco.Core/Configuration/Grid/GridEditorsConfig.cs index cab58a6d63..a1ebf008fc 100644 --- a/src/Umbraco.Core/Configuration/Grid/GridEditorsConfig.cs +++ b/src/Umbraco.Core/Configuration/Grid/GridEditorsConfig.cs @@ -29,9 +29,9 @@ namespace Umbraco.Core.Configuration.Grid { get { - List GetResult() + List GetResult() { - var editors = new List(); + var editors = new List(); var gridConfig = Path.Combine(_configFolder.FullName, "grid.editors.config.js"); if (File.Exists(gridConfig)) { @@ -59,7 +59,7 @@ namespace Umbraco.Core.Configuration.Grid //cache the result if debugging is disabled var result = _isDebug ? GetResult() - : _appCaches.RuntimeCache.GetCacheItem>(typeof(GridEditorsConfig) + ".Editors",GetResult, TimeSpan.FromMinutes(10)); + : _appCaches.RuntimeCache.GetCacheItem>(typeof(GridEditorsConfig) + ".Editors",GetResult, TimeSpan.FromMinutes(10)); return result; } diff --git a/src/Umbraco.Core/Manifest/IManifestFilter.cs b/src/Umbraco.Core/Manifest/IManifestFilter.cs index 505f13d385..f1e2c633c8 100644 --- a/src/Umbraco.Core/Manifest/IManifestFilter.cs +++ b/src/Umbraco.Core/Manifest/IManifestFilter.cs @@ -14,6 +14,6 @@ namespace Umbraco.Core.Manifest /// /// It is possible to remove, change, or add manifests. /// - void Filter(List manifests); + void Filter(List manifests); } } diff --git a/src/Umbraco.Core/Manifest/IManifestParser.cs b/src/Umbraco.Core/Manifest/IManifestParser.cs index 3641396e0a..367ee3be77 100644 --- a/src/Umbraco.Core/Manifest/IManifestParser.cs +++ b/src/Umbraco.Core/Manifest/IManifestParser.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using Umbraco.Core.Configuration.Grid; using Umbraco.Core.PropertyEditors; namespace Umbraco.Core.Manifest @@ -11,13 +12,13 @@ namespace Umbraco.Core.Manifest /// Gets all manifests, merged into a single manifest object. /// /// - PackageManifest Manifest { get; } + IPackageManifest Manifest { get; } /// /// Parses a manifest. /// - PackageManifest ParseManifest(string text); + IPackageManifest ParseManifest(string text); - IEnumerable ParseGridEditors(string text); + IEnumerable ParseGridEditors(string text); } -} \ No newline at end of file +} diff --git a/src/Umbraco.Core/Manifest/IPackageManifest.cs b/src/Umbraco.Core/Manifest/IPackageManifest.cs new file mode 100644 index 0000000000..01b0be70db --- /dev/null +++ b/src/Umbraco.Core/Manifest/IPackageManifest.cs @@ -0,0 +1,65 @@ +using System.Runtime.Serialization; +using Umbraco.Core.PropertyEditors; + +namespace Umbraco.Core.Manifest +{ + public interface IPackageManifest + { + /// + /// Gets the source path of the manifest. + /// + /// + /// Gets the full absolute file path of the manifest, + /// using system directory separators. + /// + string Source { get; set; } + + /// + /// Gets or sets the scripts listed in the manifest. + /// + [DataMember(Name = "javascript")] + string[] Scripts { get; set; } + + /// + /// Gets or sets the stylesheets listed in the manifest. + /// + [DataMember(Name = "css")] + string[] Stylesheets { get; set; } + + /// + /// Gets or sets the property editors listed in the manifest. + /// + [DataMember(Name = "propertyEditors")] + IDataEditor[] PropertyEditors { get; set; } + + /// + /// Gets or sets the parameter editors listed in the manifest. + /// + [DataMember(Name = "parameterEditors")] + IDataEditor[] ParameterEditors { get; set; } + + /// + /// Gets or sets the grid editors listed in the manifest. + /// + [DataMember(Name = "gridEditors")] + GridEditor[] GridEditors { get; set; } + + /// + /// Gets or sets the content apps listed in the manifest. + /// + [DataMember(Name = "contentApps")] + ManifestContentAppDefinition[] ContentApps { get; set; } + + /// + /// Gets or sets the dashboards listed in the manifest. + /// + [DataMember(Name = "dashboards")] + ManifestDashboard[] Dashboards { get; set; } + + /// + /// Gets or sets the sections listed in the manifest. + /// + [DataMember(Name = "sections")] + ManifestSection[] Sections { get; set; } + } +} diff --git a/src/Umbraco.Core/Manifest/ManifestFilterCollection.cs b/src/Umbraco.Core/Manifest/ManifestFilterCollection.cs index febdb7e356..0f49c96094 100644 --- a/src/Umbraco.Core/Manifest/ManifestFilterCollection.cs +++ b/src/Umbraco.Core/Manifest/ManifestFilterCollection.cs @@ -19,7 +19,7 @@ namespace Umbraco.Core.Manifest /// Filters package manifests. /// /// The package manifests. - public void Filter(List manifests) + public void Filter(List manifests) { foreach (var filter in this) filter.Filter(manifests); diff --git a/src/Umbraco.Core/Manifest/ManifestParser.cs b/src/Umbraco.Core/Manifest/ManifestParser.cs index 2e55d07059..4e2ca1f2b6 100644 --- a/src/Umbraco.Core/Manifest/ManifestParser.cs +++ b/src/Umbraco.Core/Manifest/ManifestParser.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Text; using Newtonsoft.Json; using Umbraco.Core.Cache; +using Umbraco.Core.Configuration.Grid; using Umbraco.Core.Exceptions; using Umbraco.Core.IO; using Umbraco.Core.Logging; @@ -57,8 +58,8 @@ namespace Umbraco.Core.Manifest /// Gets all manifests, merged into a single manifest object. /// /// - public PackageManifest Manifest - => _cache.GetCacheItem("Umbraco.Core.Manifest.ManifestParser::Manifests", () => + public IPackageManifest Manifest + => _cache.GetCacheItem("Umbraco.Core.Manifest.ManifestParser::Manifests", () => { var manifests = GetManifests(); return MergeManifests(manifests); @@ -67,9 +68,9 @@ namespace Umbraco.Core.Manifest /// /// Gets all manifests. /// - private IEnumerable GetManifests() + private IEnumerable GetManifests() { - var manifests = new List(); + var manifests = new List(); foreach (var path in GetManifestFiles()) { @@ -97,7 +98,7 @@ namespace Umbraco.Core.Manifest /// /// Merges all manifests into one. /// - private static PackageManifest MergeManifests(IEnumerable manifests) + private static IPackageManifest MergeManifests(IEnumerable manifests) { var scripts = new HashSet(); var stylesheets = new HashSet(); @@ -153,7 +154,7 @@ namespace Umbraco.Core.Manifest /// /// Parses a manifest. /// - public PackageManifest ParseManifest(string text) + public IPackageManifest ParseManifest(string text) { if (string.IsNullOrWhiteSpace(text)) throw new ArgumentNullOrEmptyException(nameof(text)); @@ -179,7 +180,7 @@ namespace Umbraco.Core.Manifest } // purely for tests - public IEnumerable ParseGridEditors(string text) + public IEnumerable ParseGridEditors(string text) { return JsonConvert.DeserializeObject>(text); } diff --git a/src/Umbraco.Core/Manifest/PackageManifest.cs b/src/Umbraco.Core/Manifest/PackageManifest.cs index e50eb69467..a81021432d 100644 --- a/src/Umbraco.Core/Manifest/PackageManifest.cs +++ b/src/Umbraco.Core/Manifest/PackageManifest.cs @@ -1,70 +1,70 @@ -using System; -using Newtonsoft.Json; -using Umbraco.Core.PropertyEditors; - -namespace Umbraco.Core.Manifest -{ - /// - /// Represents the content of a package 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. - /// - [JsonProperty("javascript")] - public string[] Scripts { get; set; } = Array.Empty(); - - /// - /// Gets or sets the stylesheets listed in the manifest. - /// - [JsonProperty("css")] - public string[] Stylesheets { get; set; } = Array.Empty(); - - /// - /// Gets or sets the property editors listed in the manifest. - /// - [JsonProperty("propertyEditors")] - public IDataEditor[] PropertyEditors { get; set; } = Array.Empty(); - - /// - /// Gets or sets the parameter editors listed in the manifest. - /// - [JsonProperty("parameterEditors")] - public IDataEditor[] ParameterEditors { get; set; } = Array.Empty(); - - /// - /// Gets or sets the grid editors listed in the manifest. - /// - [JsonProperty("gridEditors")] - public GridEditor[] GridEditors { get; set; } = Array.Empty(); - - /// - /// Gets or sets the content apps listed in the manifest. - /// - [JsonProperty("contentApps")] - public ManifestContentAppDefinition[] ContentApps { get; set; } = Array.Empty(); - - /// - /// Gets or sets the dashboards listed in the manifest. - /// - [JsonProperty("dashboards")] - public ManifestDashboard[] Dashboards { get; set; } = Array.Empty(); - - /// - /// Gets or sets the sections listed in the manifest. - /// - [JsonProperty("sections")] - public ManifestSection[] Sections { get; set; } = Array.Empty(); - } -} +using System; +using Newtonsoft.Json; +using Umbraco.Core.PropertyEditors; + +namespace Umbraco.Core.Manifest +{ + /// + /// Represents the content of a package manifest. + /// + public class PackageManifest : IPackageManifest + { + /// + /// 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. + /// + [JsonProperty("javascript")] + public string[] Scripts { get; set; } = Array.Empty(); + + /// + /// Gets or sets the stylesheets listed in the manifest. + /// + [JsonProperty("css")] + public string[] Stylesheets { get; set; } = Array.Empty(); + + /// + /// Gets or sets the property editors listed in the manifest. + /// + [JsonProperty("propertyEditors")] + public IDataEditor[] PropertyEditors { get; set; } = Array.Empty(); + + /// + /// Gets or sets the parameter editors listed in the manifest. + /// + [JsonProperty("parameterEditors")] + public IDataEditor[] ParameterEditors { get; set; } = Array.Empty(); + + /// + /// Gets or sets the grid editors listed in the manifest. + /// + [JsonProperty("gridEditors")] + public GridEditor[] GridEditors { get; set; } = Array.Empty(); + + /// + /// Gets or sets the content apps listed in the manifest. + /// + [JsonProperty("contentApps")] + public ManifestContentAppDefinition[] ContentApps { get; set; } = Array.Empty(); + + /// + /// Gets or sets the dashboards listed in the manifest. + /// + [JsonProperty("dashboards")] + public ManifestDashboard[] Dashboards { get; set; } = Array.Empty(); + + /// + /// Gets or sets the sections listed in the manifest. + /// + [JsonProperty("sections")] + public ManifestSection[] Sections { get; set; } = Array.Empty(); + } +} diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index 54a59d2162..aee3bc6864 100755 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -158,6 +158,7 @@ + @@ -184,6 +185,7 @@ + diff --git a/src/Umbraco.Tests/Published/ModelTypeTests.cs b/src/Umbraco.Tests/Published/ModelTypeTests.cs index 622bebdf78..1dab67b351 100644 --- a/src/Umbraco.Tests/Published/ModelTypeTests.cs +++ b/src/Umbraco.Tests/Published/ModelTypeTests.cs @@ -53,7 +53,7 @@ namespace Umbraco.Tests.Published // there's an "*" there because the arrays are not true SZArray - but that changes when we map Assert.AreEqual("{alias1}[*]", ModelType.For("alias1").MakeArrayType().FullName); // note the inner assembly qualified name - Assert.AreEqual("System.Collections.Generic.IEnumerable`1[[{alias1}[*], Umbraco.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]", typeof(IEnumerable<>).MakeGenericType(ModelType.For("alias1").MakeArrayType()).FullName); + Assert.AreEqual("System.Collections.Generic.IEnumerable`1[[{alias1}[*], Umbraco.Abstractions, Version=9.0.0.0, Culture=neutral, PublicKeyToken=null]]", typeof(IEnumerable<>).MakeGenericType(ModelType.For("alias1").MakeArrayType()).FullName); } [Test]