diff --git a/build/NuSpecs/tools/Web.config.install.xdt b/build/NuSpecs/tools/Web.config.install.xdt
index 2b79f95c70..f118fa8c3a 100644
--- a/build/NuSpecs/tools/Web.config.install.xdt
+++ b/build/NuSpecs/tools/Web.config.install.xdt
@@ -5,9 +5,9 @@
-
+
-
+
diff --git a/src/Umbraco.Core/Composing/ComponentCollection.cs b/src/Umbraco.Abstractions/Composing/ComponentCollection.cs
similarity index 100%
rename from src/Umbraco.Core/Composing/ComponentCollection.cs
rename to src/Umbraco.Abstractions/Composing/ComponentCollection.cs
diff --git a/src/Umbraco.Core/Composing/ComponentCollectionBuilder.cs b/src/Umbraco.Abstractions/Composing/ComponentCollectionBuilder.cs
similarity index 100%
rename from src/Umbraco.Core/Composing/ComponentCollectionBuilder.cs
rename to src/Umbraco.Abstractions/Composing/ComponentCollectionBuilder.cs
diff --git a/src/Umbraco.Core/Composing/Composition.cs b/src/Umbraco.Abstractions/Composing/Composition.cs
similarity index 96%
rename from src/Umbraco.Core/Composing/Composition.cs
rename to src/Umbraco.Abstractions/Composing/Composition.cs
index 34c5296dce..8cf02151e8 100644
--- a/src/Umbraco.Core/Composing/Composition.cs
+++ b/src/Umbraco.Abstractions/Composing/Composition.cs
@@ -27,19 +27,12 @@ namespace Umbraco.Core.Composing
/// A logger.
/// The runtime state.
/// Optional configs.
- public Composition(IRegister register, TypeLoader typeLoader, IProfilingLogger logger, IRuntimeState runtimeState, Configs configs = null)
+ public Composition(IRegister register, TypeLoader typeLoader, IProfilingLogger logger, IRuntimeState runtimeState, Configs configs)
{
_register = register;
TypeLoader = typeLoader;
Logger = logger;
RuntimeState = runtimeState;
-
- if (configs == null)
- {
- configs = new Configs();
- configs.AddCoreConfigs();
- }
-
Configs = configs;
}
@@ -131,12 +124,14 @@ namespace Umbraco.Core.Composing
builder.RegisterWith(_register);
_builders.Clear(); // no point keep them around
- Configs.RegisterWith(_register);
-
IFactory factory = null;
+
+ Configs.RegisterWith(_register, () => factory);
+
// ReSharper disable once AccessToModifiedClosure -- on purpose
_register.Register(_ => factory, Lifetime.Singleton);
factory = _register.CreateFactory();
+
return factory;
}
diff --git a/src/Umbraco.Core/Composing/IComposer.cs b/src/Umbraco.Abstractions/Composing/IComposer.cs
similarity index 100%
rename from src/Umbraco.Core/Composing/IComposer.cs
rename to src/Umbraco.Abstractions/Composing/IComposer.cs
diff --git a/src/Umbraco.Core/Composing/ICoreComposer.cs b/src/Umbraco.Abstractions/Composing/ICoreComposer.cs
similarity index 100%
rename from src/Umbraco.Core/Composing/ICoreComposer.cs
rename to src/Umbraco.Abstractions/Composing/ICoreComposer.cs
diff --git a/src/Umbraco.Core/CompositionExtensions_Uniques.cs b/src/Umbraco.Abstractions/CompositionExtensions_Uniques.cs
similarity index 100%
rename from src/Umbraco.Core/CompositionExtensions_Uniques.cs
rename to src/Umbraco.Abstractions/CompositionExtensions_Uniques.cs
diff --git a/src/Umbraco.Abstractions/ConfigConnectionStringExtensions.cs b/src/Umbraco.Abstractions/ConfigConnectionStringExtensions.cs
new file mode 100644
index 0000000000..693b8a433e
--- /dev/null
+++ b/src/Umbraco.Abstractions/ConfigConnectionStringExtensions.cs
@@ -0,0 +1,40 @@
+using System;
+using System.IO;
+using System.Linq;
+using Umbraco.Core.Configuration;
+
+namespace Umbraco.Core
+{
+
+ public static class ConfigConnectionStringExtensions
+ {
+ public static bool IsConnectionStringConfigured(this ConfigConnectionString databaseSettings)
+ {
+ var dbIsSqlCe = false;
+ if (databaseSettings?.ProviderName != null)
+ dbIsSqlCe = databaseSettings.ProviderName == Constants.DbProviderNames.SqlCe;
+ var sqlCeDatabaseExists = false;
+ if (dbIsSqlCe)
+ {
+ var parts = databaseSettings.ConnectionString.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
+ var dataSourcePart = parts.FirstOrDefault(x => x.InvariantStartsWith("Data Source="));
+ if (dataSourcePart != null)
+ {
+ var datasource = dataSourcePart.Replace("|DataDirectory|", AppDomain.CurrentDomain.GetData("DataDirectory").ToString());
+ var filePath = datasource.Replace("Data Source=", string.Empty);
+ sqlCeDatabaseExists = File.Exists(filePath);
+ }
+ }
+
+ // Either the connection details are not fully specified or it's a SQL CE database that doesn't exist yet
+ if (databaseSettings == null
+ || string.IsNullOrWhiteSpace(databaseSettings.ConnectionString) || string.IsNullOrWhiteSpace(databaseSettings.ProviderName)
+ || (dbIsSqlCe && sqlCeDatabaseExists == false))
+ {
+ return false;
+ }
+
+ return true;
+ }
+ }
+}
diff --git a/src/Umbraco.Abstractions/Configuration/ConfigConnectionString.cs b/src/Umbraco.Abstractions/Configuration/ConfigConnectionString.cs
new file mode 100644
index 0000000000..e9ac944b85
--- /dev/null
+++ b/src/Umbraco.Abstractions/Configuration/ConfigConnectionString.cs
@@ -0,0 +1,16 @@
+namespace Umbraco.Core.Configuration
+{
+ public class ConfigConnectionString
+ {
+ public ConfigConnectionString(string connectionString, string providerName, string name)
+ {
+ ConnectionString = connectionString;
+ ProviderName = providerName;
+ Name = name;
+ }
+
+ public string ConnectionString { get; }
+ public string ProviderName { get; }
+ public string Name { get; }
+ }
+}
diff --git a/src/Umbraco.Core/Configuration/Configs.cs b/src/Umbraco.Abstractions/Configuration/Configs.cs
similarity index 82%
rename from src/Umbraco.Core/Configuration/Configs.cs
rename to src/Umbraco.Abstractions/Configuration/Configs.cs
index 51e1a327a0..abb06d525f 100644
--- a/src/Umbraco.Core/Configuration/Configs.cs
+++ b/src/Umbraco.Abstractions/Configuration/Configs.cs
@@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
-using System.Configuration;
using Umbraco.Core.Composing;
-using Umbraco.Core.Logging;
namespace Umbraco.Core.Configuration
{
@@ -15,8 +13,16 @@ namespace Umbraco.Core.Configuration
///
public class Configs
{
+ private readonly Func _configSectionResolver;
+
+ public Configs(Func configSectionResolver)
+ {
+ _configSectionResolver = configSectionResolver ?? throw new ArgumentNullException(nameof(configSectionResolver));
+ }
+
private readonly Dictionary> _configs = new Dictionary>();
private Dictionary> _registerings = new Dictionary>();
+ private Lazy _factory;
///
/// Gets a configuration.
@@ -60,7 +66,7 @@ namespace Umbraco.Core.Configuration
_configs[typeOfConfig] = new Lazy
public interface IGlobalSettings
{
+ // fixme: Review this class, it is now just a dumping ground for config options (based basically on whatever might be in appSettings),
+ // our config classes should be named according to what they are configuring.
+
///
/// Gets the reserved urls from web.config.
///
@@ -63,14 +66,39 @@
///
LocalTempStorage LocalTempStorageLocation { get; }
- ///
- /// Gets the location of temporary files.
- ///
- string LocalTempPath { get; }
-
string UmbracoPath { get; }
string UmbracoCssPath { get; }
string UmbracoScriptsPath { get; }
string UmbracoMediaPath { get; }
+ bool DebugMode { get; }
+
+ bool IsSmtpServerConfigured { get; }
+
+ ///
+ /// Gets a value indicating whether the runtime should enter Install level when the database is missing.
+ ///
+ ///
+ /// By default, when a database connection string is configured but it is not possible to
+ /// connect to the database, the runtime enters the BootFailed level. If this options is set to true,
+ /// it enters the Install level instead.
+ /// It is then up to the implementor, that is setting this value, to take over the installation
+ /// sequence.
+ ///
+ bool InstallMissingDatabase { get; }
+
+ ///
+ /// Gets a value indicating whether the runtime should enter Install level when the database is empty.
+ ///
+ ///
+ /// By default, when a database connection string is configured and it is possible to connect to
+ /// the database, but the database is empty, the runtime enters the BootFailed level. If this options
+ /// is set to true, it enters the Install level instead.
+ /// It is then up to the implementor, that is setting this value, to take over the installation
+ /// sequence.
+ ///
+ bool InstallEmptyDatabase { get; }
+ bool DisableElectionForSingleServer { get; }
+ string RegisterType { get; }
+ string DatabaseFactoryServerVersion { get; }
}
}
diff --git a/src/Umbraco.Abstractions/Configuration/IUmbracoVersion.cs b/src/Umbraco.Abstractions/Configuration/IUmbracoVersion.cs
new file mode 100644
index 0000000000..1bdce0ec7c
--- /dev/null
+++ b/src/Umbraco.Abstractions/Configuration/IUmbracoVersion.cs
@@ -0,0 +1,56 @@
+using System;
+using Semver;
+
+namespace Umbraco.Core.Configuration
+{
+ public interface IUmbracoVersion
+ {
+ ///
+ /// Gets the non-semantic version of the Umbraco code.
+ ///
+ Version Current { get; }
+
+ ///
+ /// Gets the semantic version comments of the Umbraco code.
+ ///
+ string Comment { get; }
+
+ ///
+ /// Gets the assembly version of the Umbraco code.
+ ///
+ ///
+ /// The assembly version is the value of the .
+ /// Is the one that the CLR checks for compatibility. Therefore, it changes only on
+ /// hard-breaking changes (for instance, on new major versions).
+ ///
+ Version AssemblyVersion { get; }
+
+ ///
+ /// Gets the assembly file version of the Umbraco code.
+ ///
+ ///
+ /// The assembly version is the value of the .
+ ///
+ Version AssemblyFileVersion { get; }
+
+ ///
+ /// Gets the semantic version of the Umbraco code.
+ ///
+ ///
+ /// The semantic version is the value of the .
+ /// It is the full version of Umbraco, including comments.
+ ///
+ SemVersion SemanticVersion { get; }
+
+ ///
+ /// Gets the "local" version of the site.
+ ///
+ ///
+ /// Three things have a version, really: the executing code, the database model,
+ /// and the site/files. The database model version is entirely managed via migrations,
+ /// and changes during an upgrade. The executing code version changes when new code is
+ /// deployed. The site/files version changes during an upgrade.
+ ///
+ SemVersion LocalVersion { get; }
+ }
+}
diff --git a/src/Umbraco.Core/Configuration/UmbracoVersion.cs b/src/Umbraco.Abstractions/Configuration/UmbracoVersion.cs
similarity index 74%
rename from src/Umbraco.Core/Configuration/UmbracoVersion.cs
rename to src/Umbraco.Abstractions/Configuration/UmbracoVersion.cs
index 2f615d26b3..dd96e6edd7 100644
--- a/src/Umbraco.Core/Configuration/UmbracoVersion.cs
+++ b/src/Umbraco.Abstractions/Configuration/UmbracoVersion.cs
@@ -8,11 +8,19 @@ namespace Umbraco.Core.Configuration
///
/// Represents the version of the executing code.
///
- public static class UmbracoVersion
+ public class UmbracoVersion : IUmbracoVersion
{
- static UmbracoVersion()
+ private readonly IGlobalSettings _globalSettings;
+
+ public UmbracoVersion(IGlobalSettings globalSettings)
+ :this()
{
- var umbracoCoreAssembly = typeof(UmbracoVersion).Assembly;
+ _globalSettings = globalSettings;
+ }
+
+ public UmbracoVersion()
+ {
+ var umbracoCoreAssembly = typeof(SemVersion).Assembly;
// gets the value indicated by the AssemblyVersion attribute
AssemblyVersion = umbracoCoreAssembly.GetName().Version;
@@ -32,12 +40,12 @@ namespace Umbraco.Core.Configuration
/// Gets the non-semantic version of the Umbraco code.
///
// TODO: rename to Version
- public static Version Current { get; }
+ public Version Current { get; }
///
/// Gets the semantic version comments of the Umbraco code.
///
- public static string Comment => SemanticVersion.Prerelease;
+ public string Comment => SemanticVersion.Prerelease;
///
/// Gets the assembly version of the Umbraco code.
@@ -47,7 +55,7 @@ namespace Umbraco.Core.Configuration
/// Is the one that the CLR checks for compatibility. Therefore, it changes only on
/// hard-breaking changes (for instance, on new major versions).
///
- public static Version AssemblyVersion {get; }
+ public Version AssemblyVersion {get; }
///
/// Gets the assembly file version of the Umbraco code.
@@ -55,7 +63,7 @@ namespace Umbraco.Core.Configuration
///
/// The assembly version is the value of the .
///
- public static Version AssemblyFileVersion { get; }
+ public Version AssemblyFileVersion { get; }
///
/// Gets the semantic version of the Umbraco code.
@@ -64,7 +72,7 @@ namespace Umbraco.Core.Configuration
/// The semantic version is the value of the .
/// It is the full version of Umbraco, including comments.
///
- public static SemVersion SemanticVersion { get; }
+ public SemVersion SemanticVersion { get; }
///
/// Gets the "local" version of the site.
@@ -75,21 +83,11 @@ namespace Umbraco.Core.Configuration
/// and changes during an upgrade. The executing code version changes when new code is
/// deployed. The site/files version changes during an upgrade.
///
- public static SemVersion LocalVersion
- {
+ public SemVersion LocalVersion {
get
{
- try
- {
- // TODO: https://github.com/umbraco/Umbraco-CMS/issues/4238 - stop having version in web.config appSettings
- var value = ConfigurationManager.AppSettings[Constants.AppSettings.ConfigurationStatus];
- return value.IsNullOrWhiteSpace() ? null : SemVersion.TryParse(value, out var semver) ? semver : null;
- }
- catch
- {
- return null;
- }
- }
- }
+ var value = _globalSettings.ConfigurationStatus;
+ return value.IsNullOrWhiteSpace() ? null : SemVersion.TryParse(value, out var semver) ? semver : null;
+ } }
}
}
diff --git a/src/Umbraco.Core/Events/CancellableEnumerableObjectEventArgs.cs b/src/Umbraco.Abstractions/Events/CancellableEnumerableObjectEventArgs.cs
similarity index 100%
rename from src/Umbraco.Core/Events/CancellableEnumerableObjectEventArgs.cs
rename to src/Umbraco.Abstractions/Events/CancellableEnumerableObjectEventArgs.cs
diff --git a/src/Umbraco.Core/Events/CancellableObjectEventArgsOfTEventObject.cs b/src/Umbraco.Abstractions/Events/CancellableObjectEventArgsOfTEventObject.cs
similarity index 100%
rename from src/Umbraco.Core/Events/CancellableObjectEventArgsOfTEventObject.cs
rename to src/Umbraco.Abstractions/Events/CancellableObjectEventArgsOfTEventObject.cs
diff --git a/src/Umbraco.Core/Events/CopyEventArgs.cs b/src/Umbraco.Abstractions/Events/CopyEventArgs.cs
similarity index 100%
rename from src/Umbraco.Core/Events/CopyEventArgs.cs
rename to src/Umbraco.Abstractions/Events/CopyEventArgs.cs
diff --git a/src/Umbraco.Core/Events/DeleteEventArgs.cs b/src/Umbraco.Abstractions/Events/DeleteEventArgs.cs
similarity index 99%
rename from src/Umbraco.Core/Events/DeleteEventArgs.cs
rename to src/Umbraco.Abstractions/Events/DeleteEventArgs.cs
index 07bbe562db..5be669886e 100644
--- a/src/Umbraco.Core/Events/DeleteEventArgs.cs
+++ b/src/Umbraco.Abstractions/Events/DeleteEventArgs.cs
@@ -100,7 +100,7 @@ namespace Umbraco.Core.Events
public IEnumerable DeletedEntities
{
get => EventObject;
- internal set => EventObject = value;
+ set => EventObject = value;
}
///
diff --git a/src/Umbraco.Core/Events/DeleteRevisionsEventArgs.cs b/src/Umbraco.Abstractions/Events/DeleteRevisionsEventArgs.cs
similarity index 100%
rename from src/Umbraco.Core/Events/DeleteRevisionsEventArgs.cs
rename to src/Umbraco.Abstractions/Events/DeleteRevisionsEventArgs.cs
diff --git a/src/Umbraco.Core/Events/EventExtensions.cs b/src/Umbraco.Abstractions/Events/EventExtensions.cs
similarity index 100%
rename from src/Umbraco.Core/Events/EventExtensions.cs
rename to src/Umbraco.Abstractions/Events/EventExtensions.cs
diff --git a/src/Umbraco.Core/Events/MoveEventArgs.cs b/src/Umbraco.Abstractions/Events/MoveEventArgs.cs
similarity index 100%
rename from src/Umbraco.Core/Events/MoveEventArgs.cs
rename to src/Umbraco.Abstractions/Events/MoveEventArgs.cs
diff --git a/src/Umbraco.Core/Events/NewEventArgs.cs b/src/Umbraco.Abstractions/Events/NewEventArgs.cs
similarity index 100%
rename from src/Umbraco.Core/Events/NewEventArgs.cs
rename to src/Umbraco.Abstractions/Events/NewEventArgs.cs
diff --git a/src/Umbraco.Core/Events/PublishEventArgs.cs b/src/Umbraco.Abstractions/Events/PublishEventArgs.cs
similarity index 100%
rename from src/Umbraco.Core/Events/PublishEventArgs.cs
rename to src/Umbraco.Abstractions/Events/PublishEventArgs.cs
diff --git a/src/Umbraco.Core/Events/RecycleBinEventArgs.cs b/src/Umbraco.Abstractions/Events/RecycleBinEventArgs.cs
similarity index 95%
rename from src/Umbraco.Core/Events/RecycleBinEventArgs.cs
rename to src/Umbraco.Abstractions/Events/RecycleBinEventArgs.cs
index 796952de98..3f0f3784a2 100644
--- a/src/Umbraco.Core/Events/RecycleBinEventArgs.cs
+++ b/src/Umbraco.Abstractions/Events/RecycleBinEventArgs.cs
@@ -1,8 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Linq;
-using Umbraco.Core.Models;
namespace Umbraco.Core.Events
{
diff --git a/src/Umbraco.Core/Events/RolesEventArgs.cs b/src/Umbraco.Abstractions/Events/RolesEventArgs.cs
similarity index 100%
rename from src/Umbraco.Core/Events/RolesEventArgs.cs
rename to src/Umbraco.Abstractions/Events/RolesEventArgs.cs
diff --git a/src/Umbraco.Core/Events/RollbackEventArgs.cs b/src/Umbraco.Abstractions/Events/RollbackEventArgs.cs
similarity index 100%
rename from src/Umbraco.Core/Events/RollbackEventArgs.cs
rename to src/Umbraco.Abstractions/Events/RollbackEventArgs.cs
diff --git a/src/Umbraco.Core/Events/SaveEventArgs.cs b/src/Umbraco.Abstractions/Events/SaveEventArgs.cs
similarity index 100%
rename from src/Umbraco.Core/Events/SaveEventArgs.cs
rename to src/Umbraco.Abstractions/Events/SaveEventArgs.cs
diff --git a/src/Umbraco.Core/Events/SendToPublishEventArgs.cs b/src/Umbraco.Abstractions/Events/SendToPublishEventArgs.cs
similarity index 100%
rename from src/Umbraco.Core/Events/SendToPublishEventArgs.cs
rename to src/Umbraco.Abstractions/Events/SendToPublishEventArgs.cs
diff --git a/src/Umbraco.Core/Events/TransientEventMessagesFactory.cs b/src/Umbraco.Abstractions/Events/TransientEventMessagesFactory.cs
similarity index 81%
rename from src/Umbraco.Core/Events/TransientEventMessagesFactory.cs
rename to src/Umbraco.Abstractions/Events/TransientEventMessagesFactory.cs
index bd2e12dc17..7a0947c990 100644
--- a/src/Umbraco.Core/Events/TransientEventMessagesFactory.cs
+++ b/src/Umbraco.Abstractions/Events/TransientEventMessagesFactory.cs
@@ -3,7 +3,7 @@
///
/// A simple/default transient messages factory
///
- internal class TransientEventMessagesFactory : IEventMessagesFactory
+ public class TransientEventMessagesFactory : IEventMessagesFactory
{
public EventMessages Get()
{
diff --git a/src/Umbraco.Abstractions/IO/IIOHelper.cs b/src/Umbraco.Abstractions/IO/IIOHelper.cs
index 735aed4813..b4a1007c2d 100644
--- a/src/Umbraco.Abstractions/IO/IIOHelper.cs
+++ b/src/Umbraco.Abstractions/IO/IIOHelper.cs
@@ -19,6 +19,7 @@ namespace Umbraco.Core.IO
string MapPath(string path, bool useHttpContext);
string MapPath(string path);
+
///
/// Verifies that the current filepath matches a directory where the user is allowed to edit a file.
///
diff --git a/src/Umbraco.Core/Logging/DebugDiagnosticsLogger.cs b/src/Umbraco.Abstractions/Logging/DebugDiagnosticsLogger.cs
similarity index 77%
rename from src/Umbraco.Core/Logging/DebugDiagnosticsLogger.cs
rename to src/Umbraco.Abstractions/Logging/DebugDiagnosticsLogger.cs
index d1bde55306..552daba713 100644
--- a/src/Umbraco.Core/Logging/DebugDiagnosticsLogger.cs
+++ b/src/Umbraco.Abstractions/Logging/DebugDiagnosticsLogger.cs
@@ -7,6 +7,13 @@ namespace Umbraco.Core.Logging
///
public class DebugDiagnosticsLogger : ILogger
{
+ private readonly IMessageTemplates _messageTemplates;
+
+ public DebugDiagnosticsLogger(IMessageTemplates messageTemplates)
+ {
+ _messageTemplates = messageTemplates;
+ }
+
public bool IsEnabled(Type reporting, LogLevel level)
=> true;
@@ -31,7 +38,7 @@ namespace Umbraco.Core.Logging
///
public void Fatal(Type reporting, Exception exception, string messageTemplate, params object[] propertyValues)
{
- System.Diagnostics.Debug.WriteLine(MessageTemplates.Render(messageTemplate, propertyValues) + Environment.NewLine + exception, reporting.FullName);
+ System.Diagnostics.Debug.WriteLine(_messageTemplates.Render(messageTemplate, propertyValues) + Environment.NewLine + exception, reporting.FullName);
}
///
@@ -61,7 +68,7 @@ namespace Umbraco.Core.Logging
///
public void Error(Type reporting, Exception exception, string messageTemplate, params object[] propertyValues)
{
- System.Diagnostics.Debug.WriteLine(MessageTemplates.Render(messageTemplate, propertyValues) + Environment.NewLine + exception, reporting.FullName);
+ System.Diagnostics.Debug.WriteLine(_messageTemplates.Render(messageTemplate, propertyValues) + Environment.NewLine + exception, reporting.FullName);
}
///
@@ -79,7 +86,7 @@ namespace Umbraco.Core.Logging
///
public void Warn(Type reporting, string message, params object[] propertyValues)
{
- System.Diagnostics.Debug.WriteLine(MessageTemplates.Render(message, propertyValues), reporting.FullName);
+ System.Diagnostics.Debug.WriteLine(_messageTemplates.Render(message, propertyValues), reporting.FullName);
}
///
@@ -91,7 +98,7 @@ namespace Umbraco.Core.Logging
///
public void Warn(Type reporting, Exception exception, string message, params object[] propertyValues)
{
- System.Diagnostics.Debug.WriteLine(MessageTemplates.Render(message + Environment.NewLine + exception, propertyValues), reporting.FullName);
+ System.Diagnostics.Debug.WriteLine(_messageTemplates.Render(message + Environment.NewLine + exception, propertyValues), reporting.FullName);
}
///
@@ -103,7 +110,7 @@ namespace Umbraco.Core.Logging
///
public void Info(Type reporting, string messageTemplate, params object[] propertyValues)
{
- System.Diagnostics.Debug.WriteLine(MessageTemplates.Render(messageTemplate, propertyValues), reporting.FullName);
+ System.Diagnostics.Debug.WriteLine(_messageTemplates.Render(messageTemplate, propertyValues), reporting.FullName);
}
///
@@ -115,7 +122,7 @@ namespace Umbraco.Core.Logging
///
public void Debug(Type reporting, string messageTemplate, params object[] propertyValues)
{
- System.Diagnostics.Debug.WriteLine(MessageTemplates.Render(messageTemplate, propertyValues), reporting.FullName);
+ System.Diagnostics.Debug.WriteLine(_messageTemplates.Render(messageTemplate, propertyValues), reporting.FullName);
}
///
@@ -127,7 +134,7 @@ namespace Umbraco.Core.Logging
///
public void Verbose(Type reporting, string messageTemplate, params object[] propertyValues)
{
- System.Diagnostics.Debug.WriteLine(MessageTemplates.Render(messageTemplate, propertyValues), reporting.FullName);
+ System.Diagnostics.Debug.WriteLine(_messageTemplates.Render(messageTemplate, propertyValues), reporting.FullName);
}
}
}
diff --git a/src/Umbraco.Abstractions/Logging/IMessageTemplates.cs b/src/Umbraco.Abstractions/Logging/IMessageTemplates.cs
new file mode 100644
index 0000000000..b455e4af21
--- /dev/null
+++ b/src/Umbraco.Abstractions/Logging/IMessageTemplates.cs
@@ -0,0 +1,10 @@
+namespace Umbraco.Core.Logging
+{
+ ///
+ /// Provides tools to support message templates.
+ ///
+ public interface IMessageTemplates
+ {
+ string Render(string messageTemplate, params object[] args);
+ }
+}
diff --git a/src/Umbraco.Core/Logging/LogProfiler.cs b/src/Umbraco.Abstractions/Logging/LogProfiler.cs
similarity index 97%
rename from src/Umbraco.Core/Logging/LogProfiler.cs
rename to src/Umbraco.Abstractions/Logging/LogProfiler.cs
index 74dae545b4..294f92dad3 100644
--- a/src/Umbraco.Core/Logging/LogProfiler.cs
+++ b/src/Umbraco.Abstractions/Logging/LogProfiler.cs
@@ -6,7 +6,7 @@ namespace Umbraco.Core.Logging
///
/// Implements by writing profiling results to an .
///
- internal class LogProfiler : IProfiler
+ public class LogProfiler : IProfiler
{
private readonly ILogger _logger;
diff --git a/src/Umbraco.Core/Logging/LoggingTaskExtension.cs b/src/Umbraco.Abstractions/Logging/LoggingTaskExtension.cs
similarity index 100%
rename from src/Umbraco.Core/Logging/LoggingTaskExtension.cs
rename to src/Umbraco.Abstractions/Logging/LoggingTaskExtension.cs
diff --git a/src/Umbraco.Core/Logging/VoidProfiler.cs b/src/Umbraco.Abstractions/Logging/VoidProfiler.cs
similarity index 92%
rename from src/Umbraco.Core/Logging/VoidProfiler.cs
rename to src/Umbraco.Abstractions/Logging/VoidProfiler.cs
index 24eb8e81c3..51bec521a3 100644
--- a/src/Umbraco.Core/Logging/VoidProfiler.cs
+++ b/src/Umbraco.Abstractions/Logging/VoidProfiler.cs
@@ -2,7 +2,7 @@
namespace Umbraco.Core.Logging
{
- internal class VoidProfiler : IProfiler
+ public class VoidProfiler : IProfiler
{
private readonly VoidDisposable _disposable = new VoidDisposable();
diff --git a/src/Umbraco.Abstractions/Models/Entities/EntityExtensions.cs b/src/Umbraco.Abstractions/Models/Entities/EntityExtensions.cs
index 1e51f81d88..2df08f207d 100644
--- a/src/Umbraco.Abstractions/Models/Entities/EntityExtensions.cs
+++ b/src/Umbraco.Abstractions/Models/Entities/EntityExtensions.cs
@@ -11,7 +11,6 @@ namespace Umbraco.Core.Models.Entities
{
var now = DateTime.Now;
- // just in case
if (entity.CreateDate == default)
{
entity.CreateDate = now;
diff --git a/src/Umbraco.Core/NameValueCollectionExtensions.cs b/src/Umbraco.Abstractions/NameValueCollectionExtensions.cs
similarity index 95%
rename from src/Umbraco.Core/NameValueCollectionExtensions.cs
rename to src/Umbraco.Abstractions/NameValueCollectionExtensions.cs
index 3c52989019..b7272c042d 100644
--- a/src/Umbraco.Core/NameValueCollectionExtensions.cs
+++ b/src/Umbraco.Abstractions/NameValueCollectionExtensions.cs
@@ -6,7 +6,7 @@ using System.Text;
namespace Umbraco.Core
{
- internal static class NameValueCollectionExtensions
+ public static class NameValueCollectionExtensions
{
public static IEnumerable> AsEnumerable(this NameValueCollection nvc)
{
diff --git a/src/Umbraco.Abstractions/Properties/AssemblyInfo.cs b/src/Umbraco.Abstractions/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000000..6d5520f975
--- /dev/null
+++ b/src/Umbraco.Abstractions/Properties/AssemblyInfo.cs
@@ -0,0 +1,35 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+[assembly: ComVisible(false)]
+[assembly: Guid("DA322714-FB89-4943-92BD-BB122B82F66B")]
+
+// Umbraco Cms
+[assembly: InternalsVisibleTo("Umbraco.Web")]
+[assembly: InternalsVisibleTo("Umbraco.Web.UI")]
+[assembly: InternalsVisibleTo("Umbraco.Examine")]
+[assembly: InternalsVisibleTo("Umbraco.ModelsBuilder.Embedded")]
+
+[assembly: InternalsVisibleTo("Umbraco.Tests")]
+[assembly: InternalsVisibleTo("Umbraco.Tests.Benchmarks")]
+
+// Allow this to be mocked in our unit tests
+[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
+
+// Umbraco Deploy
+[assembly: InternalsVisibleTo("Umbraco.Deploy")]
+[assembly: InternalsVisibleTo("Umbraco.Deploy.UI")]
+[assembly: InternalsVisibleTo("Umbraco.Deploy.Cloud")]
+
+// Umbraco Forms
+[assembly: InternalsVisibleTo("Umbraco.Forms.Core")]
+[assembly: InternalsVisibleTo("Umbraco.Forms.Core.Providers")]
+[assembly: InternalsVisibleTo("Umbraco.Forms.Web")]
+
+// Umbraco Headless
+[assembly: InternalsVisibleTo("Umbraco.Cloud.Headless")]
+
+// code analysis
+// IDE1006 is broken, wants _value syntax for consts, etc - and it's even confusing ppl at MS, kill it
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "~_~")]
diff --git a/src/Umbraco.Core/PropertyEditors/IIgnoreUserStartNodesConfig.cs b/src/Umbraco.Abstractions/PropertyEditors/IIgnoreUserStartNodesConfig.cs
similarity index 82%
rename from src/Umbraco.Core/PropertyEditors/IIgnoreUserStartNodesConfig.cs
rename to src/Umbraco.Abstractions/PropertyEditors/IIgnoreUserStartNodesConfig.cs
index bef3f42f46..28ce8654c3 100644
--- a/src/Umbraco.Core/PropertyEditors/IIgnoreUserStartNodesConfig.cs
+++ b/src/Umbraco.Abstractions/PropertyEditors/IIgnoreUserStartNodesConfig.cs
@@ -3,7 +3,7 @@
///
/// Marker interface for any editor configuration that supports Ignoring user start nodes
///
- internal interface IIgnoreUserStartNodesConfig
+ public interface IIgnoreUserStartNodesConfig
{
bool IgnoreUserStartNodes { get; set; }
}
diff --git a/src/Umbraco.Core/RegisterExtensions.cs b/src/Umbraco.Abstractions/RegisterExtensions.cs
similarity index 100%
rename from src/Umbraco.Core/RegisterExtensions.cs
rename to src/Umbraco.Abstractions/RegisterExtensions.cs
diff --git a/src/Umbraco.Abstractions/Services/IRuntime.cs b/src/Umbraco.Abstractions/Services/IRuntime.cs
index d433dde12d..e846342dbc 100644
--- a/src/Umbraco.Abstractions/Services/IRuntime.cs
+++ b/src/Umbraco.Abstractions/Services/IRuntime.cs
@@ -1,4 +1,5 @@
using Umbraco.Core.Composing;
+using Umbraco.Core.Configuration;
namespace Umbraco.Core
{
diff --git a/src/Umbraco.Abstractions/Umbraco.Abstractions.csproj b/src/Umbraco.Abstractions/Umbraco.Abstractions.csproj
index b3a1b4fa25..4fbb43e33d 100644
--- a/src/Umbraco.Abstractions/Umbraco.Abstractions.csproj
+++ b/src/Umbraco.Abstractions/Umbraco.Abstractions.csproj
@@ -4,6 +4,10 @@
netstandard2.0
7.3
Umbraco.Core
+ 9.0.0
+ 9.0.0
+ 9.0.0
+ Umbraco CMS
diff --git a/src/Umbraco.Core/Configuration/CaseInsensitiveEnumConfigConverter.cs b/src/Umbraco.Configuration/CaseInsensitiveEnumConfigConverter.cs
similarity index 100%
rename from src/Umbraco.Core/Configuration/CaseInsensitiveEnumConfigConverter.cs
rename to src/Umbraco.Configuration/CaseInsensitiveEnumConfigConverter.cs
diff --git a/src/Umbraco.Core/Configuration/CommaDelimitedConfigurationElement.cs b/src/Umbraco.Configuration/CommaDelimitedConfigurationElement.cs
similarity index 100%
rename from src/Umbraco.Core/Configuration/CommaDelimitedConfigurationElement.cs
rename to src/Umbraco.Configuration/CommaDelimitedConfigurationElement.cs
diff --git a/src/Umbraco.Configuration/ConfigsFactory.cs b/src/Umbraco.Configuration/ConfigsFactory.cs
new file mode 100644
index 0000000000..c016c3171d
--- /dev/null
+++ b/src/Umbraco.Configuration/ConfigsFactory.cs
@@ -0,0 +1,34 @@
+using System.Configuration;
+using Umbraco.Core.Configuration.HealthChecks;
+using Umbraco.Core.Configuration.UmbracoSettings;
+using Umbraco.Core.IO;
+
+namespace Umbraco.Core.Configuration
+{
+ public class ConfigsFactory : IConfigsFactory
+ {
+ private readonly IIOHelper _ioHelper;
+
+ public ConfigsFactory(IIOHelper ioHelper)
+ {
+ _ioHelper = ioHelper;
+ GlobalSettings = new GlobalSettings(_ioHelper);
+ }
+
+ public IGlobalSettings GlobalSettings { get; }
+
+ public Configs Create()
+ {
+ var configs = new Configs(section => ConfigurationManager.GetSection(section));
+ configs.Add(() => GlobalSettings);
+
+ configs.Add("umbracoConfiguration/settings");
+ configs.Add("umbracoConfiguration/HealthChecks");
+
+ configs.Add(() => new CoreDebug());
+ configs.Add(() => new ConnectionStrings());
+ configs.AddCoreConfigs(_ioHelper);
+ return configs;
+ }
+ }
+}
diff --git a/src/Umbraco.Configuration/ConnectionStrings.cs b/src/Umbraco.Configuration/ConnectionStrings.cs
new file mode 100644
index 0000000000..1842ff6627
--- /dev/null
+++ b/src/Umbraco.Configuration/ConnectionStrings.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Configuration;
+using System.Linq;
+using System.Xml.Linq;
+using Umbraco.Core.IO;
+
+namespace Umbraco.Core.Configuration
+{
+ public class ConnectionStrings : IConnectionStrings
+ {
+ public ConfigConnectionString this[string key]
+ {
+ get
+ {
+ var settings = ConfigurationManager.ConnectionStrings[key];
+
+ return new ConfigConnectionString(settings.ConnectionString, settings.ProviderName, settings.Name);
+ }
+ }
+ }
+}
diff --git a/src/Umbraco.Core/Configuration/CoreDebug.cs b/src/Umbraco.Configuration/CoreDebug.cs
similarity index 53%
rename from src/Umbraco.Core/Configuration/CoreDebug.cs
rename to src/Umbraco.Configuration/CoreDebug.cs
index b24e8a3329..0ff3274565 100644
--- a/src/Umbraco.Core/Configuration/CoreDebug.cs
+++ b/src/Umbraco.Configuration/CoreDebug.cs
@@ -1,22 +1,21 @@
using System;
+using System.Configuration;
namespace Umbraco.Core.Configuration
{
- internal class CoreDebug
+ public class CoreDebug : ICoreDebug
{
public CoreDebug()
{
- var appSettings = System.Configuration.ConfigurationManager.AppSettings;
+ var appSettings = ConfigurationManager.AppSettings;
LogUncompletedScopes = string.Equals("true", appSettings[Constants.AppSettings.Debug.LogUncompletedScopes], StringComparison.OrdinalIgnoreCase);
DumpOnTimeoutThreadAbort = string.Equals("true", appSettings[Constants.AppSettings.Debug.DumpOnTimeoutThreadAbort], StringComparison.OrdinalIgnoreCase);
}
- // when true, Scope logs the stack trace for any scope that gets disposed without being completed.
- // this helps troubleshooting rogue scopes that we forget to complete
+ ///
public bool LogUncompletedScopes { get; }
- // when true, the Logger creates a mini dump of w3wp in ~/App_Data/MiniDump whenever it logs
- // an error due to a ThreadAbortException that is due to a timeout.
+ ///
public bool DumpOnTimeoutThreadAbort { get; }
}
}
diff --git a/src/Umbraco.Core/Configuration/GlobalSettings.cs b/src/Umbraco.Configuration/GlobalSettings.cs
similarity index 76%
rename from src/Umbraco.Core/Configuration/GlobalSettings.cs
rename to src/Umbraco.Configuration/GlobalSettings.cs
index b224d03ecd..0d1bb2a494 100644
--- a/src/Umbraco.Core/Configuration/GlobalSettings.cs
+++ b/src/Umbraco.Configuration/GlobalSettings.cs
@@ -1,12 +1,7 @@
using System;
using System.Configuration;
using System.Linq;
-using System.Net.Configuration;
-using System.Web;
-using System.Web.Configuration;
-using System.Web.Hosting;
using System.Xml.Linq;
-using Umbraco.Core.Composing;
using Umbraco.Core.IO;
namespace Umbraco.Core.Configuration
@@ -19,6 +14,7 @@ namespace Umbraco.Core.Configuration
///
public class GlobalSettings : IGlobalSettings
{
+ private readonly IIOHelper _ioHelper;
private string _localTempPath;
// TODO these should not be static
@@ -29,6 +25,11 @@ namespace Umbraco.Core.Configuration
internal const string StaticReservedPaths = "~/app_plugins/,~/install/,~/mini-profiler-resources/,"; //must end with a comma!
internal const string StaticReservedUrls = "~/config/splashes/noNodes.aspx,~/.well-known,"; //must end with a comma!
+ public GlobalSettings(IIOHelper ioHelper)
+ {
+ _ioHelper = ioHelper;
+ }
+
///
/// Used in unit testing to reset all config items that were set with property setters (i.e. did not come from config)
///
@@ -47,20 +48,42 @@ namespace Umbraco.Core.Configuration
{
ResetInternal();
}
-
- public static bool HasSmtpServerConfigured(string appPath)
+ public bool IsSmtpServerConfigured
{
- if (HasSmtpServer.HasValue) return HasSmtpServer.Value;
+ get
+ {
+ var smtpSection = ConfigurationManager.GetSection("system.net/mailSettings/smtp") as ConfigurationSection;
+ if (smtpSection is null) return false;
- var config = WebConfigurationManager.OpenWebConfiguration(appPath);
- var settings = (MailSettingsSectionGroup)config.GetSectionGroup("system.net/mailSettings");
- // note: "noreply@example.com" is/was the sample SMTP from email - we'll regard that as "not configured"
- if (settings == null || settings.Smtp == null || "noreply@example.com".Equals(settings.Smtp.From, StringComparison.OrdinalIgnoreCase)) return false;
- if (settings.Smtp.SpecifiedPickupDirectory != null && string.IsNullOrEmpty(settings.Smtp.SpecifiedPickupDirectory.PickupDirectoryLocation) == false)
- return true;
- if (settings.Smtp.Network != null && string.IsNullOrEmpty(settings.Smtp.Network.Host) == false)
- return true;
- return false;
+ var from = smtpSection.ElementInformation.Properties["from"];
+ if (@from != null
+ && @from.Value is string fromPropValue
+ && string.IsNullOrEmpty(fromPropValue) == false
+ && !string.Equals("noreply@example.com", fromPropValue, StringComparison.OrdinalIgnoreCase))
+ {
+ return true;
+ }
+
+ var networkSection = ConfigurationManager.GetSection("system.net/mailSettings/smtp/network") as ConfigurationSection;
+ var host = networkSection?.ElementInformation.Properties["host"];
+ if (host != null
+ && host.Value is string hostPropValue
+ && string.IsNullOrEmpty(hostPropValue) == false)
+ {
+ return true;
+ }
+
+ var specifiedPickupDirectorySection = ConfigurationManager.GetSection("system.net/mailSettings/smtp/specifiedPickupDirectory") as ConfigurationSection;
+ var pickupDirectoryLocation = specifiedPickupDirectorySection?.ElementInformation.Properties["pickupDirectoryLocation"];
+ if (pickupDirectoryLocation != null
+ && pickupDirectoryLocation.Value is string pickupDirectoryLocationPropValue
+ && string.IsNullOrEmpty(pickupDirectoryLocationPropValue) == false)
+ {
+ return true;
+ }
+
+ return false;
+ }
}
///
@@ -141,7 +164,7 @@ namespace Umbraco.Core.Configuration
get
{
return ConfigurationManager.AppSettings.ContainsKey(Constants.AppSettings.Path)
- ? Current.IOHelper.ResolveUrl(ConfigurationManager.AppSettings[Constants.AppSettings.Path])
+ ? _ioHelper.ResolveUrl(ConfigurationManager.AppSettings[Constants.AppSettings.Path])
: string.Empty;
}
}
@@ -160,7 +183,7 @@ namespace Umbraco.Core.Configuration
}
set
{
- SaveSetting(Constants.AppSettings.ConfigurationStatus, value);
+ SaveSetting(Constants.AppSettings.ConfigurationStatus, value, _ioHelper);
}
}
@@ -169,9 +192,9 @@ namespace Umbraco.Core.Configuration
///
/// Key of the setting to be saved.
/// Value of the setting to be saved.
- internal static void SaveSetting(string key, string value)
+ internal static void SaveSetting(string key, string value, IIOHelper ioHelper)
{
- var fileName = Current.IOHelper.MapPath(string.Format("{0}/web.config", Current.IOHelper.Root));
+ var fileName = ioHelper.MapPath(string.Format("{0}/web.config", ioHelper.Root));
var xml = XDocument.Load(fileName, LoadOptions.PreserveWhitespace);
var appSettings = xml.Root.DescendantsAndSelf("appSettings").Single();
@@ -191,9 +214,9 @@ namespace Umbraco.Core.Configuration
/// Removes a setting from the configuration file.
///
/// Key of the setting to be removed.
- internal static void RemoveSetting(string key)
+ public static void RemoveSetting(string key, IIOHelper ioHelper)
{
- var fileName = Current.IOHelper.MapPath(string.Format("{0}/web.config", Current.IOHelper.Root));
+ var fileName = ioHelper.MapPath(string.Format("{0}/web.config", ioHelper.Root));
var xml = XDocument.Load(fileName, LoadOptions.PreserveWhitespace);
var appSettings = xml.Root.DescendantsAndSelf("appSettings").Single();
@@ -207,28 +230,25 @@ namespace Umbraco.Core.Configuration
}
}
- ///
- /// Gets a value indicating whether umbraco is running in [debug mode].
- ///
- /// true if [debug mode]; otherwise, false.
- public static bool DebugMode
+ public bool DebugMode
{
get
{
try
{
- if (HttpContext.Current != null)
+ if (ConfigurationManager.GetSection("system.web/compilation") is ConfigurationSection compilation)
{
- return HttpContext.Current.IsDebuggingEnabled;
+ var debugElement = compilation.ElementInformation.Properties["debug"];
+
+ return debugElement != null && (debugElement.Value is bool debug && debug);
}
- //go and get it from config directly
- var section = ConfigurationManager.GetSection("system.web/compilation") as CompilationSection;
- return section != null && section.Debug;
}
catch
{
- return false;
+ // ignored
}
+
+ return false;
}
}
@@ -283,47 +303,6 @@ namespace Umbraco.Core.Configuration
}
}
- ///
- public string LocalTempPath
- {
- get
- {
- if (_localTempPath != null)
- return _localTempPath;
-
- switch (LocalTempStorageLocation)
- {
- case LocalTempStorage.AspNetTemp:
- return _localTempPath = System.IO.Path.Combine(HttpRuntime.CodegenDir, "UmbracoData");
-
- case LocalTempStorage.EnvironmentTemp:
-
- // environment temp is unique, we need a folder per site
-
- // use a hash
- // combine site name and application id
- // site name is a Guid on Cloud
- // application id is eg /LM/W3SVC/123456/ROOT
- // the combination is unique on one server
- // and, if a site moves from worker A to B and then back to A...
- // hopefully it gets a new Guid or new application id?
-
- var siteName = HostingEnvironment.SiteName;
- var applicationId = HostingEnvironment.ApplicationID; // ie HttpRuntime.AppDomainAppId
-
- var hashString = siteName + "::" + applicationId;
- var hash = hashString.GenerateHash();
- var siteTemp = System.IO.Path.Combine(Environment.ExpandEnvironmentVariables("%temp%"), "UmbracoData", hash);
-
- return _localTempPath = siteTemp;
-
- //case LocalTempStorage.Default:
- //case LocalTempStorage.Unknown:
- default:
- return _localTempPath = Current.IOHelper.MapPath("~/App_Data/TEMP");
- }
- }
- }
///
/// Gets the default UI language.
@@ -391,6 +370,21 @@ namespace Umbraco.Core.Configuration
private string _umbracoPath = null;
public string UmbracoPath => GetterWithDefaultValue(Constants.AppSettings.UmbracoPath, "~/umbraco", ref _umbracoPath);
+ private bool _installMissingDatabase;
+ public bool InstallMissingDatabase => GetterWithDefaultValue("Umbraco.Core.RuntimeState.InstallMissingDatabase", false, ref _installMissingDatabase);
+
+ private bool _installEmptyDatabase;
+ public bool InstallEmptyDatabase => GetterWithDefaultValue("Umbraco.Core.RuntimeState.InstallEmptyDatabase", false, ref _installEmptyDatabase);
+
+ private bool _disableElectionForSingleServer;
+ public bool DisableElectionForSingleServer => GetterWithDefaultValue(Constants.AppSettings.DisableElectionForSingleServer, false, ref _disableElectionForSingleServer);
+
+ private string _registerType;
+ public string RegisterType => GetterWithDefaultValue(Constants.AppSettings.RegisterType, string.Empty, ref _registerType);
+
+ private string _databaseFactoryServerVersion;
+ public string DatabaseFactoryServerVersion => GetterWithDefaultValue(Constants.AppSettings.Debug.DatabaseFactoryServerVersion, string.Empty, ref _databaseFactoryServerVersion);
+
private T GetterWithDefaultValue(string appSettingKey, T defaultValue, ref T backingField)
{
if (backingField != null) return backingField;
diff --git a/src/Umbraco.Core/Configuration/HealthChecks/DisabledHealthCheckElement.cs b/src/Umbraco.Configuration/HealthChecks/DisabledHealthCheckElement.cs
similarity index 100%
rename from src/Umbraco.Core/Configuration/HealthChecks/DisabledHealthCheckElement.cs
rename to src/Umbraco.Configuration/HealthChecks/DisabledHealthCheckElement.cs
diff --git a/src/Umbraco.Core/Configuration/HealthChecks/DisabledHealthChecksElementCollection.cs b/src/Umbraco.Configuration/HealthChecks/DisabledHealthChecksElementCollection.cs
similarity index 100%
rename from src/Umbraco.Core/Configuration/HealthChecks/DisabledHealthChecksElementCollection.cs
rename to src/Umbraco.Configuration/HealthChecks/DisabledHealthChecksElementCollection.cs
diff --git a/src/Umbraco.Core/Configuration/HealthChecks/HealthCheckNotificationSettingsElement.cs b/src/Umbraco.Configuration/HealthChecks/HealthCheckNotificationSettingsElement.cs
similarity index 100%
rename from src/Umbraco.Core/Configuration/HealthChecks/HealthCheckNotificationSettingsElement.cs
rename to src/Umbraco.Configuration/HealthChecks/HealthCheckNotificationSettingsElement.cs
diff --git a/src/Umbraco.Core/Configuration/HealthChecks/HealthChecksSection.cs b/src/Umbraco.Configuration/HealthChecks/HealthChecksSection.cs
similarity index 100%
rename from src/Umbraco.Core/Configuration/HealthChecks/HealthChecksSection.cs
rename to src/Umbraco.Configuration/HealthChecks/HealthChecksSection.cs
diff --git a/src/Umbraco.Core/Configuration/HealthChecks/NotificationMethodElement.cs b/src/Umbraco.Configuration/HealthChecks/NotificationMethodElement.cs
similarity index 100%
rename from src/Umbraco.Core/Configuration/HealthChecks/NotificationMethodElement.cs
rename to src/Umbraco.Configuration/HealthChecks/NotificationMethodElement.cs
diff --git a/src/Umbraco.Core/Configuration/HealthChecks/NotificationMethodSettingsElement.cs b/src/Umbraco.Configuration/HealthChecks/NotificationMethodSettingsElement.cs
similarity index 100%
rename from src/Umbraco.Core/Configuration/HealthChecks/NotificationMethodSettingsElement.cs
rename to src/Umbraco.Configuration/HealthChecks/NotificationMethodSettingsElement.cs
diff --git a/src/Umbraco.Core/Configuration/HealthChecks/NotificationMethodSettingsElementCollection.cs b/src/Umbraco.Configuration/HealthChecks/NotificationMethodSettingsElementCollection.cs
similarity index 100%
rename from src/Umbraco.Core/Configuration/HealthChecks/NotificationMethodSettingsElementCollection.cs
rename to src/Umbraco.Configuration/HealthChecks/NotificationMethodSettingsElementCollection.cs
diff --git a/src/Umbraco.Core/Configuration/HealthChecks/NotificationMethodsElementCollection.cs b/src/Umbraco.Configuration/HealthChecks/NotificationMethodsElementCollection.cs
similarity index 100%
rename from src/Umbraco.Core/Configuration/HealthChecks/NotificationMethodsElementCollection.cs
rename to src/Umbraco.Configuration/HealthChecks/NotificationMethodsElementCollection.cs
diff --git a/src/Umbraco.Core/Configuration/InnerTextConfigurationElement.cs b/src/Umbraco.Configuration/InnerTextConfigurationElement.cs
similarity index 100%
rename from src/Umbraco.Core/Configuration/InnerTextConfigurationElement.cs
rename to src/Umbraco.Configuration/InnerTextConfigurationElement.cs
diff --git a/src/Umbraco.Core/Configuration/OptionalCommaDelimitedConfigurationElement.cs b/src/Umbraco.Configuration/OptionalCommaDelimitedConfigurationElement.cs
similarity index 100%
rename from src/Umbraco.Core/Configuration/OptionalCommaDelimitedConfigurationElement.cs
rename to src/Umbraco.Configuration/OptionalCommaDelimitedConfigurationElement.cs
diff --git a/src/Umbraco.Core/Configuration/OptionalInnerTextConfigurationElement.cs b/src/Umbraco.Configuration/OptionalInnerTextConfigurationElement.cs
similarity index 100%
rename from src/Umbraco.Core/Configuration/OptionalInnerTextConfigurationElement.cs
rename to src/Umbraco.Configuration/OptionalInnerTextConfigurationElement.cs
diff --git a/src/Umbraco.Configuration/Properties/AssemblyInfo.cs b/src/Umbraco.Configuration/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000000..d10dd929da
--- /dev/null
+++ b/src/Umbraco.Configuration/Properties/AssemblyInfo.cs
@@ -0,0 +1,10 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// Umbraco Cms
+[assembly: InternalsVisibleTo("Umbraco.Tests")]
+[assembly: InternalsVisibleTo("Umbraco.Tests.Benchmarks")]
+
+// Allow this to be mocked in our unit tests
+[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
diff --git a/src/Umbraco.Core/Configuration/RawXmlConfigurationElement.cs b/src/Umbraco.Configuration/RawXmlConfigurationElement.cs
similarity index 100%
rename from src/Umbraco.Core/Configuration/RawXmlConfigurationElement.cs
rename to src/Umbraco.Configuration/RawXmlConfigurationElement.cs
diff --git a/src/Umbraco.Configuration/Umbraco.Configuration.csproj b/src/Umbraco.Configuration/Umbraco.Configuration.csproj
new file mode 100644
index 0000000000..04f8eb14d3
--- /dev/null
+++ b/src/Umbraco.Configuration/Umbraco.Configuration.csproj
@@ -0,0 +1,39 @@
+
+
+
+ netstandard2.0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <_UnmanagedRegistrationCache Remove="obj\Umbraco.Configuration.csproj.UnmanagedRegistration.cache" />
+ <_UnmanagedRegistrationCache Remove="obj\Umbraco.Configuration.csproj.UnmanagedRegistration.cache" />
+ <_UnmanagedRegistrationCache Remove="obj\Umbraco.Configuration.csproj.UnmanagedRegistration.cache" />
+
+
+
+
+
+
+
+
+
+
+
+
+ C:\Users\Bjarke\AppData\Local\Temp\Temporary ASP.NET Files\root\408beac9\de517473\assembly\dl3\77bf709f\48ac59e4_3595d501\Umbraco.Core.dll
+
+
+
+
diff --git a/src/Umbraco.Core/Configuration/UmbracoConfigurationSection.cs b/src/Umbraco.Configuration/UmbracoConfigurationSection.cs
similarity index 100%
rename from src/Umbraco.Core/Configuration/UmbracoConfigurationSection.cs
rename to src/Umbraco.Configuration/UmbracoConfigurationSection.cs
diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/BackOfficeElement.cs b/src/Umbraco.Configuration/UmbracoSettings/BackOfficeElement.cs
similarity index 100%
rename from src/Umbraco.Core/Configuration/UmbracoSettings/BackOfficeElement.cs
rename to src/Umbraco.Configuration/UmbracoSettings/BackOfficeElement.cs
diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/CharCollection.cs b/src/Umbraco.Configuration/UmbracoSettings/CharCollection.cs
similarity index 100%
rename from src/Umbraco.Core/Configuration/UmbracoSettings/CharCollection.cs
rename to src/Umbraco.Configuration/UmbracoSettings/CharCollection.cs
diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/CharElement.cs b/src/Umbraco.Configuration/UmbracoSettings/CharElement.cs
similarity index 100%
rename from src/Umbraco.Core/Configuration/UmbracoSettings/CharElement.cs
rename to src/Umbraco.Configuration/UmbracoSettings/CharElement.cs
diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/ContentElement.cs b/src/Umbraco.Configuration/UmbracoSettings/ContentElement.cs
similarity index 99%
rename from src/Umbraco.Core/Configuration/UmbracoSettings/ContentElement.cs
rename to src/Umbraco.Configuration/UmbracoSettings/ContentElement.cs
index 77ad7df0dc..8e4f0edd8f 100644
--- a/src/Umbraco.Core/Configuration/UmbracoSettings/ContentElement.cs
+++ b/src/Umbraco.Configuration/UmbracoSettings/ContentElement.cs
@@ -33,7 +33,7 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
[ConfigurationProperty("allowedUploadFiles")]
internal CommaDelimitedConfigurationElement AllowedUploadFiles => GetOptionalDelimitedElement("allowedUploadFiles", new string[0]);
-
+
[ConfigurationProperty("showDeprecatedPropertyEditors")]
internal InnerTextConfigurationElement ShowDeprecatedPropertyEditors => GetOptionalTextElement("showDeprecatedPropertyEditors", false);
diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/ContentError404Collection.cs b/src/Umbraco.Configuration/UmbracoSettings/ContentError404Collection.cs
similarity index 100%
rename from src/Umbraco.Core/Configuration/UmbracoSettings/ContentError404Collection.cs
rename to src/Umbraco.Configuration/UmbracoSettings/ContentError404Collection.cs
diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/ContentErrorPageElement.cs b/src/Umbraco.Configuration/UmbracoSettings/ContentErrorPageElement.cs
similarity index 100%
rename from src/Umbraco.Core/Configuration/UmbracoSettings/ContentErrorPageElement.cs
rename to src/Umbraco.Configuration/UmbracoSettings/ContentErrorPageElement.cs
diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/ContentErrorsElement.cs b/src/Umbraco.Configuration/UmbracoSettings/ContentErrorsElement.cs
similarity index 100%
rename from src/Umbraco.Core/Configuration/UmbracoSettings/ContentErrorsElement.cs
rename to src/Umbraco.Configuration/UmbracoSettings/ContentErrorsElement.cs
diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/ContentImagingElement.cs b/src/Umbraco.Configuration/UmbracoSettings/ContentImagingElement.cs
similarity index 93%
rename from src/Umbraco.Core/Configuration/UmbracoSettings/ContentImagingElement.cs
rename to src/Umbraco.Configuration/UmbracoSettings/ContentImagingElement.cs
index 67562c411a..9a5a9b2a59 100644
--- a/src/Umbraco.Core/Configuration/UmbracoSettings/ContentImagingElement.cs
+++ b/src/Umbraco.Configuration/UmbracoSettings/ContentImagingElement.cs
@@ -12,7 +12,7 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
//set the default
GetDefaultImageFileTypes());
- internal static string[] GetDefaultImageFileTypes()
+ public static string[] GetDefaultImageFileTypes()
{
return new[] {"jpeg", "jpg", "gif", "bmp", "png", "tiff", "tif"};
}
@@ -49,7 +49,7 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
}
}
- internal static ImagingAutoFillPropertiesCollection GetDefaultImageAutoFillProperties()
+ public static ImagingAutoFillPropertiesCollection GetDefaultImageAutoFillProperties()
{
return new ImagingAutoFillPropertiesCollection
{
diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/ContentSectionExtensions.cs b/src/Umbraco.Configuration/UmbracoSettings/ContentSectionExtensions.cs
similarity index 100%
rename from src/Umbraco.Core/Configuration/UmbracoSettings/ContentSectionExtensions.cs
rename to src/Umbraco.Configuration/UmbracoSettings/ContentSectionExtensions.cs
diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/ImagingAutoFillPropertiesCollection.cs b/src/Umbraco.Configuration/UmbracoSettings/ImagingAutoFillPropertiesCollection.cs
similarity index 100%
rename from src/Umbraco.Core/Configuration/UmbracoSettings/ImagingAutoFillPropertiesCollection.cs
rename to src/Umbraco.Configuration/UmbracoSettings/ImagingAutoFillPropertiesCollection.cs
diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/ImagingAutoFillUploadFieldElement.cs b/src/Umbraco.Configuration/UmbracoSettings/ImagingAutoFillUploadFieldElement.cs
similarity index 100%
rename from src/Umbraco.Core/Configuration/UmbracoSettings/ImagingAutoFillUploadFieldElement.cs
rename to src/Umbraco.Configuration/UmbracoSettings/ImagingAutoFillUploadFieldElement.cs
diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/LoggingElement.cs b/src/Umbraco.Configuration/UmbracoSettings/LoggingElement.cs
similarity index 100%
rename from src/Umbraco.Core/Configuration/UmbracoSettings/LoggingElement.cs
rename to src/Umbraco.Configuration/UmbracoSettings/LoggingElement.cs
diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/NotificationsElement.cs b/src/Umbraco.Configuration/UmbracoSettings/NotificationsElement.cs
similarity index 100%
rename from src/Umbraco.Core/Configuration/UmbracoSettings/NotificationsElement.cs
rename to src/Umbraco.Configuration/UmbracoSettings/NotificationsElement.cs
diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/RequestHandlerElement.cs b/src/Umbraco.Configuration/UmbracoSettings/RequestHandlerElement.cs
similarity index 98%
rename from src/Umbraco.Core/Configuration/UmbracoSettings/RequestHandlerElement.cs
rename to src/Umbraco.Configuration/UmbracoSettings/RequestHandlerElement.cs
index 263a822381..80fcb6ca1a 100644
--- a/src/Umbraco.Core/Configuration/UmbracoSettings/RequestHandlerElement.cs
+++ b/src/Umbraco.Configuration/UmbracoSettings/RequestHandlerElement.cs
@@ -38,7 +38,7 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
}
}
- internal static CharCollection GetDefaultCharReplacements()
+ public static CharCollection GetDefaultCharReplacements()
{
var dictionary = new Dictionary()
{
diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/SecurityElement.cs b/src/Umbraco.Configuration/UmbracoSettings/SecurityElement.cs
similarity index 100%
rename from src/Umbraco.Core/Configuration/UmbracoSettings/SecurityElement.cs
rename to src/Umbraco.Configuration/UmbracoSettings/SecurityElement.cs
diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/TourConfigElement.cs b/src/Umbraco.Configuration/UmbracoSettings/TourConfigElement.cs
similarity index 100%
rename from src/Umbraco.Core/Configuration/UmbracoSettings/TourConfigElement.cs
rename to src/Umbraco.Configuration/UmbracoSettings/TourConfigElement.cs
diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/UmbracoConfigurationElement.cs b/src/Umbraco.Configuration/UmbracoSettings/UmbracoConfigurationElement.cs
similarity index 100%
rename from src/Umbraco.Core/Configuration/UmbracoSettings/UmbracoConfigurationElement.cs
rename to src/Umbraco.Configuration/UmbracoSettings/UmbracoConfigurationElement.cs
diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/UmbracoSettingsSection.cs b/src/Umbraco.Configuration/UmbracoSettings/UmbracoSettingsSection.cs
similarity index 58%
rename from src/Umbraco.Core/Configuration/UmbracoSettings/UmbracoSettingsSection.cs
rename to src/Umbraco.Configuration/UmbracoSettings/UmbracoSettingsSection.cs
index 7cf8096345..98fdcaff93 100644
--- a/src/Umbraco.Core/Configuration/UmbracoSettings/UmbracoSettingsSection.cs
+++ b/src/Umbraco.Configuration/UmbracoSettings/UmbracoSettingsSection.cs
@@ -2,26 +2,26 @@
namespace Umbraco.Core.Configuration.UmbracoSettings
{
- public class UmbracoSettingsSection : ConfigurationSection, IUmbracoSettingsSection
+ internal class UmbracoSettingsSection : ConfigurationSection, IUmbracoSettingsSection
{
[ConfigurationProperty("backOffice")]
- internal BackOfficeElement BackOffice => (BackOfficeElement)this["backOffice"];
+ public BackOfficeElement BackOffice => (BackOfficeElement)this["backOffice"];
[ConfigurationProperty("content")]
- internal ContentElement Content => (ContentElement)this["content"];
+ public ContentElement Content => (ContentElement)this["content"];
[ConfigurationProperty("security")]
- internal SecurityElement Security => (SecurityElement)this["security"];
+ public SecurityElement Security => (SecurityElement)this["security"];
[ConfigurationProperty("requestHandler")]
- internal RequestHandlerElement RequestHandler => (RequestHandlerElement)this["requestHandler"];
+ public RequestHandlerElement RequestHandler => (RequestHandlerElement)this["requestHandler"];
[ConfigurationProperty("logging")]
- internal LoggingElement Logging => (LoggingElement)this["logging"];
+ public LoggingElement Logging => (LoggingElement)this["logging"];
[ConfigurationProperty("web.routing")]
- internal WebRoutingElement WebRouting => (WebRoutingElement)this["web.routing"];
+ public WebRoutingElement WebRouting => (WebRoutingElement)this["web.routing"];
IContentSection IUmbracoSettingsSection.Content => Content;
diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/UrlReplacingElement.cs b/src/Umbraco.Configuration/UmbracoSettings/UrlReplacingElement.cs
similarity index 100%
rename from src/Umbraco.Core/Configuration/UmbracoSettings/UrlReplacingElement.cs
rename to src/Umbraco.Configuration/UmbracoSettings/UrlReplacingElement.cs
diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/WebRoutingElement.cs b/src/Umbraco.Configuration/UmbracoSettings/WebRoutingElement.cs
similarity index 100%
rename from src/Umbraco.Core/Configuration/UmbracoSettings/WebRoutingElement.cs
rename to src/Umbraco.Configuration/UmbracoSettings/WebRoutingElement.cs
diff --git a/src/Umbraco.Configuration/UmbracoVersionExtensions.cs b/src/Umbraco.Configuration/UmbracoVersionExtensions.cs
new file mode 100644
index 0000000000..168bb16f57
--- /dev/null
+++ b/src/Umbraco.Configuration/UmbracoVersionExtensions.cs
@@ -0,0 +1,33 @@
+using System.Configuration;
+using Semver;
+using Umbraco.Core;
+using Umbraco.Core.Configuration;
+
+namespace Umbraco.Configuration
+{
+ public static class UmbracoVersionExtensions
+ {
+ ///
+ /// Gets the "local" version of the site.
+ ///
+ ///
+ /// Three things have a version, really: the executing code, the database model,
+ /// and the site/files. The database model version is entirely managed via migrations,
+ /// and changes during an upgrade. The executing code version changes when new code is
+ /// deployed. The site/files version changes during an upgrade.
+ ///
+ public static SemVersion LocalVersion(this IUmbracoVersion umbracoVersion)
+ {
+ try
+ {
+ // TODO: https://github.com/umbraco/Umbraco-CMS/issues/4238 - stop having version in web.config appSettings
+ var value = ConfigurationManager.AppSettings[Constants.AppSettings.ConfigurationStatus];
+ return value.IsNullOrWhiteSpace() ? null : SemVersion.TryParse(value, out var semver) ? semver : null;
+ }
+ catch
+ {
+ return null;
+ }
+ }
+ }
+}
diff --git a/src/Umbraco.Core/Composing/Current.cs b/src/Umbraco.Core/Composing/Current.cs
index afc2a93ea0..3661695c54 100644
--- a/src/Umbraco.Core/Composing/Current.cs
+++ b/src/Umbraco.Core/Composing/Current.cs
@@ -61,7 +61,7 @@ namespace Umbraco.Core.Composing
}
}
- internal static bool HasFactory => _factory != null;
+ public static bool HasFactory => _factory != null;
///
/// Resets . Indented for testing only, and not supported in production code.
@@ -93,11 +93,11 @@ namespace Umbraco.Core.Composing
/// Unlocks so that it is possible to add configurations
/// directly to without having to wire composition.
///
- public static void UnlockConfigs()
+ public static void UnlockConfigs(IConfigsFactory configsFactory)
{
if (_factory != null)
throw new InvalidOperationException("Cannot unlock configs when a factory has been set.");
- _configs = new Configs();
+ _configs = configsFactory.Create();
}
internal static event EventHandler Resetted;
@@ -113,7 +113,7 @@ namespace Umbraco.Core.Composing
public static ILogger Logger
=> _logger ?? (_logger = _factory?.TryGetInstance()
- ?? new DebugDiagnosticsLogger());
+ ?? new DebugDiagnosticsLogger(new MessageTemplates()));
public static IProfiler Profiler
=> _profiler ?? (_profiler = _factory?.TryGetInstance()
@@ -207,6 +207,9 @@ namespace Umbraco.Core.Composing
public static readonly IIOHelper IOHelper = Umbraco.Core.IO.IOHelper.Default;
+ public static IUmbracoVersion UmbracoVersion
+ => Factory.GetInstance();
+
#endregion
}
}
diff --git a/src/Umbraco.Core/Composing/RegisterFactory.cs b/src/Umbraco.Core/Composing/RegisterFactory.cs
index ea25d6a135..8f842e14fe 100644
--- a/src/Umbraco.Core/Composing/RegisterFactory.cs
+++ b/src/Umbraco.Core/Composing/RegisterFactory.cs
@@ -1,6 +1,6 @@
using System;
-using System.Configuration;
using System.Reflection;
+using Umbraco.Core.Configuration;
namespace Umbraco.Core.Composing
{
@@ -21,11 +21,11 @@ namespace Umbraco.Core.Composing
/// To override the default LightInjectContainer, add an appSetting named 'Umbraco.Core.RegisterType' with
/// a fully qualified type name to a class with a static method "Create" returning an IRegister.
///
- public static IRegister Create()
+ public static IRegister Create(IGlobalSettings globalSettings)
{
Type type;
- var configuredTypeName = ConfigurationManager.AppSettings[Constants.AppSettings.RegisterType];
+ var configuredTypeName = globalSettings.RegisterType;
if (configuredTypeName.IsNullOrWhiteSpace())
{
// try to get the web LightInject container type,
diff --git a/src/Umbraco.Core/CompositionExtensions_Essentials.cs b/src/Umbraco.Core/CompositionExtensions_Essentials.cs
index 20c1646629..3174f07468 100644
--- a/src/Umbraco.Core/CompositionExtensions_Essentials.cs
+++ b/src/Umbraco.Core/CompositionExtensions_Essentials.cs
@@ -1,5 +1,6 @@
using Umbraco.Core.Cache;
using Umbraco.Core.Composing;
+using Umbraco.Core.Configuration;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.Persistence;
@@ -22,7 +23,8 @@ namespace Umbraco.Core
TypeLoader typeLoader,
IRuntimeState state,
ITypeFinder typeFinder,
- IIOHelper ioHelper)
+ IIOHelper ioHelper,
+ IUmbracoVersion umbracoVersion)
{
composition.RegisterUnique(logger);
composition.RegisterUnique(profiler);
@@ -35,6 +37,7 @@ namespace Umbraco.Core
composition.RegisterUnique(state);
composition.RegisterUnique(typeFinder);
composition.RegisterUnique(ioHelper);
+ composition.RegisterUnique(umbracoVersion);
}
}
}
diff --git a/src/Umbraco.Core/Configuration/GlobalSettingsExtensions.cs b/src/Umbraco.Core/Configuration/GlobalSettingsExtensions.cs
index 5c45b41f43..65b1a0d9ea 100644
--- a/src/Umbraco.Core/Configuration/GlobalSettingsExtensions.cs
+++ b/src/Umbraco.Core/Configuration/GlobalSettingsExtensions.cs
@@ -1,51 +1,56 @@
using System;
-using System.Collections.Concurrent;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
using System.Web;
-using System.Web.Routing;
-using Umbraco.Core.Composing;
+using System.Web.Hosting;
using Umbraco.Core.IO;
namespace Umbraco.Core.Configuration
{
+
public static class GlobalSettingsExtensions
{
- private static string _mvcArea;
-
+ private static string _localTempPath;
///
- /// This returns the string of the MVC Area route.
+ /// Gets the location of temporary files.
///
- ///
- /// This will return the MVC area that we will route all custom routes through like surface controllers, etc...
- /// We will use the 'Path' (default ~/umbraco) to create it but since it cannot contain '/' and people may specify a path of ~/asdf/asdf/admin
- /// we will convert the '/' to '-' and use that as the path. its a bit lame but will work.
- ///
- /// We also make sure that the virtual directory (SystemDirectories.Root) is stripped off first, otherwise we'd end up with something
- /// like "MyVirtualDirectory-Umbraco" instead of just "Umbraco".
- ///
- public static string GetUmbracoMvcArea(this IGlobalSettings globalSettings)
+ public static string LocalTempPath(this IGlobalSettings globalSettings, IIOHelper ioHelper)
{
- if (_mvcArea != null) return _mvcArea;
- _mvcArea = GetUmbracoMvcAreaNoCache(globalSettings);
+ if (_localTempPath != null)
+ return _localTempPath;
- return _mvcArea;
- }
-
- internal static string GetUmbracoMvcAreaNoCache(this IGlobalSettings globalSettings)
- {
- if (globalSettings.Path.IsNullOrWhiteSpace())
+ switch (globalSettings.LocalTempStorageLocation)
{
- throw new InvalidOperationException("Cannot create an MVC Area path without the umbracoPath specified");
+ case LocalTempStorage.AspNetTemp:
+ return _localTempPath = System.IO.Path.Combine(HttpRuntime.CodegenDir, "UmbracoData");
+
+ case LocalTempStorage.EnvironmentTemp:
+
+ // environment temp is unique, we need a folder per site
+
+ // use a hash
+ // combine site name and application id
+ // site name is a Guid on Cloud
+ // application id is eg /LM/W3SVC/123456/ROOT
+ // the combination is unique on one server
+ // and, if a site moves from worker A to B and then back to A...
+ // hopefully it gets a new Guid or new application id?
+
+ var siteName = HostingEnvironment.SiteName;
+ var applicationId = HostingEnvironment.ApplicationID; // ie HttpRuntime.AppDomainAppId
+
+ var hashString = siteName + "::" + applicationId;
+ var hash = hashString.GenerateHash();
+ var siteTemp = System.IO.Path.Combine(Environment.ExpandEnvironmentVariables("%temp%"), "UmbracoData", hash);
+
+ return _localTempPath = siteTemp;
+
+ //case LocalTempStorage.Default:
+ //case LocalTempStorage.Unknown:
+ default:
+ return _localTempPath = ioHelper.MapPath("~/App_Data/TEMP");
}
- var path = globalSettings.Path;
- if (path.StartsWith(Current.IOHelper.Root)) // beware of TrimStart, see U4-2518
- path = path.Substring(Current.IOHelper.Root.Length);
- return path.TrimStart('~').TrimStart('/').Replace('/', '-').Trim().ToLower();
}
}
diff --git a/src/Umbraco.Core/ConventionsHelper.cs b/src/Umbraco.Core/ConventionsHelper.cs
index 16ad95b95e..834078f84d 100644
--- a/src/Umbraco.Core/ConventionsHelper.cs
+++ b/src/Umbraco.Core/ConventionsHelper.cs
@@ -21,7 +21,8 @@ namespace Umbraco.Core
new PropertyType(Constants.PropertyEditors.Aliases.Label, ValueStorageType.Integer, true,
Constants.Conventions.Member.FailedPasswordAttempts)
{
- Name = Constants.Conventions.Member.FailedPasswordAttemptsLabel
+ Name = Constants.Conventions.Member.FailedPasswordAttemptsLabel,
+ DataTypeId = Constants.DataTypes.LabelInt
}
},
{
@@ -45,7 +46,8 @@ namespace Umbraco.Core
new PropertyType(Constants.PropertyEditors.Aliases.Label, ValueStorageType.Date, true,
Constants.Conventions.Member.LastLockoutDate)
{
- Name = Constants.Conventions.Member.LastLockoutDateLabel
+ Name = Constants.Conventions.Member.LastLockoutDateLabel,
+ DataTypeId = Constants.DataTypes.LabelDateTime
}
},
{
@@ -53,7 +55,8 @@ namespace Umbraco.Core
new PropertyType(Constants.PropertyEditors.Aliases.Label, ValueStorageType.Date, true,
Constants.Conventions.Member.LastLoginDate)
{
- Name = Constants.Conventions.Member.LastLoginDateLabel
+ Name = Constants.Conventions.Member.LastLoginDateLabel,
+ DataTypeId = Constants.DataTypes.LabelDateTime
}
},
{
@@ -61,7 +64,8 @@ namespace Umbraco.Core
new PropertyType(Constants.PropertyEditors.Aliases.Label, ValueStorageType.Date, true,
Constants.Conventions.Member.LastPasswordChangeDate)
{
- Name = Constants.Conventions.Member.LastPasswordChangeDateLabel
+ Name = Constants.Conventions.Member.LastPasswordChangeDateLabel,
+ DataTypeId = Constants.DataTypes.LabelDateTime
}
},
{
@@ -69,7 +73,8 @@ namespace Umbraco.Core
new PropertyType(Constants.PropertyEditors.Aliases.Label, ValueStorageType.Nvarchar, true,
Constants.Conventions.Member.PasswordAnswer)
{
- Name = Constants.Conventions.Member.PasswordAnswerLabel
+ Name = Constants.Conventions.Member.PasswordAnswerLabel,
+ DataTypeId = Constants.DataTypes.LabelString
}
},
{
@@ -77,7 +82,8 @@ namespace Umbraco.Core
new PropertyType(Constants.PropertyEditors.Aliases.Label, ValueStorageType.Nvarchar, true,
Constants.Conventions.Member.PasswordQuestion)
{
- Name = Constants.Conventions.Member.PasswordQuestionLabel
+ Name = Constants.Conventions.Member.PasswordQuestionLabel,
+ DataTypeId = Constants.DataTypes.LabelString
}
}
};
diff --git a/src/Umbraco.Core/EmailSender.cs b/src/Umbraco.Core/EmailSender.cs
index e876d5b0c8..7dc75b116d 100644
--- a/src/Umbraco.Core/EmailSender.cs
+++ b/src/Umbraco.Core/EmailSender.cs
@@ -2,6 +2,7 @@
using System.Net.Mail;
using System.Threading.Tasks;
using System.Web;
+using Umbraco.Core.Composing;
using Umbraco.Core.Configuration;
using Umbraco.Core.Events;
@@ -28,7 +29,7 @@ namespace Umbraco.Core
_enableEvents = enableEvents;
}
- private static readonly Lazy SmtpConfigured = new Lazy(() => GlobalSettings.HasSmtpServerConfigured(HttpRuntime.AppDomainAppVirtualPath));
+ private static readonly Lazy SmtpConfigured = new Lazy(() => Current.Configs.Global().IsSmtpServerConfigured);
///
/// Sends the message non-async
diff --git a/src/Umbraco.Core/IO/IOHelper.cs b/src/Umbraco.Core/IO/IOHelper.cs
index c4fa57dd28..0c15ac1b26 100644
--- a/src/Umbraco.Core/IO/IOHelper.cs
+++ b/src/Umbraco.Core/IO/IOHelper.cs
@@ -115,8 +115,6 @@ namespace Umbraco.Core.IO
return MapPath(path, true);
}
-
-
///
/// Verifies that the current filepath matches a directory where the user is allowed to edit a file.
///
diff --git a/src/Umbraco.Core/IO/MediaFileSystem.cs b/src/Umbraco.Core/IO/MediaFileSystem.cs
index edcbfadf0d..e776c1b2b2 100644
--- a/src/Umbraco.Core/IO/MediaFileSystem.cs
+++ b/src/Umbraco.Core/IO/MediaFileSystem.cs
@@ -1,15 +1,12 @@
using System;
using System.Collections.Generic;
-using System.Configuration;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Umbraco.Core.Composing;
-using Umbraco.Core.Configuration;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.Exceptions;
using Umbraco.Core.Logging;
-using Umbraco.Core.Media;
using Umbraco.Core.Models;
namespace Umbraco.Core.IO
diff --git a/src/Umbraco.Core/IO/SystemFiles.cs b/src/Umbraco.Core/IO/SystemFiles.cs
index 132945d130..5025a5b01f 100644
--- a/src/Umbraco.Core/IO/SystemFiles.cs
+++ b/src/Umbraco.Core/IO/SystemFiles.cs
@@ -11,7 +11,7 @@ namespace Umbraco.Core.IO
// TODO: Kill this off we don't have umbraco.config XML cache we now have NuCache
public static string GetContentCacheXml(IGlobalSettings globalSettings)
{
- return Path.Combine(globalSettings.LocalTempPath, "umbraco.config");
+ return Path.Combine(globalSettings.LocalTempPath(Current.IOHelper), "umbraco.config");
}
}
}
diff --git a/src/Umbraco.Core/Logging/MessageTemplates.cs b/src/Umbraco.Core/Logging/MessageTemplates.cs
index 47de1230ff..4640007e1a 100644
--- a/src/Umbraco.Core/Logging/MessageTemplates.cs
+++ b/src/Umbraco.Core/Logging/MessageTemplates.cs
@@ -8,10 +8,7 @@ using Serilog.Parsing;
namespace Umbraco.Core.Logging
{
- ///
- /// Provides tools to support message templates.
- ///
- public static class MessageTemplates
+ public class MessageTemplates : IMessageTemplates
{
// Umbraco now uses Message Templates (https://messagetemplates.org/) for logging, which means
// we cannot plainly use string.Format() to format them. There is a work-in-progress C# lib,
@@ -21,7 +18,7 @@ namespace Umbraco.Core.Logging
private static readonly Lazy MinimalLogger = new Lazy(() => new LoggerConfiguration().CreateLogger());
- public static string Render(string messageTemplate, params object[] args)
+ public string Render(string messageTemplate, params object[] args)
{
// by default, unless initialized otherwise, Log.Logger is SilentLogger which cannot bind message
// templates. Log.Logger is set to a true Logger when initializing Umbraco's logger, but in case
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/Migrations/Install/DatabaseBuilder.cs b/src/Umbraco.Core/Migrations/Install/DatabaseBuilder.cs
index a0421a27c1..100aaf6478 100644
--- a/src/Umbraco.Core/Migrations/Install/DatabaseBuilder.cs
+++ b/src/Umbraco.Core/Migrations/Install/DatabaseBuilder.cs
@@ -1,5 +1,4 @@
using System;
-using System.Configuration;
using System.Data.SqlServerCe;
using System.IO;
using System.Linq;
@@ -7,7 +6,6 @@ using System.Xml.Linq;
using Umbraco.Core.Composing;
using Umbraco.Core.Configuration;
using Umbraco.Core.Exceptions;
-using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.Migrations.Upgrade;
using Umbraco.Core.Persistence;
@@ -338,35 +336,6 @@ namespace Umbraco.Core.Migrations.Install
attribute.Value = value;
}
- internal bool IsConnectionStringConfigured(ConnectionStringSettings databaseSettings)
- {
- var dbIsSqlCe = false;
- if (databaseSettings?.ProviderName != null)
- dbIsSqlCe = databaseSettings.ProviderName == Constants.DbProviderNames.SqlCe;
- var sqlCeDatabaseExists = false;
- if (dbIsSqlCe)
- {
- var parts = databaseSettings.ConnectionString.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
- var dataSourcePart = parts.FirstOrDefault(x => x.InvariantStartsWith("Data Source="));
- if (dataSourcePart != null)
- {
- var datasource = dataSourcePart.Replace("|DataDirectory|", AppDomain.CurrentDomain.GetData("DataDirectory").ToString());
- var filePath = datasource.Replace("Data Source=", string.Empty);
- sqlCeDatabaseExists = File.Exists(filePath);
- }
- }
-
- // Either the connection details are not fully specified or it's a SQL CE database that doesn't exist yet
- if (databaseSettings == null
- || string.IsNullOrWhiteSpace(databaseSettings.ConnectionString) || string.IsNullOrWhiteSpace(databaseSettings.ProviderName)
- || (dbIsSqlCe && sqlCeDatabaseExists == false))
- {
- return false;
- }
-
- return true;
- }
-
#endregion
#region Database Schema
diff --git a/src/Umbraco.Core/Migrations/Upgrade/UmbracoPlan.cs b/src/Umbraco.Core/Migrations/Upgrade/UmbracoPlan.cs
index e8fd3414ec..070f4bdf6a 100644
--- a/src/Umbraco.Core/Migrations/Upgrade/UmbracoPlan.cs
+++ b/src/Umbraco.Core/Migrations/Upgrade/UmbracoPlan.cs
@@ -1,6 +1,6 @@
using System;
-using System.Configuration;
using Semver;
+using Umbraco.Core.Composing;
using Umbraco.Core.Configuration;
using Umbraco.Core.Migrations.Upgrade.Common;
using Umbraco.Core.Migrations.Upgrade.V_8_0_0;
@@ -17,6 +17,7 @@ namespace Umbraco.Core.Migrations.Upgrade
private const string InitPrefix = "{init-";
private const string InitSuffix = "}";
+ private IUmbracoVersion UmbracoVersion => Current.UmbracoVersion;
///
/// Initializes a new instance of the class.
///
@@ -61,7 +62,7 @@ namespace Umbraco.Core.Migrations.Upgrade
get
{
// no state in database yet - assume we have something in web.config that makes some sense
- if (!SemVersion.TryParse(ConfigurationManager.AppSettings[Constants.AppSettings.ConfigurationStatus], out var currentVersion))
+ if (!SemVersion.TryParse(Current.Configs.Global().ConfigurationStatus, out var currentVersion))
throw new InvalidOperationException($"Could not get current version from web.config {Constants.AppSettings.ConfigurationStatus} appSetting.");
// cannot go back in time
diff --git a/src/Umbraco.Core/Models/Packaging/PackageDefinition.cs b/src/Umbraco.Core/Models/Packaging/PackageDefinition.cs
index 070d0773d2..e12a722b37 100644
--- a/src/Umbraco.Core/Models/Packaging/PackageDefinition.cs
+++ b/src/Umbraco.Core/Models/Packaging/PackageDefinition.cs
@@ -4,6 +4,7 @@ using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Runtime.Serialization;
+using Umbraco.Core.Composing;
namespace Umbraco.Core.Models.Packaging
{
@@ -69,8 +70,8 @@ namespace Umbraco.Core.Models.Packaging
/// The minimum umbraco version that this package requires
///
[DataMember(Name = "umbracoVersion")]
- public Version UmbracoVersion { get; set; } = Configuration.UmbracoVersion.Current;
-
+ public Version UmbracoVersion { get; set; } = Current.UmbracoVersion.Current;
+
[DataMember(Name = "author")]
[Required]
public string Author { get; set; } = string.Empty;
@@ -131,7 +132,7 @@ namespace Umbraco.Core.Models.Packaging
[DataMember(Name = "iconUrl")]
public string IconUrl { get; set; } = string.Empty;
-
+
}
diff --git a/src/Umbraco.Core/Packaging/PackagesRepository.cs b/src/Umbraco.Core/Packaging/PackagesRepository.cs
index cdfb532a39..1dfd6488ba 100644
--- a/src/Umbraco.Core/Packaging/PackagesRepository.cs
+++ b/src/Umbraco.Core/Packaging/PackagesRepository.cs
@@ -548,6 +548,7 @@ namespace Umbraco.Core.Packaging
private static XElement GetPackageInfoXml(PackageDefinition definition)
{
+
var info = new XElement("info");
//Package info
@@ -564,9 +565,9 @@ namespace Umbraco.Core.Packaging
var requirements = new XElement("requirements");
- requirements.Add(new XElement("major", definition.UmbracoVersion == null ? UmbracoVersion.SemanticVersion.Major.ToInvariantString() : definition.UmbracoVersion.Major.ToInvariantString()));
- requirements.Add(new XElement("minor", definition.UmbracoVersion == null ? UmbracoVersion.SemanticVersion.Minor.ToInvariantString() : definition.UmbracoVersion.Minor.ToInvariantString()));
- requirements.Add(new XElement("patch", definition.UmbracoVersion == null ? UmbracoVersion.SemanticVersion.Patch.ToInvariantString() : definition.UmbracoVersion.Build.ToInvariantString()));
+ requirements.Add(new XElement("major", definition.UmbracoVersion == null ? Current.UmbracoVersion.SemanticVersion.Major.ToInvariantString() : definition.UmbracoVersion.Major.ToInvariantString()));
+ requirements.Add(new XElement("minor", definition.UmbracoVersion == null ? Current.UmbracoVersion.SemanticVersion.Minor.ToInvariantString() : definition.UmbracoVersion.Minor.ToInvariantString()));
+ requirements.Add(new XElement("patch", definition.UmbracoVersion == null ? Current.UmbracoVersion.SemanticVersion.Patch.ToInvariantString() : definition.UmbracoVersion.Build.ToInvariantString()));
if (definition.UmbracoVersion != null)
requirements.Add(new XAttribute("type", RequirementsType.Strict.ToString()));
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/MemberTypeRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/MemberTypeRepository.cs
index 741c5922ea..a204ab53d4 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/MemberTypeRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/MemberTypeRepository.cs
@@ -225,8 +225,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
if (builtinProperties.ContainsKey(propertyType.Alias))
{
//this reset's its current data type reference which will be re-assigned based on the property editor assigned on the next line
- var propDefinition = builtinProperties[propertyType.Alias];
- if (propDefinition != null)
+ if (builtinProperties.TryGetValue(propertyType.Alias, out var propDefinition) && propDefinition != null)
{
propertyType.DataTypeId = propDefinition.DataTypeId;
propertyType.DataTypeKey = propDefinition.DataTypeKey;
diff --git a/src/Umbraco.Core/Persistence/UmbracoDatabaseFactory.cs b/src/Umbraco.Core/Persistence/UmbracoDatabaseFactory.cs
index 13422f43b1..6a1a3ee3f1 100644
--- a/src/Umbraco.Core/Persistence/UmbracoDatabaseFactory.cs
+++ b/src/Umbraco.Core/Persistence/UmbracoDatabaseFactory.cs
@@ -1,9 +1,10 @@
using System;
-using System.Configuration;
using System.Data.Common;
using System.Threading;
using NPoco;
using NPoco.FluentMappings;
+using Umbraco.Core.Composing;
+using Umbraco.Core.Configuration;
using Umbraco.Core.Exceptions;
using Umbraco.Core.Logging;
using Umbraco.Core.Persistence.FaultHandling;
@@ -51,15 +52,15 @@ namespace Umbraco.Core.Persistence
/// Initializes a new instance of the .
///
/// Used by core runtime.
- public UmbracoDatabaseFactory(ILogger logger, Lazy mappers)
- : this(Constants.System.UmbracoConnectionName, logger, mappers)
+ public UmbracoDatabaseFactory(ILogger logger, Lazy mappers, Configs configs)
+ : this(Constants.System.UmbracoConnectionName, logger, mappers, configs)
{ }
///
/// Initializes a new instance of the .
///
/// Used by the other ctor and in tests.
- public UmbracoDatabaseFactory(string connectionStringName, ILogger logger, Lazy mappers)
+ public UmbracoDatabaseFactory(string connectionStringName, ILogger logger, Lazy mappers, Configs configs)
{
if (string.IsNullOrWhiteSpace(connectionStringName))
throw new ArgumentNullOrEmptyException(nameof(connectionStringName));
@@ -67,7 +68,8 @@ namespace Umbraco.Core.Persistence
_mappers = mappers ?? throw new ArgumentNullException(nameof(mappers));
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
- var settings = ConfigurationManager.ConnectionStrings[connectionStringName];
+ var settings = configs.ConnectionStrings()[connectionStringName];
+
if (settings == null)
{
logger.Debug("Missing connection string, defer configuration.");
@@ -135,7 +137,7 @@ namespace Umbraco.Core.Persistence
{
// replace NPoco database type by a more efficient one
- var setting = ConfigurationManager.AppSettings[Constants.AppSettings.Debug.DatabaseFactoryServerVersion];
+ var setting = Current.Configs.Global().DatabaseFactoryServerVersion;
var fromSettings = false;
if (setting.IsNullOrWhiteSpace() || !setting.StartsWith("SqlServer.")
diff --git a/src/Umbraco.Core/PropertyEditors/ParameterEditorCollection.cs b/src/Umbraco.Core/PropertyEditors/ParameterEditorCollection.cs
index 4dd4a75c22..dacda815ec 100644
--- a/src/Umbraco.Core/PropertyEditors/ParameterEditorCollection.cs
+++ b/src/Umbraco.Core/PropertyEditors/ParameterEditorCollection.cs
@@ -6,7 +6,7 @@ namespace Umbraco.Core.PropertyEditors
{
public class ParameterEditorCollection : BuilderCollectionBase
{
- public ParameterEditorCollection(DataEditorCollection dataEditors, ManifestParser manifestParser)
+ public ParameterEditorCollection(DataEditorCollection dataEditors, IManifestParser manifestParser)
: base(dataEditors
.Where(x => (x.Type & EditorType.MacroParameter) > 0)
.Union(manifestParser.Manifest.PropertyEditors))
@@ -15,11 +15,11 @@ namespace Umbraco.Core.PropertyEditors
// note: virtual so it can be mocked
public virtual IDataEditor this[string alias]
=> this.SingleOrDefault(x => x.Alias == alias);
-
+
public virtual bool TryGet(string alias, out IDataEditor editor)
{
editor = this.FirstOrDefault(x => x.Alias == alias);
return editor != null;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Umbraco.Core/PropertyEditors/PropertyEditorCollection.cs b/src/Umbraco.Core/PropertyEditors/PropertyEditorCollection.cs
index 712a66e55d..86cfde2ee4 100644
--- a/src/Umbraco.Core/PropertyEditors/PropertyEditorCollection.cs
+++ b/src/Umbraco.Core/PropertyEditors/PropertyEditorCollection.cs
@@ -6,7 +6,7 @@ namespace Umbraco.Core.PropertyEditors
{
public class PropertyEditorCollection : BuilderCollectionBase
{
- public PropertyEditorCollection(DataEditorCollection dataEditors, ManifestParser manifestParser)
+ public PropertyEditorCollection(DataEditorCollection dataEditors, IManifestParser manifestParser)
: base(dataEditors
.Where(x => (x.Type & EditorType.PropertyValue) > 0)
.Union(manifestParser.Manifest.PropertyEditors))
@@ -20,11 +20,11 @@ namespace Umbraco.Core.PropertyEditors
// note: virtual so it can be mocked
public virtual IDataEditor this[string alias]
=> this.SingleOrDefault(x => x.Alias == alias);
-
+
public virtual bool TryGet(string alias, out IDataEditor editor)
{
editor = this.FirstOrDefault(x => x.Alias == alias);
return editor != null;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Umbraco.Core/Runtime/CoreInitialComposer.cs b/src/Umbraco.Core/Runtime/CoreInitialComposer.cs
index bc521b0328..61a9f472fe 100644
--- a/src/Umbraco.Core/Runtime/CoreInitialComposer.cs
+++ b/src/Umbraco.Core/Runtime/CoreInitialComposer.cs
@@ -1,5 +1,4 @@
using System;
-using System.Configuration;
using Umbraco.Core.Cache;
using Umbraco.Core.Composing;
using Umbraco.Core.Composing.CompositionExtensions;
@@ -58,7 +57,7 @@ namespace Umbraco.Core.Runtime
composition.Register();
// register manifest parser, will be injected in collection builders where needed
- composition.RegisterUnique();
+ composition.RegisterUnique();
// register our predefined validators
composition.ManifestValueValidators()
@@ -81,10 +80,11 @@ namespace Umbraco.Core.Runtime
// register a server registrar, by default it's the db registrar
composition.RegisterUnique(f =>
{
- // TODO: this is a hack, use proper configuration!
- // also: we still register the full IServerMessenger because
+ var globalSettings = f.GetInstance();
+
+ // TODO: we still register the full IServerMessenger because
// even on 1 single server we can have 2 concurrent app domains
- var singleServer = "true".InvariantEquals(ConfigurationManager.AppSettings[Constants.AppSettings.DisableElectionForSingleServer]);
+ var singleServer = globalSettings.DisableElectionForSingleServer;
return singleServer
? (IServerRegistrar) new SingleServerRegistrar(f.GetInstance())
: new DatabaseServerRegistrar(
diff --git a/src/Umbraco.Core/Runtime/CoreRuntime.cs b/src/Umbraco.Core/Runtime/CoreRuntime.cs
index 90dbbe666c..6e99cffc60 100644
--- a/src/Umbraco.Core/Runtime/CoreRuntime.cs
+++ b/src/Umbraco.Core/Runtime/CoreRuntime.cs
@@ -10,7 +10,6 @@ using Umbraco.Core.Configuration;
using Umbraco.Core.Exceptions;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
-using Umbraco.Core.Logging.Serilog;
using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.Mappers;
using Umbraco.Core.Sync;
@@ -28,10 +27,31 @@ namespace Umbraco.Core.Runtime
private IFactory _factory;
private RuntimeState _state;
+
+ public CoreRuntime(Configs configs, IUmbracoVersion umbracoVersion, IIOHelper ioHelper, ILogger logger)
+ {
+ IOHelper = ioHelper;
+ Configs = configs;
+ UmbracoVersion = umbracoVersion ;
+
+ Logger = logger;
+ // runtime state
+ // beware! must use '() => _factory.GetInstance()' and NOT '_factory.GetInstance'
+ // as the second one captures the current value (null) and therefore fails
+ _state = new RuntimeState(Logger,
+ Configs.Settings(), Configs.Global(),
+ new Lazy(() => _factory.GetInstance()),
+ new Lazy(() => _factory.GetInstance()),
+ UmbracoVersion)
+ {
+ Level = RuntimeLevel.Boot
+ };
+ }
+
///
/// Gets the logger.
///
- protected ILogger Logger { get; private set; }
+ protected ILogger Logger { get; }
///
/// Gets the profiler.
@@ -51,7 +71,9 @@ namespace Umbraco.Core.Runtime
///
/// Gets the
///
- protected IIOHelper IOHelper { get; private set; }
+ protected IIOHelper IOHelper { get; }
+ protected Configs Configs { get; }
+ protected IUmbracoVersion UmbracoVersion { get; }
///
public IRuntimeState State => _state;
@@ -63,18 +85,11 @@ namespace Umbraco.Core.Runtime
// ie the bare minimum required to boot
// loggers
- var logger = Logger = GetLogger();
- if (logger == null)
- throw new InvalidOperationException($"The object returned from {nameof(GetLogger)} cannot be null");
var profiler = Profiler = GetProfiler();
if (profiler == null)
throw new InvalidOperationException($"The object returned from {nameof(GetProfiler)} cannot be null");
- var profilingLogger = ProfilingLogger = new ProfilingLogger(logger, profiler);
-
- IOHelper = GetIOHelper();
- if (IOHelper == null)
- throw new InvalidOperationException($"The object returned from {nameof(GetIOHelper)} cannot be null");
+ var profilingLogger = ProfilingLogger = new ProfilingLogger(Logger, profiler);
TypeFinder = GetTypeFinder();
if (TypeFinder == null)
@@ -89,17 +104,18 @@ namespace Umbraco.Core.Runtime
// are NOT disposed - which is not a big deal as long as they remain lightweight
// objects.
+ var umbracoVersion = new UmbracoVersion();
using (var timer = profilingLogger.TraceDuration(
- $"Booting Umbraco {UmbracoVersion.SemanticVersion.ToSemanticString()}.",
+ $"Booting Umbraco {umbracoVersion.SemanticVersion.ToSemanticString()}.",
"Booted.",
"Boot failed."))
{
- logger.Info("Booting site '{HostingSiteName}', app '{HostingApplicationID}', path '{HostingPhysicalPath}', server '{MachineName}'.",
+ Logger.Info("Booting site '{HostingSiteName}', app '{HostingApplicationID}', path '{HostingPhysicalPath}', server '{MachineName}'.",
HostingEnvironment.SiteName,
HostingEnvironment.ApplicationID,
HostingEnvironment.ApplicationPhysicalPath,
NetworkHelper.MachineName);
- logger.Debug("Runtime: {Runtime}", GetType().FullName);
+ Logger.Debug("Runtime: {Runtime}", GetType().FullName);
// application environment
ConfigureUnhandledException();
@@ -132,29 +148,15 @@ namespace Umbraco.Core.Runtime
// database factory
var databaseFactory = GetDatabaseFactory();
- // configs
- var configs = GetConfigs();
-
// type finder/loader
- var typeLoader = new TypeLoader(IOHelper, TypeFinder, appCaches.RuntimeCache, new DirectoryInfo(configs.Global().LocalTempPath), ProfilingLogger);
-
- // runtime state
- // beware! must use '() => _factory.GetInstance()' and NOT '_factory.GetInstance'
- // as the second one captures the current value (null) and therefore fails
- _state = new RuntimeState(Logger,
- configs.Settings(), configs.Global(),
- new Lazy(() => _factory.GetInstance()),
- new Lazy(() => _factory.GetInstance()))
- {
- Level = RuntimeLevel.Boot
- };
+ var typeLoader = new TypeLoader(IOHelper, TypeFinder, appCaches.RuntimeCache, new DirectoryInfo(Configs.Global().LocalTempPath(IOHelper)), ProfilingLogger);
// main dom
var mainDom = new MainDom(Logger);
// create the composition
- composition = new Composition(register, typeLoader, ProfilingLogger, _state, configs);
- composition.RegisterEssentials(Logger, Profiler, ProfilingLogger, mainDom, appCaches, databaseFactory, typeLoader, _state, TypeFinder, IOHelper);
+ composition = new Composition(register, typeLoader, ProfilingLogger, _state, Configs);
+ composition.RegisterEssentials(Logger, Profiler, ProfilingLogger, mainDom, appCaches, databaseFactory, typeLoader, _state, TypeFinder, IOHelper, UmbracoVersion);
// run handlers
RuntimeOptions.DoRuntimeEssentials(composition, appCaches, typeLoader, databaseFactory);
@@ -218,6 +220,11 @@ namespace Umbraco.Core.Runtime
return _factory;
}
+ private IUmbracoVersion GetUmbracoVersion(IGlobalSettings globalSettings)
+ {
+ return new UmbracoVersion(globalSettings);
+ }
+
protected virtual void ConfigureUnhandledException()
{
//take care of unhandled exceptions - there is nothing we can do to
@@ -324,12 +331,6 @@ namespace Umbraco.Core.Runtime
protected virtual IEnumerable GetComposerTypes(TypeLoader typeLoader)
=> typeLoader.GetTypes();
- ///
- /// Gets a logger.
- ///
- protected virtual ILogger GetLogger()
- => SerilogLogger.CreateWithDefaultConfiguration();
-
///
/// Gets a profiler.
///
@@ -343,12 +344,6 @@ namespace Umbraco.Core.Runtime
protected virtual ITypeFinder GetTypeFinder()
=> new TypeFinder(Logger);
- ///
- /// Gets a
- ///
- ///
- protected virtual IIOHelper GetIOHelper()
- => Umbraco.Core.IO.IOHelper.Default;
///
/// Gets the application caches.
@@ -375,17 +370,8 @@ namespace Umbraco.Core.Runtime
///
/// This is strictly internal, for tests only.
protected internal virtual IUmbracoDatabaseFactory GetDatabaseFactory()
- => new UmbracoDatabaseFactory(Logger, new Lazy(() => _factory.GetInstance()));
+ => new UmbracoDatabaseFactory(Logger, new Lazy(() => _factory.GetInstance()), Configs);
- ///
- /// Gets the configurations.
- ///
- protected virtual Configs GetConfigs()
- {
- var configs = new Configs();
- configs.AddCoreConfigs();
- return configs;
- }
#endregion
}
diff --git a/src/Umbraco.Core/RuntimeOptions.cs b/src/Umbraco.Core/RuntimeOptions.cs
index c0bae23446..23abd474a4 100644
--- a/src/Umbraco.Core/RuntimeOptions.cs
+++ b/src/Umbraco.Core/RuntimeOptions.cs
@@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
-using System.Configuration;
-using System.Runtime.CompilerServices;
using Umbraco.Core.Cache;
using Umbraco.Core.Composing;
using Umbraco.Core.Logging;
@@ -19,43 +17,6 @@ namespace Umbraco.Core
{
private static List> _onBoot;
private static List> _onEssentials;
- private static bool? _installMissingDatabase;
- private static bool? _installEmptyDatabase;
-
- // reads a boolean appSetting
- private static bool BoolSetting(string key, bool missing) => ConfigurationManager.AppSettings[key]?.InvariantEquals("true") ?? missing;
-
- ///
- /// Gets a value indicating whether the runtime should enter Install level when the database is missing.
- ///
- ///
- /// By default, when a database connection string is configured but it is not possible to
- /// connect to the database, the runtime enters the BootFailed level. If this options is set to true,
- /// it enters the Install level instead.
- /// It is then up to the implementor, that is setting this value, to take over the installation
- /// sequence.
- ///
- public static bool InstallMissingDatabase
- {
- get => _installEmptyDatabase ?? BoolSetting("Umbraco.Core.RuntimeState.InstallMissingDatabase", false);
- set => _installEmptyDatabase = value;
- }
-
- ///
- /// Gets a value indicating whether the runtime should enter Install level when the database is empty.
- ///
- ///
- /// By default, when a database connection string is configured and it is possible to connect to
- /// the database, but the database is empty, the runtime enters the BootFailed level. If this options
- /// is set to true, it enters the Install level instead.
- /// It is then up to the implementor, that is setting this value, to take over the installation
- /// sequence.
- ///
- public static bool InstallEmptyDatabase
- {
- get => _installMissingDatabase ?? BoolSetting("Umbraco.Core.RuntimeState.InstallEmptyDatabase", false);
- set => _installMissingDatabase = value;
- }
///
/// Executes the RuntimeBoot handlers.
diff --git a/src/Umbraco.Core/RuntimeState.cs b/src/Umbraco.Core/RuntimeState.cs
index 5d34fe70a1..e0ce17f769 100644
--- a/src/Umbraco.Core/RuntimeState.cs
+++ b/src/Umbraco.Core/RuntimeState.cs
@@ -25,18 +25,20 @@ namespace Umbraco.Core
private readonly HashSet _applicationUrls = new HashSet();
private readonly Lazy _mainDom;
private readonly Lazy _serverRegistrar;
+ private readonly IUmbracoVersion _umbracoVersion;
///
/// Initializes a new instance of the class.
///
public RuntimeState(ILogger logger, IUmbracoSettingsSection settings, IGlobalSettings globalSettings,
- Lazy mainDom, Lazy serverRegistrar)
+ Lazy mainDom, Lazy serverRegistrar, IUmbracoVersion umbracoVersion)
{
_logger = logger;
_settings = settings;
_globalSettings = globalSettings;
_mainDom = mainDom;
_serverRegistrar = serverRegistrar;
+ _umbracoVersion = umbracoVersion;
}
///
@@ -56,16 +58,16 @@ namespace Umbraco.Core
public IMainDom MainDom => _mainDom.Value;
///
- public Version Version => UmbracoVersion.Current;
+ public Version Version => _umbracoVersion.Current;
///
- public string VersionComment => UmbracoVersion.Comment;
+ public string VersionComment => _umbracoVersion.Comment;
///
- public SemVersion SemanticVersion => UmbracoVersion.SemanticVersion;
+ public SemVersion SemanticVersion => _umbracoVersion.SemanticVersion;
///
- public bool Debug { get; } = GlobalSettings.DebugMode;
+ public bool Debug => HttpContext.Current != null ? HttpContext.Current.IsDebuggingEnabled : _globalSettings.DebugMode;
///
public bool IsMainDom => MainDom.IsMainDom;
@@ -125,7 +127,7 @@ namespace Umbraco.Core
///
public void DetermineRuntimeLevel(IUmbracoDatabaseFactory databaseFactory, ILogger logger)
{
- var localVersion = UmbracoVersion.LocalVersion; // the local, files, version
+ var localVersion = _umbracoVersion.LocalVersion; // the local, files, version
var codeVersion = SemanticVersion; // the executing code version
var connect = false;
@@ -167,7 +169,7 @@ namespace Umbraco.Core
// else, keep going,
// anything other than install wants a database - see if we can connect
// (since this is an already existing database, assume localdb is ready)
- var tries = RuntimeOptions.InstallMissingDatabase ? 2 : 5;
+ var tries = _globalSettings.InstallMissingDatabase ? 2 : 5;
for (var i = 0;;)
{
connect = databaseFactory.CanConnect;
@@ -181,7 +183,7 @@ namespace Umbraco.Core
// cannot connect to configured database, this is bad, fail
logger.Debug("Could not connect to database.");
- if (RuntimeOptions.InstallMissingDatabase)
+ if (_globalSettings.InstallMissingDatabase)
{
// ok to install on a configured but missing database
Level = RuntimeLevel.Install;
@@ -210,7 +212,7 @@ namespace Umbraco.Core
// can connect to the database but cannot check the upgrade state... oops
logger.Warn(e, "Could not check the upgrade state.");
- if (RuntimeOptions.InstallEmptyDatabase)
+ if (_globalSettings.InstallEmptyDatabase)
{
// ok to install on an empty database
Level = RuntimeLevel.Install;
diff --git a/src/Umbraco.Core/Security/MembershipProviderBase.cs b/src/Umbraco.Core/Security/MembershipProviderBase.cs
index 633e12bcc1..aa0ef43b5c 100644
--- a/src/Umbraco.Core/Security/MembershipProviderBase.cs
+++ b/src/Umbraco.Core/Security/MembershipProviderBase.cs
@@ -10,9 +10,7 @@ using System.Web.Configuration;
using System.Web.Hosting;
using System.Web.Security;
using Umbraco.Core.Composing;
-using Umbraco.Core.Configuration;
using Umbraco.Core.Logging;
-using Umbraco.Core.Models;
namespace Umbraco.Core.Security
{
diff --git a/src/Umbraco.Core/Services/Implement/KeyValueService.cs b/src/Umbraco.Core/Services/Implement/KeyValueService.cs
index b3f3f2468d..d5d8e66525 100644
--- a/src/Umbraco.Core/Services/Implement/KeyValueService.cs
+++ b/src/Umbraco.Core/Services/Implement/KeyValueService.cs
@@ -1,5 +1,6 @@
using System;
using System.Linq;
+using Umbraco.Core.Composing;
using Umbraco.Core.Configuration;
using Umbraco.Core.Logging;
using Umbraco.Core.Migrations;
@@ -14,12 +15,14 @@ namespace Umbraco.Core.Services.Implement
private readonly object _initialock = new object();
private readonly IScopeProvider _scopeProvider;
private readonly ILogger _logger;
+ private readonly IUmbracoVersion _umbracoVersion;
private bool _initialized;
- public KeyValueService(IScopeProvider scopeProvider, ILogger logger)
+ public KeyValueService(IScopeProvider scopeProvider, ILogger logger, IUmbracoVersion umbracoVersion)
{
_scopeProvider = scopeProvider;
_logger = logger;
+ _umbracoVersion = umbracoVersion;
}
private void EnsureInitialized()
@@ -39,7 +42,7 @@ namespace Umbraco.Core.Services.Implement
// if already running 8, either following an upgrade or an install,
// then everything should be ok (the table should exist, etc)
- if (UmbracoVersion.LocalVersion != null && UmbracoVersion.LocalVersion.Major >= 8)
+ if (_umbracoVersion.LocalVersion != null && _umbracoVersion.LocalVersion.Major >= 8)
{
_initialized = true;
return;
@@ -202,9 +205,7 @@ namespace Umbraco.Core.Services.Implement
/// Used by to determine the runtime state.
internal static string GetValue(IUmbracoDatabase database, string key)
{
- // not 8 yet = no key/value table, no value
- if (UmbracoVersion.LocalVersion.Major < 8)
- return null;
+ if (database is null) return null;
var sql = database.SqlContext.Sql()
.Select()
diff --git a/src/Umbraco.Core/Sync/DatabaseServerMessenger.cs b/src/Umbraco.Core/Sync/DatabaseServerMessenger.cs
index 7442169b44..118080feb6 100644
--- a/src/Umbraco.Core/Sync/DatabaseServerMessenger.cs
+++ b/src/Umbraco.Core/Sync/DatabaseServerMessenger.cs
@@ -534,7 +534,7 @@ namespace Umbraco.Core.Sync
{
var fileName = HttpRuntime.AppDomainAppId.ReplaceNonAlphanumericChars(string.Empty) + "-lastsynced.txt";
- var distCacheFilePath = Path.Combine(globalSettings.LocalTempPath, "DistCache", fileName);
+ var distCacheFilePath = Path.Combine(globalSettings.LocalTempPath(Current.IOHelper), "DistCache", fileName);
//ensure the folder exists
var folder = Path.GetDirectoryName(distCacheFilePath);
diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj
index eae73c28bc..1335319a9a 100755
--- a/src/Umbraco.Core/Umbraco.Core.csproj
+++ b/src/Umbraco.Core/Umbraco.Core.csproj
@@ -127,330 +127,40 @@
-->
-
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -462,6 +172,7 @@
+
@@ -475,52 +186,282 @@
-
+
+
+
+
+
+
+
-
-
+
-
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -529,72 +470,48 @@
+
+
+
+
+
+
+
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
@@ -623,14 +540,73 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
@@ -643,6 +619,7 @@
+
@@ -659,7 +636,10 @@
+
+
+
@@ -685,121 +665,13 @@
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -816,33 +688,38 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -860,8 +737,8 @@
-
+
@@ -872,8 +749,10 @@
-
+
+
+
@@ -888,21 +767,48 @@
+
-
-
+
+ Properties\SolutionInfo.cs
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -917,9 +823,17 @@
+
+
+
+
+
+
+
+
@@ -950,42 +864,48 @@
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
@@ -999,41 +919,39 @@
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+
+
-
- Component
-
-
- Properties\SolutionInfo.cs
-
-
-
-
-
-
-
@@ -1041,6 +959,11 @@
Umbraco.Abstractions
-
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Umbraco.Core/UriExtensions.cs b/src/Umbraco.Core/UriExtensions.cs
index 9fd1bf46dc..8aedd8f263 100644
--- a/src/Umbraco.Core/UriExtensions.cs
+++ b/src/Umbraco.Core/UriExtensions.cs
@@ -52,9 +52,10 @@ namespace Umbraco.Core
//if not, then def not back office
if (isUmbracoPath == false) return false;
+ var mvcArea = globalSettings.GetUmbracoMvcArea(Current.IOHelper);
//if its the normal /umbraco path
- if (urlPath.InvariantEquals("/" + globalSettings.GetUmbracoMvcArea())
- || urlPath.InvariantEquals("/" + globalSettings.GetUmbracoMvcArea() + "/"))
+ if (urlPath.InvariantEquals("/" + mvcArea)
+ || urlPath.InvariantEquals("/" + mvcArea + "/"))
{
return true;
}
@@ -75,15 +76,15 @@ namespace Umbraco.Core
}
//check for special back office paths
- if (urlPath.InvariantStartsWith("/" + globalSettings.GetUmbracoMvcArea() + "/BackOffice/")
- || urlPath.InvariantStartsWith("/" + globalSettings.GetUmbracoMvcArea() + "/Preview/"))
+ if (urlPath.InvariantStartsWith("/" + mvcArea + "/BackOffice/")
+ || urlPath.InvariantStartsWith("/" + mvcArea + "/Preview/"))
{
return true;
}
//check for special front-end paths
- if (urlPath.InvariantStartsWith("/" + globalSettings.GetUmbracoMvcArea() + "/Surface/")
- || urlPath.InvariantStartsWith("/" + globalSettings.GetUmbracoMvcArea() + "/Api/"))
+ if (urlPath.InvariantStartsWith("/" + mvcArea + "/Surface/")
+ || urlPath.InvariantStartsWith("/" + mvcArea + "/Api/"))
{
return false;
}
diff --git a/src/Umbraco.Tests.Benchmarks/BulkInsertBenchmarks.cs b/src/Umbraco.Tests.Benchmarks/BulkInsertBenchmarks.cs
index d6dc1f8c73..dc260c4a3b 100644
--- a/src/Umbraco.Tests.Benchmarks/BulkInsertBenchmarks.cs
+++ b/src/Umbraco.Tests.Benchmarks/BulkInsertBenchmarks.cs
@@ -49,7 +49,7 @@ namespace Umbraco.Tests.Benchmarks
[GlobalSetup]
public void Setup()
{
- var logger = new DebugDiagnosticsLogger();
+ var logger = new DebugDiagnosticsLogger(new MessageTemplates());
var path = TestHelper.CurrentAssemblyDirectory;
SetupSqlCe(path, logger);
diff --git a/src/Umbraco.Tests/Cache/DistributedCache/DistributedCacheTests.cs b/src/Umbraco.Tests/Cache/DistributedCache/DistributedCacheTests.cs
index 4ef08a15f5..ee78360716 100644
--- a/src/Umbraco.Tests/Cache/DistributedCache/DistributedCacheTests.cs
+++ b/src/Umbraco.Tests/Cache/DistributedCache/DistributedCacheTests.cs
@@ -24,9 +24,9 @@ namespace Umbraco.Tests.Cache.DistributedCache
[SetUp]
public void Setup()
{
- var register = RegisterFactory.Create();
+ var register = TestHelper.GetRegister();
- var composition = new Composition(register, TestHelper.GetMockedTypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run));
+ var composition = new Composition(register, TestHelper.GetMockedTypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs());
composition.RegisterUnique(_ => new TestServerRegistrar());
composition.RegisterUnique(_ => new TestServerMessenger());
diff --git a/src/Umbraco.Tests/Components/ComponentTests.cs b/src/Umbraco.Tests/Components/ComponentTests.cs
index 232d74ba6a..89bcd48d05 100644
--- a/src/Umbraco.Tests/Components/ComponentTests.cs
+++ b/src/Umbraco.Tests/Components/ComponentTests.cs
@@ -8,6 +8,7 @@ using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Core.Compose;
using Umbraco.Core.Composing;
+using Umbraco.Core.Configuration;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.Persistence;
@@ -25,6 +26,7 @@ namespace Umbraco.Tests.Components
private static readonly List Composed = new List();
private static readonly List Initialized = new List();
private static readonly List Terminated = new List();
+ private static readonly Configs Configs = TestHelper.GetConfigs();
private static IFactory MockFactory(Action> setup = null)
{
@@ -34,7 +36,7 @@ namespace Umbraco.Tests.Components
var logger = Mock.Of();
var typeFinder = new TypeFinder(logger);
- var f = new UmbracoDatabaseFactory(logger, new Lazy(() => new MapperCollection(Enumerable.Empty())));
+ var f = new UmbracoDatabaseFactory(logger, new Lazy(() => new MapperCollection(Enumerable.Empty())), TestHelper.GetConfigs());
var fs = new FileSystems(mock.Object, logger, IOHelper.Default, SettingsForTests.GenerateMockGlobalSettings());
var p = new ScopeProvider(f, fs, logger, typeFinder);
@@ -69,7 +71,7 @@ namespace Umbraco.Tests.Components
public void Boot1A()
{
var register = MockRegister();
- var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown));
+ var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown), TestHelper.GetConfigs());
var types = TypeArray();
var composers = new Composers(composition, types, Mock.Of());
@@ -108,7 +110,7 @@ namespace Umbraco.Tests.Components
public void Boot1B()
{
var register = MockRegister();
- var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Run));
+ var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs());
var types = TypeArray();
var composers = new Composers(composition, types, Mock.Of());
@@ -124,7 +126,7 @@ namespace Umbraco.Tests.Components
public void Boot2()
{
var register = MockRegister();
- var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown));
+ var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown), TestHelper.GetConfigs());
var types = TypeArray();
var composers = new Composers(composition, types, Mock.Of());
@@ -139,7 +141,7 @@ namespace Umbraco.Tests.Components
public void Boot3()
{
var register = MockRegister();
- var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown));
+ var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown), TestHelper.GetConfigs());
var types = TypeArray();
var composers = new Composers(composition, types, Mock.Of());
@@ -156,7 +158,7 @@ namespace Umbraco.Tests.Components
public void BrokenRequire()
{
var register = MockRegister();
- var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown));
+ var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown), TestHelper.GetConfigs());
var types = TypeArray();
var composers = new Composers(composition, types, Mock.Of());
@@ -179,7 +181,7 @@ namespace Umbraco.Tests.Components
public void BrokenRequired()
{
var register = MockRegister();
- var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown));
+ var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown), TestHelper.GetConfigs());
var types = TypeArray();
var composers = new Composers(composition, types, Mock.Of());
@@ -214,7 +216,7 @@ namespace Umbraco.Tests.Components
throw new NotSupportedException(type.FullName);
});
});
- var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown));
+ var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown), TestHelper.GetConfigs());
var types = new[] { typeof(Composer1), typeof(Composer5), typeof(Composer5a) };
var composers = new Composers(composition, types, Mock.Of());
@@ -240,7 +242,7 @@ namespace Umbraco.Tests.Components
public void Requires1()
{
var register = MockRegister();
- var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown));
+ var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown), TestHelper.GetConfigs());
var types = new[] { typeof(Composer6), typeof(Composer7), typeof(Composer8) };
var composers = new Composers(composition, types, Mock.Of());
@@ -255,7 +257,7 @@ namespace Umbraco.Tests.Components
public void Requires2A()
{
var register = MockRegister();
- var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown));
+ var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown), Configs);
var types = new[] { typeof(Composer9), typeof(Composer2), typeof(Composer4) };
var composers = new Composers(composition, types, Mock.Of());
@@ -272,7 +274,7 @@ namespace Umbraco.Tests.Components
{
var register = MockRegister();
var factory = MockFactory();
- var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Run));
+ var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Run), Configs);
var types = new[] { typeof(Composer9), typeof(Composer2), typeof(Composer4) };
var composers = new Composers(composition, types, Mock.Of());
@@ -291,7 +293,7 @@ namespace Umbraco.Tests.Components
public void WeakDependencies()
{
var register = MockRegister();
- var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown));
+ var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown), Configs);
var types = new[] { typeof(Composer10) };
var composers = new Composers(composition, types, Mock.Of());
@@ -330,7 +332,7 @@ namespace Umbraco.Tests.Components
public void DisableMissing()
{
var register = MockRegister();
- var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown));
+ var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown), Configs);
var types = new[] { typeof(Composer6), typeof(Composer8) }; // 8 disables 7 which is not in the list
var composers = new Composers(composition, types, Mock.Of());
@@ -345,7 +347,7 @@ namespace Umbraco.Tests.Components
public void AttributesPriorities()
{
var register = MockRegister();
- var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown));
+ var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown), Configs);
var types = new[] { typeof(Composer26) }; // 26 disabled by assembly attribute
var composers = new Composers(composition, types, Mock.Of());
@@ -370,7 +372,7 @@ namespace Umbraco.Tests.Components
var typeLoader = new TypeLoader(ioHelper, typeFinder, AppCaches.Disabled.RuntimeCache, new DirectoryInfo(ioHelper.MapPath("~/App_Data/TEMP")), Mock.Of());
var register = MockRegister();
- var composition = new Composition(register, typeLoader, Mock.Of(), MockRuntimeState(RuntimeLevel.Run));
+ var composition = new Composition(register, typeLoader, Mock.Of(), MockRuntimeState(RuntimeLevel.Run), Configs);
var types = typeLoader.GetTypes().Where(x => x.FullName.StartsWith("Umbraco.Core.") || x.FullName.StartsWith("Umbraco.Web"));
var composers = new Composers(composition, types, Mock.Of());
diff --git a/src/Umbraco.Tests/Composing/CollectionBuildersTests.cs b/src/Umbraco.Tests/Composing/CollectionBuildersTests.cs
index 339bc7a3aa..53b4a9c380 100644
--- a/src/Umbraco.Tests/Composing/CollectionBuildersTests.cs
+++ b/src/Umbraco.Tests/Composing/CollectionBuildersTests.cs
@@ -5,6 +5,7 @@ using Moq;
using NUnit.Framework;
using Umbraco.Core.Composing;
using Umbraco.Core;
+using Umbraco.Core.Configuration;
using Umbraco.Core.Logging;
using Umbraco.Tests.Components;
using Umbraco.Tests.TestHelpers;
@@ -21,8 +22,8 @@ namespace Umbraco.Tests.Composing
{
Current.Reset();
- var register = RegisterFactory.Create();
- _composition = new Composition(register, TestHelper.GetMockedTypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run));
+ var register = TestHelper.GetRegister();
+ _composition = new Composition(register, TestHelper.GetMockedTypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs());
}
[TearDown]
diff --git a/src/Umbraco.Tests/Composing/CompositionTests.cs b/src/Umbraco.Tests/Composing/CompositionTests.cs
index 5516d6cab8..560f79fb24 100644
--- a/src/Umbraco.Tests/Composing/CompositionTests.cs
+++ b/src/Umbraco.Tests/Composing/CompositionTests.cs
@@ -7,6 +7,7 @@ using Umbraco.Core.Cache;
using Umbraco.Core.Composing;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
+using Umbraco.Tests.TestHelpers;
namespace Umbraco.Tests.Composing
{
@@ -40,7 +41,7 @@ namespace Umbraco.Tests.Composing
var typeFinder = new TypeFinder(Mock.Of());
var ioHelper = IOHelper.Default;
var typeLoader = new TypeLoader(ioHelper, typeFinder, Mock.Of(), new DirectoryInfo(ioHelper.MapPath("~/App_Data/TEMP")), logger);
- var composition = new Composition(mockedRegister, typeLoader, logger, Mock.Of());
+ var composition = new Composition(mockedRegister, typeLoader, logger, Mock.Of(), TestHelper.GetConfigs());
// create the factory, ensure it is the mocked factory
var factory = composition.CreateFactory();
diff --git a/src/Umbraco.Tests/Composing/ContainerConformingTests.cs b/src/Umbraco.Tests/Composing/ContainerConformingTests.cs
index f5c1ff9bc7..4ec6dfc0d5 100644
--- a/src/Umbraco.Tests/Composing/ContainerConformingTests.cs
+++ b/src/Umbraco.Tests/Composing/ContainerConformingTests.cs
@@ -4,6 +4,7 @@ using System.Linq;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Composing;
+using Umbraco.Tests.TestHelpers;
namespace Umbraco.Tests.Composing
{
@@ -12,7 +13,7 @@ namespace Umbraco.Tests.Composing
{
// tests that a container conforms
- private IRegister GetRegister() => RegisterFactory.Create();
+ private IRegister GetRegister() => TestHelper.GetRegister();
[Test]
public void CanRegisterAndGet()
diff --git a/src/Umbraco.Tests/Composing/LazyCollectionBuilderTests.cs b/src/Umbraco.Tests/Composing/LazyCollectionBuilderTests.cs
index ed5a6e3ee2..6ba6a4c9b0 100644
--- a/src/Umbraco.Tests/Composing/LazyCollectionBuilderTests.cs
+++ b/src/Umbraco.Tests/Composing/LazyCollectionBuilderTests.cs
@@ -30,7 +30,7 @@ namespace Umbraco.Tests.Composing
private IRegister CreateRegister()
{
- return RegisterFactory.Create();
+ return TestHelper.GetRegister();
}
// note
@@ -41,7 +41,7 @@ namespace Umbraco.Tests.Composing
public void LazyCollectionBuilderHandlesTypes()
{
var container = CreateRegister();
- var composition = new Composition(container, TestHelper.GetMockedTypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run));
+ var composition = new Composition(container, TestHelper.GetMockedTypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs());
composition.WithCollectionBuilder()
.Add()
@@ -67,7 +67,7 @@ namespace Umbraco.Tests.Composing
public void LazyCollectionBuilderHandlesProducers()
{
var container = CreateRegister();
- var composition = new Composition(container, TestHelper.GetMockedTypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run));
+ var composition = new Composition(container, TestHelper.GetMockedTypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs());
composition.WithCollectionBuilder()
.Add(() => new[] { typeof(TransientObject3), typeof(TransientObject2) })
@@ -92,7 +92,7 @@ namespace Umbraco.Tests.Composing
public void LazyCollectionBuilderHandlesTypesAndProducers()
{
var container = CreateRegister();
- var composition = new Composition(container, TestHelper.GetMockedTypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run));
+ var composition = new Composition(container, TestHelper.GetMockedTypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs());
composition.WithCollectionBuilder()
.Add()
@@ -118,7 +118,7 @@ namespace Umbraco.Tests.Composing
public void LazyCollectionBuilderThrowsOnIllegalTypes()
{
var container = CreateRegister();
- var composition = new Composition(container, TestHelper.GetMockedTypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run));
+ var composition = new Composition(container, TestHelper.GetMockedTypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs());
composition.WithCollectionBuilder()
.Add()
@@ -140,7 +140,7 @@ namespace Umbraco.Tests.Composing
public void LazyCollectionBuilderCanExcludeTypes()
{
var container = CreateRegister();
- var composition = new Composition(container, TestHelper.GetMockedTypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run));
+ var composition = new Composition(container, TestHelper.GetMockedTypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs());
composition.WithCollectionBuilder()
.Add()
diff --git a/src/Umbraco.Tests/Composing/PackageActionCollectionTests.cs b/src/Umbraco.Tests/Composing/PackageActionCollectionTests.cs
index 5586f6baa0..d4709ae03a 100644
--- a/src/Umbraco.Tests/Composing/PackageActionCollectionTests.cs
+++ b/src/Umbraco.Tests/Composing/PackageActionCollectionTests.cs
@@ -19,9 +19,9 @@ namespace Umbraco.Tests.Composing
[Test]
public void PackageActionCollectionBuilderWorks()
{
- var container = RegisterFactory.Create();
-
- var composition = new Composition(container, TestHelper.GetMockedTypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run));
+ var container = TestHelper.GetRegister();
+
+ var composition = new Composition(container, TestHelper.GetMockedTypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs());
composition.WithCollectionBuilder()
.Add(() => TypeLoader.GetPackageActions());
diff --git a/src/Umbraco.Tests/Composing/TypeFinderTests.cs b/src/Umbraco.Tests/Composing/TypeFinderTests.cs
index fd070dee2a..5fe4c241d6 100644
--- a/src/Umbraco.Tests/Composing/TypeFinderTests.cs
+++ b/src/Umbraco.Tests/Composing/TypeFinderTests.cs
@@ -75,7 +75,7 @@ namespace Umbraco.Tests.Composing
private static IProfilingLogger GetTestProfilingLogger()
{
- var logger = new DebugDiagnosticsLogger();
+ var logger = new DebugDiagnosticsLogger(new MessageTemplates());
var profiler = new TestProfiler();
return new ProfilingLogger(logger, profiler);
}
diff --git a/src/Umbraco.Tests/Configurations/GlobalSettingsTests.cs b/src/Umbraco.Tests/Configurations/GlobalSettingsTests.cs
index 2b5611deec..65027edc73 100644
--- a/src/Umbraco.Tests/Configurations/GlobalSettingsTests.cs
+++ b/src/Umbraco.Tests/Configurations/GlobalSettingsTests.cs
@@ -26,17 +26,11 @@ namespace Umbraco.Tests.Configurations
Current.IOHelper.Root = _root;
}
- [Test]
- public void Is_Debug_Mode()
- {
- Assert.That(GlobalSettings.DebugMode, Is.EqualTo(true));
- }
-
[Ignore("fixme - ignored test")]
[Test]
public void Is_Version_From_Assembly_Correct()
{
- Assert.That(UmbracoVersion.SemanticVersion, Is.EqualTo("6.0.0"));
+ Assert.That(Current.UmbracoVersion.SemanticVersion, Is.EqualTo("6.0.0"));
}
[TestCase("~/umbraco", "/", "umbraco")]
@@ -52,7 +46,7 @@ namespace Umbraco.Tests.Configurations
globalSettingsMock.Setup(x => x.Path).Returns(() => Current.IOHelper.ResolveUrl(path));
Current.IOHelper.Root = rootPath;
- Assert.AreEqual(outcome, globalSettings.GetUmbracoMvcAreaNoCache());
+ Assert.AreEqual(outcome, globalSettings.GetUmbracoMvcAreaNoCache(IOHelper));
}
diff --git a/src/Umbraco.Tests/Configurations/UmbracoSettings/web.config b/src/Umbraco.Tests/Configurations/UmbracoSettings/web.config
index 3b247ecbff..5ac2d56d14 100644
--- a/src/Umbraco.Tests/Configurations/UmbracoSettings/web.config
+++ b/src/Umbraco.Tests/Configurations/UmbracoSettings/web.config
@@ -1,10 +1,10 @@
-
+
-
-
+
+
@@ -13,4 +13,4 @@
-
\ No newline at end of file
+
diff --git a/src/Umbraco.Tests/IO/FileSystemsTests.cs b/src/Umbraco.Tests/IO/FileSystemsTests.cs
index a7d4bd7c3b..48ed9adbb1 100644
--- a/src/Umbraco.Tests/IO/FileSystemsTests.cs
+++ b/src/Umbraco.Tests/IO/FileSystemsTests.cs
@@ -26,9 +26,9 @@ namespace Umbraco.Tests.IO
[SetUp]
public void Setup()
{
- _register = RegisterFactory.Create();
+ _register = TestHelper.GetRegister();
- var composition = new Composition(_register, TestHelper.GetMockedTypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run));
+ var composition = new Composition(_register, TestHelper.GetMockedTypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs());
composition.Register(_ => Mock.Of());
composition.Register(_ => Mock.Of());
diff --git a/src/Umbraco.Tests/Macros/MacroTests.cs b/src/Umbraco.Tests/Macros/MacroTests.cs
index 0c57c70742..6bf7e808a9 100644
--- a/src/Umbraco.Tests/Macros/MacroTests.cs
+++ b/src/Umbraco.Tests/Macros/MacroTests.cs
@@ -3,6 +3,7 @@ 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.Tests.TestHelpers;
@@ -26,7 +27,7 @@ namespace Umbraco.Tests.Macros
//Current.ApplicationContext = new ApplicationContext(cacheHelper, new ProfilingLogger(Mock.Of(), Mock.Of()));
Current.Reset();
- Current.UnlockConfigs();
+ Current.UnlockConfigs(TestHelper.GetConfigsFactory());
Current.Configs.Add(SettingsForTests.GetDefaultUmbracoSettings);
}
diff --git a/src/Umbraco.Tests/Membership/UmbracoServiceMembershipProviderTests.cs b/src/Umbraco.Tests/Membership/UmbracoServiceMembershipProviderTests.cs
index 1c91d8a920..c70f304d66 100644
--- a/src/Umbraco.Tests/Membership/UmbracoServiceMembershipProviderTests.cs
+++ b/src/Umbraco.Tests/Membership/UmbracoServiceMembershipProviderTests.cs
@@ -23,7 +23,7 @@ namespace Umbraco.Tests.Membership
{
var memberTypeServiceMock = new Mock();
memberTypeServiceMock.Setup(x => x.GetDefault()).Returns("Blah");
- var provider = new MembersMembershipProvider(Mock.Of(), memberTypeServiceMock.Object);
+ var provider = new MembersMembershipProvider(Mock.Of(), memberTypeServiceMock.Object, TestHelper.GetUmbracoVersion());
provider.Initialize("test", new NameValueCollection());
Assert.AreEqual("Blah", provider.DefaultMemberTypeAlias);
@@ -34,7 +34,7 @@ namespace Umbraco.Tests.Membership
{
var memberTypeServiceMock = new Mock();
memberTypeServiceMock.Setup(x => x.GetDefault()).Returns("Blah");
- var provider = new MembersMembershipProvider(Mock.Of(), memberTypeServiceMock.Object);
+ var provider = new MembersMembershipProvider(Mock.Of(), memberTypeServiceMock.Object, TestHelper.GetUmbracoVersion());
provider.Initialize("test", new NameValueCollection { { "defaultMemberTypeAlias", "Hello" } });
Assert.AreEqual("Hello", provider.DefaultMemberTypeAlias);
@@ -48,7 +48,7 @@ namespace Umbraco.Tests.Membership
var membershipServiceMock = new Mock();
membershipServiceMock.Setup(service => service.Exists("test")).Returns(true);
- var provider = new MembersMembershipProvider(membershipServiceMock.Object, memberTypeServiceMock.Object);
+ var provider = new MembersMembershipProvider(membershipServiceMock.Object, memberTypeServiceMock.Object, TestHelper.GetUmbracoVersion());
provider.Initialize("test", new NameValueCollection());
MembershipCreateStatus status;
@@ -65,7 +65,7 @@ namespace Umbraco.Tests.Membership
var membershipServiceMock = new Mock();
membershipServiceMock.Setup(service => service.GetByEmail("test@test.com")).Returns(() => new Member("test", MockedContentTypes.CreateSimpleMemberType()));
- var provider = new MembersMembershipProvider(membershipServiceMock.Object, memberTypeServiceMock.Object);
+ var provider = new MembersMembershipProvider(membershipServiceMock.Object, memberTypeServiceMock.Object, TestHelper.GetUmbracoVersion());
provider.Initialize("test", new NameValueCollection { { "requiresUniqueEmail", "true" } });
MembershipCreateStatus status;
@@ -95,7 +95,7 @@ namespace Umbraco.Tests.Membership
createdMember = new Member("test", e, u, p, memberType, isApproved);
})
.Returns(() => createdMember);
- var provider = new MembersMembershipProvider(membershipServiceMock.Object, memberTypeServiceMock.Object);
+ var provider = new MembersMembershipProvider(membershipServiceMock.Object, memberTypeServiceMock.Object, TestHelper.GetUmbracoVersion());
provider.Initialize("test", new NameValueCollection());
@@ -128,7 +128,7 @@ namespace Umbraco.Tests.Membership
})
.Returns(() => createdMember);
- var provider = new MembersMembershipProvider(membershipServiceMock.Object, memberTypeServiceMock.Object);
+ var provider = new MembersMembershipProvider(membershipServiceMock.Object, memberTypeServiceMock.Object, TestHelper.GetUmbracoVersion());
provider.Initialize("test", new NameValueCollection { { "passwordFormat", "Encrypted" } });
@@ -162,7 +162,7 @@ namespace Umbraco.Tests.Membership
})
.Returns(() => createdMember);
- var provider = new MembersMembershipProvider(membershipServiceMock.Object, memberTypeServiceMock.Object);
+ var provider = new MembersMembershipProvider(membershipServiceMock.Object, memberTypeServiceMock.Object, TestHelper.GetUmbracoVersion());
provider.Initialize("test", new NameValueCollection { { "passwordFormat", "Hashed" }, { "hashAlgorithmType", "HMACSHA256" } });
diff --git a/src/Umbraco.Tests/Migrations/AdvancedMigrationTests.cs b/src/Umbraco.Tests/Migrations/AdvancedMigrationTests.cs
index c13d141fa5..01c93a40ec 100644
--- a/src/Umbraco.Tests/Migrations/AdvancedMigrationTests.cs
+++ b/src/Umbraco.Tests/Migrations/AdvancedMigrationTests.cs
@@ -21,7 +21,7 @@ namespace Umbraco.Tests.Migrations
[Test]
public void CreateTableOfTDto()
{
- var logger = new DebugDiagnosticsLogger();
+ var logger = new DebugDiagnosticsLogger(new MessageTemplates());
var builder = Mock.Of();
Mock.Get(builder)
@@ -53,7 +53,7 @@ namespace Umbraco.Tests.Migrations
[Test]
public void DeleteKeysAndIndexesOfTDto()
{
- var logger = new DebugDiagnosticsLogger();
+ var logger = new DebugDiagnosticsLogger(new MessageTemplates());
var builder = Mock.Of();
Mock.Get(builder)
@@ -87,7 +87,7 @@ namespace Umbraco.Tests.Migrations
[Test]
public void CreateKeysAndIndexesOfTDto()
{
- var logger = new DebugDiagnosticsLogger();
+ var logger = new DebugDiagnosticsLogger(new MessageTemplates());
var builder = Mock.Of();
Mock.Get(builder)
@@ -124,7 +124,7 @@ namespace Umbraco.Tests.Migrations
[Test]
public void CreateKeysAndIndexes()
{
- var logger = new DebugDiagnosticsLogger();
+ var logger = new DebugDiagnosticsLogger(new MessageTemplates());
var builder = Mock.Of();
Mock.Get(builder)
@@ -161,7 +161,7 @@ namespace Umbraco.Tests.Migrations
[Test]
public void CreateColumn()
{
- var logger = new DebugDiagnosticsLogger();
+ var logger = new DebugDiagnosticsLogger(new MessageTemplates());
var builder = Mock.Of();
Mock.Get(builder)
diff --git a/src/Umbraco.Tests/Misc/ApplicationUrlHelperTests.cs b/src/Umbraco.Tests/Misc/ApplicationUrlHelperTests.cs
index 79878a59a1..8283b0b65a 100644
--- a/src/Umbraco.Tests/Misc/ApplicationUrlHelperTests.cs
+++ b/src/Umbraco.Tests/Misc/ApplicationUrlHelperTests.cs
@@ -27,7 +27,7 @@ namespace Umbraco.Tests.Misc
[Test]
public void NoApplicationUrlByDefault()
{
- var state = new RuntimeState(Mock.Of(), Mock.Of(), Mock.Of(), new Lazy(), new Lazy());
+ var state = new RuntimeState(Mock.Of(), Mock.Of(), Mock.Of(), new Lazy(), new Lazy(), TestHelper.GetUmbracoVersion());
Assert.IsNull(state.ApplicationUrl);
}
@@ -45,7 +45,7 @@ namespace Umbraco.Tests.Misc
var registrar = new Mock();
registrar.Setup(x => x.GetCurrentServerUmbracoApplicationUrl()).Returns("http://server1.com/umbraco");
- var state = new RuntimeState(Mock.Of(), settings, globalConfig.Object, new Lazy(), new Lazy(() => registrar.Object));
+ var state = new RuntimeState(Mock.Of(), settings, globalConfig.Object, new Lazy(), new Lazy(() => registrar.Object), TestHelper.GetUmbracoVersion());
state.EnsureApplicationUrl();
@@ -67,7 +67,7 @@ namespace Umbraco.Tests.Misc
- var state = new RuntimeState(Mock.Of(), settings, globalConfig.Object, new Lazy(), new Lazy(() => Mock.Of()));
+ var state = new RuntimeState(Mock.Of(), settings, globalConfig.Object, new Lazy(), new Lazy(() => Mock.Of()), TestHelper.GetUmbracoVersion());
state.EnsureApplicationUrl();
@@ -90,7 +90,7 @@ namespace Umbraco.Tests.Misc
// still NOT set
Assert.IsNull(url);
}
-
+
[Test]
public void SetApplicationUrlFromWrSettingsSsl()
{
diff --git a/src/Umbraco.Tests/Models/ContentTests.cs b/src/Umbraco.Tests/Models/ContentTests.cs
index ee6649dd2b..bdb1a193bc 100644
--- a/src/Umbraco.Tests/Models/ContentTests.cs
+++ b/src/Umbraco.Tests/Models/ContentTests.cs
@@ -238,7 +238,7 @@ namespace Umbraco.Tests.Models
private static IProfilingLogger GetTestProfilingLogger()
{
- var logger = new DebugDiagnosticsLogger();
+ var logger = new DebugDiagnosticsLogger(new MessageTemplates());
var profiler = new TestProfiler();
return new ProfilingLogger(logger, profiler);
}
diff --git a/src/Umbraco.Tests/Models/ContentTypeTests.cs b/src/Umbraco.Tests/Models/ContentTypeTests.cs
index 7d4b1cdcc7..afb9ea1bdf 100644
--- a/src/Umbraco.Tests/Models/ContentTypeTests.cs
+++ b/src/Umbraco.Tests/Models/ContentTypeTests.cs
@@ -130,7 +130,7 @@ namespace Umbraco.Tests.Models
private static IProfilingLogger GetTestProfilingLogger()
{
- var logger = new DebugDiagnosticsLogger();
+ var logger = new DebugDiagnosticsLogger(new MessageTemplates());
var profiler = new TestProfiler();
return new ProfilingLogger(logger, profiler);
}
diff --git a/src/Umbraco.Tests/Models/MacroTests.cs b/src/Umbraco.Tests/Models/MacroTests.cs
index d980cd1d58..e263d99cec 100644
--- a/src/Umbraco.Tests/Models/MacroTests.cs
+++ b/src/Umbraco.Tests/Models/MacroTests.cs
@@ -2,6 +2,7 @@
using System.Linq;
using NUnit.Framework;
using Umbraco.Core.Composing;
+using Umbraco.Core.Configuration;
using Umbraco.Core.Models;
using Umbraco.Core.Models.Entities;
using Umbraco.Tests.TestHelpers;
@@ -15,7 +16,7 @@ namespace Umbraco.Tests.Models
public void Init()
{
Current.Reset();
- Current.UnlockConfigs();
+ Current.UnlockConfigs(TestHelper.GetConfigsFactory());
Current.Configs.Add(SettingsForTests.GetDefaultUmbracoSettings);
}
diff --git a/src/Umbraco.Tests/Models/MemberTests.cs b/src/Umbraco.Tests/Models/MemberTests.cs
index 4680ee67f5..836ce54afa 100644
--- a/src/Umbraco.Tests/Models/MemberTests.cs
+++ b/src/Umbraco.Tests/Models/MemberTests.cs
@@ -4,6 +4,7 @@ using System.Linq;
using Newtonsoft.Json;
using NUnit.Framework;
using Umbraco.Core.Composing;
+using Umbraco.Core.Configuration;
using Umbraco.Core.Models;
using Umbraco.Core.Serialization;
using Umbraco.Tests.TestHelpers;
@@ -18,7 +19,7 @@ namespace Umbraco.Tests.Models
public void Setup()
{
Current.Reset();
- Current.UnlockConfigs();
+ Current.UnlockConfigs(TestHelper.GetConfigsFactory());
Current.Configs.Add(SettingsForTests.GetDefaultGlobalSettings);
Current.Configs.Add(SettingsForTests.GetDefaultUmbracoSettings);
}
diff --git a/src/Umbraco.Tests/Models/UserTests.cs b/src/Umbraco.Tests/Models/UserTests.cs
index 705301b9ed..603cd84a1a 100644
--- a/src/Umbraco.Tests/Models/UserTests.cs
+++ b/src/Umbraco.Tests/Models/UserTests.cs
@@ -4,6 +4,7 @@ using System.Linq;
using Newtonsoft.Json;
using NUnit.Framework;
using Umbraco.Core.Composing;
+using Umbraco.Core.Configuration;
using Umbraco.Core.Models.Membership;
using Umbraco.Core.Serialization;
using Umbraco.Tests.TestHelpers;
@@ -17,7 +18,7 @@ namespace Umbraco.Tests.Models
public void Setup()
{
Current.Reset();
- Current.UnlockConfigs();
+ Current.UnlockConfigs(TestHelper.GetConfigsFactory());
Current.Configs.Add(SettingsForTests.GetDefaultGlobalSettings);
}
diff --git a/src/Umbraco.Tests/Models/VariationTests.cs b/src/Umbraco.Tests/Models/VariationTests.cs
index c7ebb9ef71..c2651a6ff6 100644
--- a/src/Umbraco.Tests/Models/VariationTests.cs
+++ b/src/Umbraco.Tests/Models/VariationTests.cs
@@ -29,7 +29,7 @@ namespace Umbraco.Tests.Models
Current.Reset();
- var configs = new Configs();
+ var configs = TestHelper.GetConfigs();
configs.Add(SettingsForTests.GetDefaultGlobalSettings);
configs.Add(SettingsForTests.GetDefaultUmbracoSettings);
diff --git a/src/Umbraco.Tests/Persistence/DatabaseContextTests.cs b/src/Umbraco.Tests/Persistence/DatabaseContextTests.cs
index fb451b1d5c..7ab9d2e28a 100644
--- a/src/Umbraco.Tests/Persistence/DatabaseContextTests.cs
+++ b/src/Umbraco.Tests/Persistence/DatabaseContextTests.cs
@@ -34,7 +34,7 @@ namespace Umbraco.Tests.Persistence
_sqlCeSyntaxProvider = new SqlCeSyntaxProvider();
_sqlSyntaxProviders = new[] { (ISqlSyntaxProvider) _sqlCeSyntaxProvider };
_logger = Mock.Of();
- _databaseFactory = new UmbracoDatabaseFactory(_logger, new Lazy(() => Mock.Of()));
+ _databaseFactory = new UmbracoDatabaseFactory(_logger, new Lazy(() => Mock.Of()), TestHelper.GetConfigs());
}
[TearDown]
diff --git a/src/Umbraco.Tests/Persistence/NPocoTests/NPocoBulkInsertTests.cs b/src/Umbraco.Tests/Persistence/NPocoTests/NPocoBulkInsertTests.cs
index 2a6c1f4e12..85b07d4828 100644
--- a/src/Umbraco.Tests/Persistence/NPocoTests/NPocoBulkInsertTests.cs
+++ b/src/Umbraco.Tests/Persistence/NPocoTests/NPocoBulkInsertTests.cs
@@ -92,7 +92,7 @@ namespace Umbraco.Tests.Persistence.NPocoTests
// create the db
// prob not what we want, this is not a real database, but hey, the test is ignored anyways
// we'll fix this when we have proper testing infrastructure
- var dbSqlServer = TestObjects.GetUmbracoSqlServerDatabase(new DebugDiagnosticsLogger());
+ var dbSqlServer = TestObjects.GetUmbracoSqlServerDatabase(new DebugDiagnosticsLogger(new MessageTemplates()));
//drop the table
dbSqlServer.Execute("DROP TABLE [umbracoServer]");
diff --git a/src/Umbraco.Tests/Persistence/Repositories/ScriptRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/ScriptRepositoryTest.cs
index 1c82287842..997b275655 100644
--- a/src/Umbraco.Tests/Persistence/Repositories/ScriptRepositoryTest.cs
+++ b/src/Umbraco.Tests/Persistence/Repositories/ScriptRepositoryTest.cs
@@ -29,7 +29,7 @@ namespace Umbraco.Tests.Persistence.Repositories
base.SetUp();
_fileSystems = Mock.Of();
- _fileSystem = new PhysicalFileSystem(new GlobalSettings().UmbracoScriptsPath);
+ _fileSystem = new PhysicalFileSystem(SettingsForTests.GenerateMockGlobalSettings().UmbracoScriptsPath);
Mock.Get(_fileSystems).Setup(x => x.ScriptsFileSystem).Returns(_fileSystem);
using (var stream = CreateStream("Umbraco.Sys.registerNamespace(\"Umbraco.Utils\");"))
{
diff --git a/src/Umbraco.Tests/Persistence/Repositories/StylesheetRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/StylesheetRepositoryTest.cs
index ef28b42f05..a1f0662ebd 100644
--- a/src/Umbraco.Tests/Persistence/Repositories/StylesheetRepositoryTest.cs
+++ b/src/Umbraco.Tests/Persistence/Repositories/StylesheetRepositoryTest.cs
@@ -28,7 +28,7 @@ namespace Umbraco.Tests.Persistence.Repositories
base.SetUp();
_fileSystems = Mock.Of();
- _fileSystem = new PhysicalFileSystem(new GlobalSettings().UmbracoCssPath);
+ _fileSystem = new PhysicalFileSystem(SettingsForTests.GenerateMockGlobalSettings().UmbracoCssPath);
Mock.Get(_fileSystems).Setup(x => x.StylesheetsFileSystem).Returns(_fileSystem);
var stream = CreateStream("body {background:#EE7600; color:#FFF;}");
_fileSystem.AddFile("styles.css", stream);
diff --git a/src/Umbraco.Tests/PropertyEditors/ImageCropperTest.cs b/src/Umbraco.Tests/PropertyEditors/ImageCropperTest.cs
index 885aaeefb9..e492e881c0 100644
--- a/src/Umbraco.Tests/PropertyEditors/ImageCropperTest.cs
+++ b/src/Umbraco.Tests/PropertyEditors/ImageCropperTest.cs
@@ -69,8 +69,8 @@ namespace Umbraco.Tests.PropertyEditors
{
try
{
- var container = RegisterFactory.Create();
- var composition = new Composition(container, TestHelper.GetMockedTypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run));
+ var container = TestHelper.GetRegister();
+ var composition = new Composition(container, TestHelper.GetMockedTypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs());
composition.WithCollectionBuilder();
diff --git a/src/Umbraco.Tests/PropertyEditors/PropertyEditorValueEditorTests.cs b/src/Umbraco.Tests/PropertyEditors/PropertyEditorValueEditorTests.cs
index bb1b0e4b10..b3ec8dd08b 100644
--- a/src/Umbraco.Tests/PropertyEditors/PropertyEditorValueEditorTests.cs
+++ b/src/Umbraco.Tests/PropertyEditors/PropertyEditorValueEditorTests.cs
@@ -23,8 +23,8 @@ namespace Umbraco.Tests.PropertyEditors
//normalize culture
Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;
- var register = RegisterFactory.Create();
- var composition = new Composition(register, TestHelper.GetMockedTypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run));
+ var register = TestHelper.GetRegister();
+ var composition = new Composition(register, TestHelper.GetMockedTypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs());
register.Register(_
=> new DefaultShortStringHelper(new DefaultShortStringHelperConfig().WithDefault(SettingsForTests.GetDefaultUmbracoSettings())));
diff --git a/src/Umbraco.Tests/Published/ConvertersTests.cs b/src/Umbraco.Tests/Published/ConvertersTests.cs
index 360df5daeb..f1042519f5 100644
--- a/src/Umbraco.Tests/Published/ConvertersTests.cs
+++ b/src/Umbraco.Tests/Published/ConvertersTests.cs
@@ -176,9 +176,9 @@ namespace Umbraco.Tests.Published
public void SimpleConverter3Test()
{
Current.Reset();
- var register = RegisterFactory.Create();
+ var register = TestHelper.GetRegister();
- var composition = new Composition(register, TestHelper.GetMockedTypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run));
+ var composition = new Composition(register, TestHelper.GetMockedTypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs());
composition.WithCollectionBuilder()
.Append()
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]
diff --git a/src/Umbraco.Tests/PublishedContent/NuCacheChildrenTests.cs b/src/Umbraco.Tests/PublishedContent/NuCacheChildrenTests.cs
index 564e129650..31cfcb7dc8 100644
--- a/src/Umbraco.Tests/PublishedContent/NuCacheChildrenTests.cs
+++ b/src/Umbraco.Tests/PublishedContent/NuCacheChildrenTests.cs
@@ -10,6 +10,7 @@ using Umbraco.Core;
using Umbraco.Core.Composing;
using Umbraco.Core.Configuration;
using Umbraco.Core.Events;
+using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
using Umbraco.Core.Models.PublishedContent;
@@ -54,9 +55,9 @@ namespace Umbraco.Tests.PublishedContent
var factory = Mock.Of();
Current.Factory = factory;
- var configs = new Configs();
+ var configs = TestHelper.GetConfigs();
Mock.Get(factory).Setup(x => x.GetInstance(typeof(Configs))).Returns(configs);
- var globalSettings = new GlobalSettings();
+ var globalSettings = new GlobalSettings(IOHelper.Default);
configs.Add(SettingsForTests.GenerateMockUmbracoSettings);
configs.Add(() => globalSettings);
@@ -1117,7 +1118,7 @@ namespace Umbraco.Tests.PublishedContent
_snapshotService.Notify(new[]
{
- new ContentCacheRefresher.JsonPayload(1, Guid.Empty, TreeChangeTypes.RefreshNode)
+ new ContentCacheRefresher.JsonPayload(1, Guid.Empty, TreeChangeTypes.RefreshNode)
}, out _, out _);
Assert.AreEqual(2, contentStore.Test.LiveGen);
@@ -1137,7 +1138,7 @@ namespace Umbraco.Tests.PublishedContent
/// 2) Save and publish it
/// 3) Publish it with descendants
/// 4) Repeat steps 2 and 3
- ///
+ ///
/// Which has caused an exception. To replicate this test:
/// 1) RefreshBranch with kits for a branch where the top most node is unpublished
/// 2) RefreshBranch with kits for the branch where the top most node is published
@@ -1165,7 +1166,7 @@ namespace Umbraco.Tests.PublishedContent
//children of 1
yield return CreateInvariantKit(20, 1, 1, paths);
- yield return CreateInvariantKit(30, 1, 2, paths);
+ yield return CreateInvariantKit(30, 1, 2, paths);
yield return CreateInvariantKit(40, 1, 3, paths);
}
@@ -1202,12 +1203,12 @@ namespace Umbraco.Tests.PublishedContent
var (gen, contentNode) = contentStore.Test.GetValues(1)[0];
Assert.AreEqual(assertGen, gen);
//even when unpublishing/re-publishing/etc... the linked list is always maintained
- AssertLinkedNode(contentNode, 100, 2, 3, 20, 40);
+ AssertLinkedNode(contentNode, 100, 2, 3, 20, 40);
}
//unpublish the root
ChangePublishFlagOfRoot(false, 2, TreeChangeTypes.RefreshBranch);
-
+
//publish the root (since it's not published, it will cause a RefreshBranch)
ChangePublishFlagOfRoot(true, 3, TreeChangeTypes.RefreshBranch);
diff --git a/src/Umbraco.Tests/PublishedContent/NuCacheTests.cs b/src/Umbraco.Tests/PublishedContent/NuCacheTests.cs
index d3a4a0d082..25ff5e233b 100644
--- a/src/Umbraco.Tests/PublishedContent/NuCacheTests.cs
+++ b/src/Umbraco.Tests/PublishedContent/NuCacheTests.cs
@@ -8,6 +8,7 @@ using Umbraco.Core;
using Umbraco.Core.Composing;
using Umbraco.Core.Configuration;
using Umbraco.Core.Events;
+using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
using Umbraco.Core.Models.PublishedContent;
@@ -49,9 +50,9 @@ namespace Umbraco.Tests.PublishedContent
var factory = Mock.Of();
Current.Factory = factory;
- var configs = new Configs();
+ var configs = TestHelper.GetConfigs();
Mock.Get(factory).Setup(x => x.GetInstance(typeof(Configs))).Returns(configs);
- var globalSettings = new GlobalSettings();
+ var globalSettings = new GlobalSettings(IOHelper.Default);
configs.Add(SettingsForTests.GenerateMockUmbracoSettings);
configs.Add(() => globalSettings);
diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentSnapshotTestBase.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentSnapshotTestBase.cs
index d0e780a92b..882db8112c 100644
--- a/src/Umbraco.Tests/PublishedContent/PublishedContentSnapshotTestBase.cs
+++ b/src/Umbraco.Tests/PublishedContent/PublishedContentSnapshotTestBase.cs
@@ -48,7 +48,7 @@ namespace Umbraco.Tests.PublishedContent
{
var baseLoader = base.CreateTypeLoader(ioHelper, typeFinder, runtimeCache, globalSettings, logger);
- return new TypeLoader(ioHelper, typeFinder, runtimeCache, new DirectoryInfo(globalSettings.LocalTempPath), logger, false,
+ return new TypeLoader(ioHelper, typeFinder, runtimeCache, new DirectoryInfo(globalSettings.LocalTempPath(ioHelper)), logger, false,
// this is so the model factory looks into the test assembly
baseLoader.AssembliesToScan
.Union(new[] {typeof(PublishedContentMoreTests).Assembly})
diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs
index 7c70e82047..de4dd45f64 100644
--- a/src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs
+++ b/src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs
@@ -91,7 +91,7 @@ namespace Umbraco.Tests.PublishedContent
{
var baseLoader = base.CreateTypeLoader(ioHelper, typeFinder, runtimeCache, globalSettings, logger);
- return new TypeLoader(ioHelper, typeFinder, runtimeCache, new DirectoryInfo(globalSettings.LocalTempPath), logger, false,
+ return new TypeLoader(ioHelper, typeFinder, runtimeCache, new DirectoryInfo(globalSettings.LocalTempPath(ioHelper)), logger, false,
// this is so the model factory looks into the test assembly
baseLoader.AssembliesToScan
.Union(new[] { typeof(PublishedContentTests).Assembly })
diff --git a/src/Umbraco.Tests/Routing/RenderRouteHandlerTests.cs b/src/Umbraco.Tests/Routing/RenderRouteHandlerTests.cs
index ac402ad77d..cfc42d3670 100644
--- a/src/Umbraco.Tests/Routing/RenderRouteHandlerTests.cs
+++ b/src/Umbraco.Tests/Routing/RenderRouteHandlerTests.cs
@@ -19,6 +19,7 @@ using Umbraco.Core.Strings;
using Umbraco.Core.Composing;
using Umbraco.Core.Configuration;
using Umbraco.Core.Dictionary;
+using Umbraco.Core.IO;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Core.Persistence;
using Umbraco.Core.Services;
@@ -49,11 +50,11 @@ namespace Umbraco.Tests.Routing
public class TestRuntime : WebRuntime
{
- public TestRuntime(UmbracoApplicationBase umbracoApplication)
- : base(umbracoApplication)
- { }
+ public TestRuntime(UmbracoApplicationBase umbracoApplication, Configs configs, IUmbracoVersion umbracoVersion, IIOHelper ioHelper, ILogger logger)
+ : base(umbracoApplication, configs, umbracoVersion, ioHelper, Mock.Of())
+ {
+ }
- protected override ILogger GetLogger() => Mock.Of();
protected override IProfiler GetProfiler() => Mock.Of();
}
diff --git a/src/Umbraco.Tests/Routing/UmbracoModuleTests.cs b/src/Umbraco.Tests/Routing/UmbracoModuleTests.cs
index e95fdfc87c..aed4dba493 100644
--- a/src/Umbraco.Tests/Routing/UmbracoModuleTests.cs
+++ b/src/Umbraco.Tests/Routing/UmbracoModuleTests.cs
@@ -32,8 +32,9 @@ namespace Umbraco.Tests.Routing
//create the module
var logger = Mock.Of();
var globalSettings = TestObjects.GetGlobalSettings();
+ var umbracoVersion = TestHelper.GetUmbracoVersion();
var runtime = new RuntimeState(logger, Mock.Of(), globalSettings,
- new Lazy(), new Lazy());
+ new Lazy(), new Lazy(), umbracoVersion);
_module = new UmbracoInjectedModule
(
@@ -62,7 +63,7 @@ namespace Umbraco.Tests.Routing
// do not test for /base here as it's handled before EnsureUmbracoRoutablePage is called
[TestCase("/umbraco_client/Tree/treeIcons.css", false)]
- [TestCase("/umbraco_client/Tree/Themes/umbraco/style.css?cdv=37", false)]
+ [TestCase("/umbraco_client/Tree/Themes/umbraco/style.css?cdv=37", false)]
[TestCase("/umbraco/editContent.aspx", false)]
[TestCase("/install/default.aspx", false)]
[TestCase("/install/?installStep=license", false)]
diff --git a/src/Umbraco.Tests/Runtimes/CoreRuntimeTests.cs b/src/Umbraco.Tests/Runtimes/CoreRuntimeTests.cs
index 5850153100..93c931c93d 100644
--- a/src/Umbraco.Tests/Runtimes/CoreRuntimeTests.cs
+++ b/src/Umbraco.Tests/Runtimes/CoreRuntimeTests.cs
@@ -4,6 +4,7 @@ using System.Data;
using System.Web.Hosting;
using Examine;
using Moq;
+using NPoco.Expressions;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Compose;
@@ -11,6 +12,7 @@ using Umbraco.Core.Composing;
using Umbraco.Core.Configuration;
using Umbraco.Core.Events;
using Umbraco.Core.Exceptions;
+using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.Persistence;
using Umbraco.Core.Runtime;
@@ -78,18 +80,34 @@ namespace Umbraco.Tests.Runtimes
// test application
public class TestUmbracoApplication : UmbracoApplicationBase
{
+ public TestUmbracoApplication() : base(new DebugDiagnosticsLogger(new MessageTemplates()), GetConfigs())
+ {
+ }
+
+ private static Configs GetConfigs()
+ {
+ var configs = new ConfigsFactory(IOHelper.Default).Create();
+ configs.Add(SettingsForTests.GetDefaultGlobalSettings);
+ configs.Add(SettingsForTests.GetDefaultUmbracoSettings);
+ return configs;
+ }
+
public IRuntime Runtime { get; private set; }
- protected override IRuntime GetRuntime()
+ protected override IRuntime GetRuntime(Configs configs, IUmbracoVersion umbracoVersion, IIOHelper ioHelper, ILogger logger)
{
- return Runtime = new TestRuntime();
+ return Runtime = new TestRuntime(configs, umbracoVersion, ioHelper, logger);
}
}
// test runtime
public class TestRuntime : CoreRuntime
{
- protected override ILogger GetLogger() => new DebugDiagnosticsLogger();
+ public TestRuntime(Configs configs, IUmbracoVersion umbracoVersion, IIOHelper ioHelper, ILogger logger)
+ :base(configs, umbracoVersion, ioHelper, logger)
+ {
+
+ }
protected override IProfiler GetProfiler() => new TestProfiler();
// must override the database factory
@@ -102,14 +120,6 @@ namespace Umbraco.Tests.Runtimes
return mock.Object;
}
- protected override Configs GetConfigs()
- {
- var configs = new Configs();
- configs.Add(SettingsForTests.GetDefaultGlobalSettings);
- configs.Add(SettingsForTests.GetDefaultUmbracoSettings);
- return configs;
- }
-
// FIXME: so how the f* should we do it now?
/*
// pretend we have the proper migration
diff --git a/src/Umbraco.Tests/Runtimes/StandaloneTests.cs b/src/Umbraco.Tests/Runtimes/StandaloneTests.cs
index 7ff2e6e7b8..119211225a 100644
--- a/src/Umbraco.Tests/Runtimes/StandaloneTests.cs
+++ b/src/Umbraco.Tests/Runtimes/StandaloneTests.cs
@@ -56,25 +56,26 @@ namespace Umbraco.Tests.Runtimes
// FIXME: we need a better management of settings here (and, true config files?)
// create the very basic and essential things we need
- var logger = new ConsoleLogger();
+ var logger = new ConsoleLogger(new MessageTemplates());
var profiler = new LogProfiler(logger);
var profilingLogger = new ProfilingLogger(logger, profiler);
var appCaches = AppCaches.Disabled;
- var databaseFactory = new UmbracoDatabaseFactory(logger, new Lazy(() => factory.GetInstance()));
+ var databaseFactory = new UmbracoDatabaseFactory(logger, new Lazy(() => factory.GetInstance()), TestHelper.GetConfigs());
var typeFinder = new TypeFinder(logger);
var ioHelper = IOHelper.Default;
var typeLoader = new TypeLoader(ioHelper, typeFinder, appCaches.RuntimeCache, new DirectoryInfo(ioHelper.MapPath("~/App_Data/TEMP")), profilingLogger);
var mainDom = new SimpleMainDom();
- var runtimeState = new RuntimeState(logger, null, null, new Lazy(() => mainDom), new Lazy(() => factory.GetInstance()));
+ var umbracoVersion = TestHelper.GetUmbracoVersion();
+ var runtimeState = new RuntimeState(logger, null, null, new Lazy(() => mainDom), new Lazy(() => factory.GetInstance()), umbracoVersion);
+ var configs = TestHelper.GetConfigs();
// create the register and the composition
- var register = RegisterFactory.Create();
- var composition = new Composition(register, typeLoader, profilingLogger, runtimeState);
- composition.RegisterEssentials(logger, profiler, profilingLogger, mainDom, appCaches, databaseFactory, typeLoader, runtimeState, typeFinder, ioHelper);
+ var register = TestHelper.GetRegister();
+ var composition = new Composition(register, typeLoader, profilingLogger, runtimeState, configs);
+ composition.RegisterEssentials(logger, profiler, profilingLogger, mainDom, appCaches, databaseFactory, typeLoader, runtimeState, typeFinder, ioHelper, umbracoVersion);
// create the core runtime and have it compose itself
- var coreRuntime = new CoreRuntime();
- coreRuntime.Compose(composition);
+ var coreRuntime = new CoreRuntime(configs, umbracoVersion, ioHelper, logger);coreRuntime.Compose(composition);
// determine actual runtime level
runtimeState.DetermineRuntimeLevel(databaseFactory, logger);
@@ -246,7 +247,7 @@ namespace Umbraco.Tests.Runtimes
// - assigning the factory to Current.Factory
// create the very basic and essential things we need
- var logger = new ConsoleLogger();
+ var logger = new ConsoleLogger(new MessageTemplates());
var profiler = Mock.Of();
var profilingLogger = new ProfilingLogger(logger, profiler);
var appCaches = AppCaches.Disabled;
@@ -258,14 +259,16 @@ namespace Umbraco.Tests.Runtimes
Mock.Get(runtimeState).Setup(x => x.Level).Returns(RuntimeLevel.Run);
var mainDom = Mock.Of();
Mock.Get(mainDom).Setup(x => x.IsMainDom).Returns(true);
+ var configs = TestHelper.GetConfigs();
// create the register and the composition
- var register = RegisterFactory.Create();
- var composition = new Composition(register, typeLoader, profilingLogger, runtimeState);
- composition.RegisterEssentials(logger, profiler, profilingLogger, mainDom, appCaches, databaseFactory, typeLoader, runtimeState, typeFinder, ioHelper);
+ var register = TestHelper.GetRegister();
+ var composition = new Composition(register, typeLoader, profilingLogger, runtimeState, configs);
+ var umbracoVersion = TestHelper.GetUmbracoVersion();
+ composition.RegisterEssentials(logger, profiler, profilingLogger, mainDom, appCaches, databaseFactory, typeLoader, runtimeState, typeFinder, ioHelper, umbracoVersion);
// create the core runtime and have it compose itself
- var coreRuntime = new CoreRuntime();
+ var coreRuntime = new CoreRuntime(configs, umbracoVersion, ioHelper, logger);
coreRuntime.Compose(composition);
// get the components
diff --git a/src/Umbraco.Tests/Scheduling/BackgroundTaskRunnerTests.cs b/src/Umbraco.Tests/Scheduling/BackgroundTaskRunnerTests.cs
index 3664717af7..27abca7cbd 100644
--- a/src/Umbraco.Tests/Scheduling/BackgroundTaskRunnerTests.cs
+++ b/src/Umbraco.Tests/Scheduling/BackgroundTaskRunnerTests.cs
@@ -21,7 +21,7 @@ namespace Umbraco.Tests.Scheduling
[OneTimeSetUp]
public void InitializeFixture()
{
- _logger = new DebugDiagnosticsLogger();
+ _logger = new DebugDiagnosticsLogger(new MessageTemplates());
}
[Test]
diff --git a/src/Umbraco.Tests/Scheduling/BackgroundTaskRunnerTests2.cs b/src/Umbraco.Tests/Scheduling/BackgroundTaskRunnerTests2.cs
index 8e886d7dc9..6a65f3afbc 100644
--- a/src/Umbraco.Tests/Scheduling/BackgroundTaskRunnerTests2.cs
+++ b/src/Umbraco.Tests/Scheduling/BackgroundTaskRunnerTests2.cs
@@ -21,7 +21,7 @@ namespace Umbraco.Tests.Scheduling
[Timeout(4000)]
public async Task ThreadResumeIssue()
{
- var logger = new DebugDiagnosticsLogger();
+ var logger = new DebugDiagnosticsLogger(new MessageTemplates());
var runner = new BackgroundTaskRunner(new BackgroundTaskRunnerOptions { KeepAlive = true, LongRunning = true }, logger);
var work = new ThreadResumeIssueWorkItem();
runner.Add(work);
@@ -76,7 +76,7 @@ namespace Umbraco.Tests.Scheduling
[Ignore("Only runs in the debugger.")]
public async Task DebuggerInterferenceIssue()
{
- var logger = new DebugDiagnosticsLogger();
+ var logger = new DebugDiagnosticsLogger(new MessageTemplates());
var runner = new BackgroundTaskRunner(new BackgroundTaskRunnerOptions { KeepAlive = true, LongRunning = true }, logger);
var taskCompleted = false;
runner.TaskCompleted += (sender, args) =>
diff --git a/src/Umbraco.Tests/Scoping/ScopeEventDispatcherTests.cs b/src/Umbraco.Tests/Scoping/ScopeEventDispatcherTests.cs
index 44984047f1..708f0d29db 100644
--- a/src/Umbraco.Tests/Scoping/ScopeEventDispatcherTests.cs
+++ b/src/Umbraco.Tests/Scoping/ScopeEventDispatcherTests.cs
@@ -30,9 +30,9 @@ namespace Umbraco.Tests.Scoping
DoThing2 = null;
DoThing3 = null;
- var register = RegisterFactory.Create();
+ var register = TestHelper.GetRegister();
- var composition = new Composition(register, TestHelper.GetMockedTypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run));
+ var composition = new Composition(register, TestHelper.GetMockedTypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs());
_testObjects = new TestObjects(register);
diff --git a/src/Umbraco.Tests/Services/ContentServicePerformanceTest.cs b/src/Umbraco.Tests/Services/ContentServicePerformanceTest.cs
index ef80672baf..ace45fe356 100644
--- a/src/Umbraco.Tests/Services/ContentServicePerformanceTest.cs
+++ b/src/Umbraco.Tests/Services/ContentServicePerformanceTest.cs
@@ -47,7 +47,7 @@ namespace Umbraco.Tests.Services
private static IProfilingLogger GetTestProfilingLogger()
{
- var logger = new DebugDiagnosticsLogger();
+ var logger = new DebugDiagnosticsLogger(new MessageTemplates());
var profiler = new TestProfiler();
return new ProfilingLogger(logger, profiler);
}
@@ -268,7 +268,7 @@ namespace Umbraco.Tests.Services
var tagRepo = new TagRepository((IScopeAccessor) provider, AppCaches.Disabled, Logger);
var commonRepository = new ContentTypeCommonRepository((IScopeAccessor)provider, tRepository, AppCaches);
var languageRepository = new LanguageRepository((IScopeAccessor)provider, AppCaches.Disabled, Logger);
- var ctRepository = new ContentTypeRepository((IScopeAccessor) provider, AppCaches.Disabled, Logger, commonRepository, languageRepository);
+ var ctRepository = new ContentTypeRepository((IScopeAccessor) provider, AppCaches.Disabled, Logger, commonRepository, languageRepository);
var repository = new DocumentRepository((IScopeAccessor) provider, AppCaches.Disabled, Logger, ctRepository, tRepository, tagRepo, languageRepository);
// Act
diff --git a/src/Umbraco.Tests/Services/MemberServiceTests.cs b/src/Umbraco.Tests/Services/MemberServiceTests.cs
index 57d6b67af8..7bcd3790d4 100644
--- a/src/Umbraco.Tests/Services/MemberServiceTests.cs
+++ b/src/Umbraco.Tests/Services/MemberServiceTests.cs
@@ -20,6 +20,7 @@ using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Services;
using Umbraco.Core.Services.Implement;
using Umbraco.Tests.LegacyXmlPublishedCache;
+using Umbraco.Tests.TestHelpers;
using Umbraco.Tests.TestHelpers.Entities;
using Umbraco.Tests.Testing;
using Umbraco.Tests.Testing.Objects.Accessors;
@@ -40,7 +41,7 @@ namespace Umbraco.Tests.Services
base.SetUp();
// HACK: but we have no choice until we remove the SavePassword method from IMemberService
- var providerMock = new Mock(ServiceContext.MemberService, ServiceContext.MemberTypeService) { CallBase = true };
+ var providerMock = new Mock(ServiceContext.MemberService, ServiceContext.MemberTypeService, TestHelper.GetUmbracoVersion()) { CallBase = true };
providerMock.Setup(@base => @base.AllowManuallyChangingPassword).Returns(false);
providerMock.Setup(@base => @base.PasswordFormat).Returns(MembershipPasswordFormat.Hashed);
var provider = providerMock.Object;
diff --git a/src/Umbraco.Tests/Services/PerformanceTests.cs b/src/Umbraco.Tests/Services/PerformanceTests.cs
index 9cf38e1789..0ac6eeb863 100644
--- a/src/Umbraco.Tests/Services/PerformanceTests.cs
+++ b/src/Umbraco.Tests/Services/PerformanceTests.cs
@@ -60,7 +60,7 @@ namespace Umbraco.Tests.Services
private static IProfilingLogger GetTestProfilingLogger()
{
- var logger = new DebugDiagnosticsLogger();
+ var logger = new DebugDiagnosticsLogger(new MessageTemplates());
var profiler = new TestProfiler();
return new ProfilingLogger(logger, profiler);
}
diff --git a/src/Umbraco.Tests/TestHelpers/BaseUsingSqlCeSyntax.cs b/src/Umbraco.Tests/TestHelpers/BaseUsingSqlCeSyntax.cs
index e1e987c4bf..140759c3bd 100644
--- a/src/Umbraco.Tests/TestHelpers/BaseUsingSqlCeSyntax.cs
+++ b/src/Umbraco.Tests/TestHelpers/BaseUsingSqlCeSyntax.cs
@@ -35,7 +35,7 @@ namespace Umbraco.Tests.TestHelpers
{
Current.Reset();
- var container = RegisterFactory.Create();
+ var container = TestHelper.GetRegister();
var ioHelper = IOHelper.Default;
var logger = new ProfilingLogger(Mock.Of(), Mock.Of());
@@ -45,7 +45,7 @@ namespace Umbraco.Tests.TestHelpers
logger,
false);
- var composition = new Composition(container, typeLoader, Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run));
+ var composition = new Composition(container, typeLoader, Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs());
composition.RegisterUnique