Merge pull request #7276 from umbraco/netcore/feature/iohelper-cannot-use-system-web
Netcore: IOHelper cannot use System.Web
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Logging;
|
||||
|
||||
namespace Umbraco.Core.Composing
|
||||
@@ -19,6 +21,7 @@ namespace Umbraco.Core.Composing
|
||||
private readonly Dictionary<string, Action<IRegister>> _uniques = new Dictionary<string, Action<IRegister>>();
|
||||
private readonly IRegister _register;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Composition"/> class.
|
||||
/// </summary>
|
||||
@@ -27,13 +30,16 @@ namespace Umbraco.Core.Composing
|
||||
/// <param name="logger">A logger.</param>
|
||||
/// <param name="runtimeState">The runtime state.</param>
|
||||
/// <param name="configs">Optional configs.</param>
|
||||
public Composition(IRegister register, TypeLoader typeLoader, IProfilingLogger logger, IRuntimeState runtimeState, Configs configs)
|
||||
/// <param name="ioHelper">An IOHelper</param>
|
||||
public Composition(IRegister register, TypeLoader typeLoader, IProfilingLogger logger, IRuntimeState runtimeState, Configs configs, IIOHelper ioHelper, AppCaches appCaches)
|
||||
{
|
||||
_register = register;
|
||||
TypeLoader = typeLoader;
|
||||
Logger = logger;
|
||||
RuntimeState = runtimeState;
|
||||
Configs = configs;
|
||||
IOHelper = ioHelper;
|
||||
AppCaches = appCaches;
|
||||
}
|
||||
|
||||
#region Services
|
||||
@@ -43,6 +49,9 @@ namespace Umbraco.Core.Composing
|
||||
/// </summary>
|
||||
public IProfilingLogger Logger { get; }
|
||||
|
||||
public IIOHelper IOHelper { get; }
|
||||
public AppCaches AppCaches { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the type loader.
|
||||
/// </summary>
|
||||
|
||||
@@ -19,6 +19,9 @@ namespace Umbraco.Core
|
||||
public static IGlobalSettings Global(this Configs configs)
|
||||
=> configs.GetConfig<IGlobalSettings>();
|
||||
|
||||
public static IHostingSettings Hosting(this Configs configs)
|
||||
=> configs.GetConfig<IHostingSettings>();
|
||||
|
||||
public static IConnectionStrings ConnectionStrings(this Configs configs)
|
||||
=> configs.GetConfig<IConnectionStrings>();
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using Umbraco.Core.IO;
|
||||
|
||||
namespace Umbraco.Core.Configuration
|
||||
{
|
||||
public interface IConfigsFactory
|
||||
{
|
||||
Configs Create();
|
||||
Configs Create(IIOHelper ioHelper);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
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.
|
||||
// our config classes should be named according to what they are configuring.
|
||||
|
||||
/// <summary>
|
||||
/// Gets the reserved urls from web.config.
|
||||
@@ -61,16 +61,10 @@
|
||||
/// <value>The version check period in days (0 = never).</value>
|
||||
int VersionCheckPeriod { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the configuration for the location of temporary files.
|
||||
/// </summary>
|
||||
LocalTempStorage LocalTempStorageLocation { get; }
|
||||
|
||||
string UmbracoPath { get; }
|
||||
string UmbracoCssPath { get; }
|
||||
string UmbracoScriptsPath { get; }
|
||||
string UmbracoMediaPath { get; }
|
||||
bool DebugMode { get; }
|
||||
|
||||
bool IsSmtpServerConfigured { get; }
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace Umbraco.Core.Configuration
|
||||
{
|
||||
public interface IHostingSettings
|
||||
{
|
||||
bool DebugMode { get; }
|
||||
/// <summary>
|
||||
/// Gets the configuration for the location of temporary files.
|
||||
/// </summary>
|
||||
LocalTempStorage LocalTempStorageLocation { get; }
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,16 @@ namespace Umbraco.Core.Hosting
|
||||
string ApplicationVirtualPath { get; }
|
||||
|
||||
bool IsDebugMode { get; }
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether Umbraco is hosted.
|
||||
/// </summary>
|
||||
bool IsHosted { get; }
|
||||
string MapPath(string path);
|
||||
string ToAbsolute(string virtualPath, string root);
|
||||
|
||||
/// <summary>
|
||||
/// Terminates the current application. The application restarts the next time a request is received for it.
|
||||
/// </summary>
|
||||
void LazyRestartApplication();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,17 +6,11 @@ namespace Umbraco.Core.IO
|
||||
{
|
||||
bool ForceNotHosted { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether Umbraco is hosted.
|
||||
/// </summary>
|
||||
bool IsHosted { get; }
|
||||
|
||||
char DirSepChar { get; }
|
||||
string FindFile(string virtualPath);
|
||||
string ResolveVirtualUrl(string path);
|
||||
string ResolveUrl(string virtualPath);
|
||||
Attempt<string> TryResolveUrl(string virtualPath);
|
||||
string MapPath(string path, bool useHttpContext);
|
||||
string MapPath(string path);
|
||||
|
||||
|
||||
@@ -64,13 +58,6 @@ namespace Umbraco.Core.IO
|
||||
/// <param name="rootPath"></param>
|
||||
void SetRootDirectory(string rootPath);
|
||||
|
||||
/// <summary>
|
||||
/// Check to see if filename passed has any special chars in it and strips them to create a safe filename. Used to overcome an issue when Umbraco is used in IE in an intranet environment.
|
||||
/// </summary>
|
||||
/// <param name="filePath">The filename passed to the file handler from the upload field.</param>
|
||||
/// <returns>A safe filename without any path specific chars.</returns>
|
||||
string SafeFileName(string filePath);
|
||||
|
||||
void EnsurePathExists(string path);
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -4,13 +4,20 @@ using System.Globalization;
|
||||
using System.Reflection;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Hosting;
|
||||
using Umbraco.Core.Hosting;
|
||||
using Umbraco.Core.Strings;
|
||||
|
||||
namespace Umbraco.Core.IO
|
||||
{
|
||||
public class IOHelper : IIOHelper
|
||||
{
|
||||
private readonly IHostingEnvironment _hostingEnvironment;
|
||||
|
||||
public IOHelper(IHostingEnvironment hostingEnvironment)
|
||||
{
|
||||
_hostingEnvironment = hostingEnvironment;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value forcing Umbraco to consider it is non-hosted.
|
||||
/// </summary>
|
||||
@@ -22,10 +29,6 @@ namespace Umbraco.Core.IO
|
||||
// static compiled regex for faster performance
|
||||
//private static readonly Regex ResolveUrlPattern = new Regex("(=[\"\']?)(\\W?\\~(?:.(?![\"\']?\\s+(?:\\S+)=|[>\"\']))+.)[\"\']?", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether Umbraco is hosted.
|
||||
/// </summary>
|
||||
public bool IsHosted => !ForceNotHosted && (HttpContext.Current != null || HostingEnvironment.IsHosted);
|
||||
|
||||
public char DirSepChar => Path.DirectorySeparatorChar;
|
||||
|
||||
@@ -57,7 +60,7 @@ namespace Umbraco.Core.IO
|
||||
else if (Uri.IsWellFormedUriString(virtualPath, UriKind.Absolute))
|
||||
return virtualPath;
|
||||
else
|
||||
return VirtualPathUtility.ToAbsolute(virtualPath, Root);
|
||||
return _hostingEnvironment.ToAbsolute(virtualPath, Root);
|
||||
}
|
||||
|
||||
public Attempt<string> TryResolveUrl(string virtualPath)
|
||||
@@ -68,7 +71,7 @@ namespace Umbraco.Core.IO
|
||||
return Attempt.Succeed(virtualPath.Replace("~", Root).Replace("//", "/"));
|
||||
if (Uri.IsWellFormedUriString(virtualPath, UriKind.Absolute))
|
||||
return Attempt.Succeed(virtualPath);
|
||||
return Attempt.Succeed(VirtualPathUtility.ToAbsolute(virtualPath, Root));
|
||||
return Attempt.Succeed(_hostingEnvironment.ToAbsolute(virtualPath, Root));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -76,10 +79,9 @@ namespace Umbraco.Core.IO
|
||||
}
|
||||
}
|
||||
|
||||
public string MapPath(string path, bool useHttpContext)
|
||||
public string MapPath(string path)
|
||||
{
|
||||
if (path == null) throw new ArgumentNullException("path");
|
||||
useHttpContext = useHttpContext && IsHosted;
|
||||
if (path == null) throw new ArgumentNullException(nameof(path));
|
||||
|
||||
// Check if the path is already mapped
|
||||
if ((path.Length >= 2 && path[1] == Path.VolumeSeparatorChar)
|
||||
@@ -90,15 +92,20 @@ namespace Umbraco.Core.IO
|
||||
// Check that we even have an HttpContext! otherwise things will fail anyways
|
||||
// http://umbraco.codeplex.com/workitem/30946
|
||||
|
||||
if (useHttpContext && HttpContext.Current != null)
|
||||
|
||||
if (_hostingEnvironment.IsHosted)
|
||||
{
|
||||
//string retval;
|
||||
if (String.IsNullOrEmpty(path) == false && (path.StartsWith("~") || path.StartsWith(Root)))
|
||||
return HostingEnvironment.MapPath(path);
|
||||
else
|
||||
return HostingEnvironment.MapPath("~/" + path.TrimStart('/'));
|
||||
var result = (String.IsNullOrEmpty(path) == false && (path.StartsWith("~") || path.StartsWith(Root)))
|
||||
? _hostingEnvironment.MapPath(path)
|
||||
: _hostingEnvironment.MapPath("~/" + path.TrimStart('/'));
|
||||
|
||||
if (result != null) return result;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
var root = GetRootDirectorySafe();
|
||||
var newPath = path.TrimStart('~', '/').Replace('/', DirSepChar);
|
||||
var retval = root + DirSepChar.ToString(CultureInfo.InvariantCulture) + newPath;
|
||||
@@ -106,10 +113,6 @@ namespace Umbraco.Core.IO
|
||||
return retval;
|
||||
}
|
||||
|
||||
public string MapPath(string path)
|
||||
{
|
||||
return MapPath(path, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that the current filepath matches a directory where the user is allowed to edit a file.
|
||||
@@ -248,17 +251,6 @@ namespace Umbraco.Core.IO
|
||||
_rootDir = rootPath;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check to see if filename passed has any special chars in it and strips them to create a safe filename. Used to overcome an issue when Umbraco is used in IE in an intranet environment.
|
||||
/// </summary>
|
||||
/// <param name="filePath">The filename passed to the file handler from the upload field.</param>
|
||||
/// <returns>A safe filename without any path specific chars.</returns>
|
||||
public string SafeFileName(string filePath)
|
||||
{
|
||||
// use string extensions
|
||||
return filePath.ToSafeFileName();
|
||||
}
|
||||
|
||||
public void EnsurePathExists(string path)
|
||||
{
|
||||
var absolutePath = MapPath(path);
|
||||
@@ -280,7 +272,7 @@ namespace Umbraco.Core.IO
|
||||
path = relativePath;
|
||||
}
|
||||
|
||||
return path.EnsurePathIsApplicationRootPrefixed();
|
||||
return PathUtility.EnsurePathIsApplicationRootPrefixed(path);
|
||||
}
|
||||
|
||||
private string _root;
|
||||
@@ -294,7 +286,7 @@ namespace Umbraco.Core.IO
|
||||
{
|
||||
if (_root != null) return _root;
|
||||
|
||||
var appPath = HostingEnvironment.ApplicationVirtualPath;
|
||||
var appPath = _hostingEnvironment.ApplicationVirtualPath;
|
||||
// ReSharper disable once ConditionIsAlwaysTrueOrFalse
|
||||
if (appPath == null || appPath == "/") appPath = string.Empty;
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Threading.Tasks;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Strings;
|
||||
|
||||
namespace Umbraco.Core.IO
|
||||
{
|
||||
@@ -15,20 +16,18 @@ namespace Umbraco.Core.IO
|
||||
public class MediaFileSystem : FileSystemWrapper, IMediaFileSystem
|
||||
{
|
||||
private readonly IMediaPathScheme _mediaPathScheme;
|
||||
private readonly IContentSection _contentConfig;
|
||||
private readonly ILogger _logger;
|
||||
private readonly IIOHelper _ioHelper;
|
||||
private readonly IShortStringHelper _shortStringHelper;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MediaFileSystem"/> class.
|
||||
/// </summary>
|
||||
public MediaFileSystem(IFileSystem innerFileSystem, IContentSection contentConfig, IMediaPathScheme mediaPathScheme, ILogger logger, IIOHelper ioHelper)
|
||||
public MediaFileSystem(IFileSystem innerFileSystem, IMediaPathScheme mediaPathScheme, ILogger logger, IShortStringHelper shortStringHelper)
|
||||
: base(innerFileSystem)
|
||||
{
|
||||
_contentConfig = contentConfig;
|
||||
_mediaPathScheme = mediaPathScheme;
|
||||
_logger = logger;
|
||||
_ioHelper = ioHelper;
|
||||
_shortStringHelper = shortStringHelper;
|
||||
}
|
||||
|
||||
/// <inheritoc />
|
||||
@@ -65,7 +64,7 @@ namespace Umbraco.Core.IO
|
||||
{
|
||||
filename = Path.GetFileName(filename);
|
||||
if (filename == null) throw new ArgumentException("Cannot become a safe filename.", nameof(filename));
|
||||
filename = _ioHelper.SafeFileName(filename.ToLowerInvariant());
|
||||
filename = _shortStringHelper.CleanStringForSafeFileName(filename.ToLowerInvariant());
|
||||
|
||||
return _mediaPathScheme.GetFilePath(this, cuid, puid, filename);
|
||||
}
|
||||
@@ -75,7 +74,7 @@ namespace Umbraco.Core.IO
|
||||
{
|
||||
filename = Path.GetFileName(filename);
|
||||
if (filename == null) throw new ArgumentException("Cannot become a safe filename.", nameof(filename));
|
||||
filename = _ioHelper.SafeFileName(filename.ToLowerInvariant());
|
||||
filename = _shortStringHelper.CleanStringForSafeFileName(filename.ToLowerInvariant());
|
||||
|
||||
return _mediaPathScheme.GetFilePath(this, cuid, puid, filename, prevpath);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using Umbraco.Core.IO;
|
||||
|
||||
namespace Umbraco.Core
|
||||
{
|
||||
@@ -1213,5 +1214,65 @@ namespace Umbraco.Core
|
||||
/// </summary>
|
||||
public static string NullOrWhiteSpaceAsNull(this string text)
|
||||
=> string.IsNullOrWhiteSpace(text) ? null : text;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Checks if a given path is a full path including drive letter
|
||||
/// </summary>
|
||||
/// <param name="path"></param>
|
||||
/// <returns></returns>
|
||||
// From: http://stackoverflow.com/a/35046453/5018
|
||||
public static bool IsFullPath(this string path)
|
||||
{
|
||||
return string.IsNullOrWhiteSpace(path) == false
|
||||
&& path.IndexOfAny(Path.GetInvalidPathChars().ToArray()) == -1
|
||||
&& Path.IsPathRooted(path)
|
||||
&& Path.GetPathRoot(path).Equals(Path.DirectorySeparatorChar.ToString(), StringComparison.Ordinal) == false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Based on the input string, this will detect if the string is a JS path or a JS snippet.
|
||||
/// If a path cannot be determined, then it is assumed to be a snippet the original text is returned
|
||||
/// with an invalid attempt, otherwise a valid attempt is returned with the resolved path
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
/// <remarks>
|
||||
/// This is only used for legacy purposes for the Action.JsSource stuff and shouldn't be needed in v8
|
||||
/// </remarks>
|
||||
internal static Attempt<string> DetectIsJavaScriptPath(this string input, IIOHelper ioHelper)
|
||||
{
|
||||
//validate that this is a url, if it is not, we'll assume that it is a text block and render it as a text
|
||||
//block instead.
|
||||
var isValid = true;
|
||||
|
||||
if (Uri.IsWellFormedUriString(input, UriKind.RelativeOrAbsolute))
|
||||
{
|
||||
//ok it validates, but so does alert('hello'); ! so we need to do more checks
|
||||
|
||||
//here are the valid chars in a url without escaping
|
||||
if (Regex.IsMatch(input, @"[^a-zA-Z0-9-._~:/?#\[\]@!$&'\(\)*\+,%;=]"))
|
||||
isValid = false;
|
||||
|
||||
//we'll have to be smarter and just check for certain js patterns now too!
|
||||
var jsPatterns = new[] { @"\+\s*\=", @"\);", @"function\s*\(", @"!=", @"==" };
|
||||
if (jsPatterns.Any(p => Regex.IsMatch(input, p)))
|
||||
isValid = false;
|
||||
|
||||
if (isValid)
|
||||
{
|
||||
var resolvedUrlResult = ioHelper.TryResolveUrl(input);
|
||||
//if the resolution was success, return it, otherwise just return the path, we've detected
|
||||
// it's a path but maybe it's relative and resolution has failed, etc... in which case we're just
|
||||
// returning what was given to us.
|
||||
return resolvedUrlResult.Success
|
||||
? resolvedUrlResult
|
||||
: Attempt.Succeed(input);
|
||||
}
|
||||
}
|
||||
|
||||
return Attempt.Fail(input);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
namespace Umbraco.Core.Strings
|
||||
{
|
||||
public static class PathUtility
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Ensures that a path has `~/` as prefix
|
||||
/// </summary>
|
||||
/// <param name="path"></param>
|
||||
/// <returns></returns>
|
||||
public static string EnsurePathIsApplicationRootPrefixed(string path)
|
||||
{
|
||||
if (path.StartsWith("~/"))
|
||||
return path;
|
||||
if (path.StartsWith("/") == false && path.StartsWith("\\") == false)
|
||||
path = string.Format("/{0}", path);
|
||||
if (path.StartsWith("~") == false)
|
||||
path = string.Format("~{0}", path);
|
||||
return path;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,20 +7,19 @@ namespace Umbraco.Core.Configuration
|
||||
{
|
||||
public class ConfigsFactory : IConfigsFactory
|
||||
{
|
||||
private readonly IIOHelper _ioHelper;
|
||||
|
||||
public ConfigsFactory(IIOHelper ioHelper)
|
||||
public ConfigsFactory()
|
||||
{
|
||||
_ioHelper = ioHelper;
|
||||
GlobalSettings = new GlobalSettings(_ioHelper);
|
||||
}
|
||||
|
||||
public IGlobalSettings GlobalSettings { get; }
|
||||
public IHostingSettings HostingSettings { get; } = new HostingSettings();
|
||||
public IUmbracoSettingsSection UmbracoSettings { get; }
|
||||
|
||||
public Configs Create()
|
||||
public Configs Create(IIOHelper ioHelper)
|
||||
{
|
||||
var configs = new Configs(section => ConfigurationManager.GetSection(section));
|
||||
configs.Add<IGlobalSettings>(() => GlobalSettings);
|
||||
configs.Add<IGlobalSettings>(() => new GlobalSettings(ioHelper));
|
||||
configs.Add<IHostingSettings>(() => HostingSettings);
|
||||
|
||||
configs.Add<IUmbracoSettingsSection>("umbracoConfiguration/settings");
|
||||
configs.Add<IHealthChecks>("umbracoConfiguration/HealthChecks");
|
||||
@@ -29,7 +28,7 @@ namespace Umbraco.Core.Configuration
|
||||
configs.Add<IMemberPasswordConfiguration>(() => new DefaultPasswordConfig());
|
||||
configs.Add<ICoreDebug>(() => new CoreDebug());
|
||||
configs.Add<IConnectionStrings>(() => new ConnectionStrings());
|
||||
configs.AddCoreConfigs(_ioHelper);
|
||||
configs.AddCoreConfigs(ioHelper);
|
||||
return configs;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,54 @@ using Umbraco.Core.IO;
|
||||
|
||||
namespace Umbraco.Core.Configuration
|
||||
{
|
||||
public class HostingSettings : IHostingSettings
|
||||
{
|
||||
private bool? _debugMode;
|
||||
|
||||
/// <inheritdoc />
|
||||
public LocalTempStorage LocalTempStorageLocation
|
||||
{
|
||||
get
|
||||
{
|
||||
var setting = ConfigurationManager.AppSettings[Constants.AppSettings.LocalTempStorage];
|
||||
if (!string.IsNullOrWhiteSpace(setting))
|
||||
return Enum<LocalTempStorage>.Parse(setting);
|
||||
|
||||
return LocalTempStorage.Default;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether umbraco is running in [debug mode].
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if [debug mode]; otherwise, <c>false</c>.</value>
|
||||
public bool DebugMode
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!_debugMode.HasValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (ConfigurationManager.GetSection("system.web/compilation") is ConfigurationSection compilation)
|
||||
{
|
||||
var debugElement = compilation.ElementInformation.Properties["debug"];
|
||||
|
||||
_debugMode = debugElement != null && (debugElement.Value is bool debug && debug);
|
||||
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
_debugMode = false;
|
||||
}
|
||||
}
|
||||
|
||||
return _debugMode.GetValueOrDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Replace checking for if the app settings exist and returning an empty string, instead return the defaults!
|
||||
// TODO: need to massively cleanup these configuration classes
|
||||
|
||||
@@ -229,31 +277,6 @@ namespace Umbraco.Core.Configuration
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether umbraco is running in [debug mode].
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if [debug mode]; otherwise, <c>false</c>.</value>
|
||||
public bool DebugMode
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
if (ConfigurationManager.GetSection("system.web/compilation") is ConfigurationSection compilation)
|
||||
{
|
||||
var debugElement = compilation.ElementInformation.Properties["debug"];
|
||||
|
||||
return debugElement != null && (debugElement.Value is bool debug && debug);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the time out in minutes.
|
||||
@@ -293,18 +316,7 @@ namespace Umbraco.Core.Configuration
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public LocalTempStorage LocalTempStorageLocation
|
||||
{
|
||||
get
|
||||
{
|
||||
var setting = ConfigurationManager.AppSettings[Constants.AppSettings.LocalTempStorage];
|
||||
if (!string.IsNullOrWhiteSpace(setting))
|
||||
return Enum<LocalTempStorage>.Parse(setting);
|
||||
|
||||
return LocalTempStorage.Default;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.IO;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Hosting;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Manifest;
|
||||
@@ -11,16 +12,18 @@ namespace Umbraco.Core.Compose
|
||||
private readonly IRuntimeState _runtimeState;
|
||||
private readonly ILogger _logger;
|
||||
private readonly IIOHelper _ioHelper;
|
||||
private readonly IHostingEnvironment _hostingEnvironment;
|
||||
|
||||
// if configured and in debug mode, a ManifestWatcher watches App_Plugins folders for
|
||||
// package.manifest chances and restarts the application on any change
|
||||
private ManifestWatcher _mw;
|
||||
|
||||
public ManifestWatcherComponent(IRuntimeState runtimeState, ILogger logger, IIOHelper ioHelper)
|
||||
public ManifestWatcherComponent(IRuntimeState runtimeState, ILogger logger, IIOHelper ioHelper, IHostingEnvironment hostingEnvironment)
|
||||
{
|
||||
_runtimeState = runtimeState;
|
||||
_logger = logger;
|
||||
_ioHelper = ioHelper;
|
||||
_hostingEnvironment = hostingEnvironment;
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
@@ -33,7 +36,7 @@ namespace Umbraco.Core.Compose
|
||||
var appPlugins = _ioHelper.MapPath("~/App_Plugins/");
|
||||
if (Directory.Exists(appPlugins) == false) return;
|
||||
|
||||
_mw = new ManifestWatcher(_logger);
|
||||
_mw = new ManifestWatcher(_logger, _hostingEnvironment);
|
||||
_mw.Start(Directory.GetDirectories(appPlugins));
|
||||
}
|
||||
|
||||
|
||||
@@ -96,11 +96,11 @@ namespace Umbraco.Core.Composing
|
||||
/// <para>Unlocks <see cref="Configs"/> so that it is possible to add configurations
|
||||
/// directly to <see cref="Current"/> without having to wire composition.</para>
|
||||
/// </remarks>
|
||||
public static void UnlockConfigs(IConfigsFactory configsFactory)
|
||||
public static void UnlockConfigs(IConfigsFactory configsFactory, IIOHelper ioHelper)
|
||||
{
|
||||
if (_factory != null)
|
||||
throw new InvalidOperationException("Cannot unlock configs when a factory has been set.");
|
||||
_configs = configsFactory.Create();
|
||||
_configs = configsFactory.Create(ioHelper);
|
||||
}
|
||||
|
||||
internal static event EventHandler Resetted;
|
||||
@@ -211,7 +211,7 @@ namespace Umbraco.Core.Composing
|
||||
public static IVariationContextAccessor VariationContextAccessor
|
||||
=> Factory.GetInstance<IVariationContextAccessor>();
|
||||
|
||||
public static IIOHelper IOHelper = new IOHelper();
|
||||
public static IIOHelper IOHelper => Factory.GetInstance<IIOHelper>();
|
||||
|
||||
|
||||
public static IHostingEnvironment HostingEnvironment => Factory.GetInstance<IHostingEnvironment>();
|
||||
|
||||
@@ -11,6 +11,7 @@ using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Strings;
|
||||
|
||||
namespace Umbraco.Core
|
||||
{
|
||||
@@ -136,9 +137,9 @@ namespace Umbraco.Core
|
||||
if (filename == null || filestream == null) return;
|
||||
|
||||
// get a safe & clean filename
|
||||
var ioHelper = Current.Factory.GetInstance<IIOHelper>();
|
||||
var shortStringHelper = Current.Factory.GetInstance<IShortStringHelper>();
|
||||
|
||||
filename = ioHelper.SafeFileName(filename);
|
||||
filename = shortStringHelper.CleanStringForSafeFileName(filename);
|
||||
if (string.IsNullOrWhiteSpace(filename)) return;
|
||||
filename = filename.ToLower();
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Composing;
|
||||
|
||||
namespace Umbraco.Core.Logging
|
||||
@@ -11,10 +12,11 @@ namespace Umbraco.Core.Logging
|
||||
/// Retrieve the id assigned to the currently-executing HTTP request, if any.
|
||||
/// </summary>
|
||||
/// <param name="requestId">The request id.</param>
|
||||
/// <param name="requestCache"></param>
|
||||
/// <returns><c>true</c> if there is a request in progress; <c>false</c> otherwise.</returns>
|
||||
public static bool TryGetCurrentHttpRequestId(out Guid requestId)
|
||||
public static bool TryGetCurrentHttpRequestId(out Guid requestId, IRequestCache requestCache)
|
||||
{
|
||||
var requestIdItem = Current.AppCaches.RequestCache.Get(RequestIdItemName, () => Guid.NewGuid());
|
||||
var requestIdItem = requestCache.Get(RequestIdItemName, () => Guid.NewGuid());
|
||||
requestId = (Guid)requestIdItem;
|
||||
|
||||
return true;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using Serilog.Core;
|
||||
using Serilog.Events;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Composing;
|
||||
|
||||
namespace Umbraco.Core.Logging.Serilog.Enrichers
|
||||
{
|
||||
@@ -11,6 +13,13 @@ namespace Umbraco.Core.Logging.Serilog.Enrichers
|
||||
/// </summary>
|
||||
internal class HttpRequestIdEnricher : ILogEventEnricher
|
||||
{
|
||||
private readonly Func<IRequestCache> _requestCacheGetter;
|
||||
|
||||
public HttpRequestIdEnricher(Func<IRequestCache> requestCacheGetter)
|
||||
{
|
||||
_requestCacheGetter = requestCacheGetter;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The property name added to enriched log events.
|
||||
/// </summary>
|
||||
@@ -23,14 +32,17 @@ namespace Umbraco.Core.Logging.Serilog.Enrichers
|
||||
/// <param name="propertyFactory">Factory for creating new properties to add to the event.</param>
|
||||
public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
|
||||
{
|
||||
if (logEvent == null) throw new ArgumentNullException("logEvent");
|
||||
if (logEvent == null) throw new ArgumentNullException(nameof(logEvent));
|
||||
|
||||
var requestCache = _requestCacheGetter();
|
||||
if(requestCache is null) return;
|
||||
|
||||
Guid requestId;
|
||||
if (!LogHttpRequest.TryGetCurrentHttpRequestId(out requestId))
|
||||
if (!LogHttpRequest.TryGetCurrentHttpRequestId(out requestId, requestCache))
|
||||
return;
|
||||
|
||||
var requestIdProperty = new LogEventProperty(HttpRequestIdPropertyName, new ScalarValue(requestId));
|
||||
logEvent.AddPropertyIfAbsent(requestIdProperty);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Threading;
|
||||
using Serilog.Core;
|
||||
using Serilog.Events;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Composing;
|
||||
|
||||
namespace Umbraco.Core.Logging.Serilog.Enrichers
|
||||
{
|
||||
@@ -14,6 +15,7 @@ namespace Umbraco.Core.Logging.Serilog.Enrichers
|
||||
/// </summary>
|
||||
internal class HttpRequestNumberEnricher : ILogEventEnricher
|
||||
{
|
||||
private readonly Func<IRequestCache> _requestCacheGetter;
|
||||
private static int _lastRequestNumber;
|
||||
private static readonly string _requestNumberItemName = typeof(HttpRequestNumberEnricher).Name + "+RequestNumber";
|
||||
|
||||
@@ -22,11 +24,10 @@ namespace Umbraco.Core.Logging.Serilog.Enrichers
|
||||
/// </summary>
|
||||
private const string _httpRequestNumberPropertyName = "HttpRequestNumber";
|
||||
|
||||
private readonly Lazy<IAppCache> _requestCache;
|
||||
|
||||
public HttpRequestNumberEnricher(Lazy<IAppCache> requestCache)
|
||||
public HttpRequestNumberEnricher(Func<IRequestCache> requestCacheGetter)
|
||||
{
|
||||
_requestCache = requestCache;
|
||||
_requestCacheGetter = requestCacheGetter;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -36,9 +37,12 @@ namespace Umbraco.Core.Logging.Serilog.Enrichers
|
||||
/// <param name="propertyFactory">Factory for creating new properties to add to the event.</param>
|
||||
public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
|
||||
{
|
||||
if (logEvent == null) throw new ArgumentNullException("logEvent");
|
||||
if (logEvent == null) throw new ArgumentNullException(nameof(logEvent));
|
||||
|
||||
var requestNumber = _requestCache.Value.Get(_requestNumberItemName,
|
||||
var requestCache = _requestCacheGetter();
|
||||
if (requestCache is null) return;
|
||||
|
||||
var requestNumber = requestCache.Get(_requestNumberItemName,
|
||||
() => Interlocked.Increment(ref _lastRequestNumber));
|
||||
|
||||
var requestNumberProperty = new LogEventProperty(_httpRequestNumberPropertyName, new ScalarValue(requestNumber));
|
||||
|
||||
@@ -12,9 +12,9 @@ namespace Umbraco.Core.Logging.Serilog.Enrichers
|
||||
/// </summary>
|
||||
internal class HttpSessionIdEnricher : ILogEventEnricher
|
||||
{
|
||||
private readonly Lazy<ISessionIdResolver> _sessionIdResolver;
|
||||
private readonly ISessionIdResolver _sessionIdResolver;
|
||||
|
||||
public HttpSessionIdEnricher(Lazy<ISessionIdResolver> sessionIdResolver)
|
||||
public HttpSessionIdEnricher(ISessionIdResolver sessionIdResolver)
|
||||
{
|
||||
_sessionIdResolver = sessionIdResolver;
|
||||
}
|
||||
@@ -32,7 +32,7 @@ namespace Umbraco.Core.Logging.Serilog.Enrichers
|
||||
{
|
||||
if (logEvent == null) throw new ArgumentNullException(nameof(logEvent));
|
||||
|
||||
var sessionId = _sessionIdResolver.Value.SessionId;
|
||||
var sessionId = _sessionIdResolver.SessionId;
|
||||
if (sessionId is null)
|
||||
return;
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Umbraco.Core.Logging.Serilog
|
||||
/// </summary>
|
||||
/// <param name="logConfig">A Serilog LoggerConfiguration</param>
|
||||
/// <param name="hostingEnvironment"></param>
|
||||
public static LoggerConfiguration MinimalConfiguration(this LoggerConfiguration logConfig, IHostingEnvironment hostingEnvironment)
|
||||
public static LoggerConfiguration MinimalConfiguration(this LoggerConfiguration logConfig, IHostingEnvironment hostingEnvironment, ISessionIdResolver sessionIdResolver, Func<IRequestCache> requestCacheGetter)
|
||||
{
|
||||
global::Serilog.Debugging.SelfLog.Enable(msg => System.Diagnostics.Debug.WriteLine(msg));
|
||||
|
||||
@@ -42,9 +42,9 @@ namespace Umbraco.Core.Logging.Serilog
|
||||
.Enrich.WithProperty("AppDomainAppId", hostingEnvironment.ApplicationId.ReplaceNonAlphanumericChars(string.Empty))
|
||||
.Enrich.WithProperty("MachineName", Environment.MachineName)
|
||||
.Enrich.With<Log4NetLevelMapperEnricher>()
|
||||
.Enrich.With(new HttpSessionIdEnricher(new Lazy<ISessionIdResolver>(() => Current.SessionIdResolver)))
|
||||
.Enrich.With(new HttpRequestNumberEnricher(new Lazy<IAppCache>(() => Current.AppCaches.RequestCache)))
|
||||
.Enrich.With<HttpRequestIdEnricher>();
|
||||
.Enrich.With(new HttpSessionIdEnricher(sessionIdResolver))
|
||||
.Enrich.With(new HttpRequestNumberEnricher(requestCacheGetter))
|
||||
.Enrich.With(new HttpRequestIdEnricher(requestCacheGetter));
|
||||
|
||||
return logConfig;
|
||||
}
|
||||
|
||||
@@ -4,9 +4,11 @@ using System.Reflection;
|
||||
using System.Threading;
|
||||
using Serilog;
|
||||
using Serilog.Events;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Diagnostics;
|
||||
using Umbraco.Core.Hosting;
|
||||
using Umbraco.Net;
|
||||
|
||||
namespace Umbraco.Core.Logging.Serilog
|
||||
{
|
||||
@@ -36,11 +38,11 @@ namespace Umbraco.Core.Logging.Serilog
|
||||
/// Creates a logger with some pre-defined configuration and remainder from config file
|
||||
/// </summary>
|
||||
/// <remarks>Used by UmbracoApplicationBase to get its logger.</remarks>
|
||||
public static SerilogLogger CreateWithDefaultConfiguration(IHostingEnvironment hostingEnvironment)
|
||||
public static SerilogLogger CreateWithDefaultConfiguration(IHostingEnvironment hostingEnvironment, ISessionIdResolver sessionIdResolver, Func<IRequestCache> requestCacheGetter)
|
||||
{
|
||||
var loggerConfig = new LoggerConfiguration();
|
||||
loggerConfig
|
||||
.MinimalConfiguration(hostingEnvironment)
|
||||
.MinimalConfiguration(hostingEnvironment, sessionIdResolver, requestCacheGetter)
|
||||
.ReadFromConfigFile()
|
||||
.ReadFromUserConfigFile();
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using Umbraco.Core.Hosting;
|
||||
using Umbraco.Core.Logging;
|
||||
|
||||
namespace Umbraco.Core.Manifest
|
||||
@@ -13,11 +13,13 @@ namespace Umbraco.Core.Manifest
|
||||
private static volatile bool _isRestarting;
|
||||
|
||||
private readonly ILogger _logger;
|
||||
private readonly IHostingEnvironment _hostingEnvironment;
|
||||
private readonly List<FileSystemWatcher> _fws = new List<FileSystemWatcher>();
|
||||
|
||||
public ManifestWatcher(ILogger logger)
|
||||
public ManifestWatcher(ILogger logger, IHostingEnvironment hostingEnvironment)
|
||||
{
|
||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
_hostingEnvironment = hostingEnvironment;
|
||||
}
|
||||
|
||||
public void Start(params string[] packageFolders)
|
||||
@@ -55,7 +57,7 @@ namespace Umbraco.Core.Manifest
|
||||
|
||||
_isRestarting = true;
|
||||
_logger.Info<ManifestWatcher>("Manifest has changed, app pool is restarting ({Path})", e.FullPath);
|
||||
HttpRuntime.UnloadAppDomain();
|
||||
_hostingEnvironment.LazyRestartApplication();
|
||||
Dispose(); // uh? if the app restarts then this should be disposed anyways?
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
@@ -12,9 +13,13 @@ namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0
|
||||
{
|
||||
public class DropDownPropertyEditorsMigration : PropertyEditorsMigrationBase
|
||||
{
|
||||
public DropDownPropertyEditorsMigration(IMigrationContext context)
|
||||
private readonly IIOHelper _ioHelper;
|
||||
|
||||
public DropDownPropertyEditorsMigration(IMigrationContext context, IIOHelper ioHelper)
|
||||
: base(context)
|
||||
{ }
|
||||
{
|
||||
_ioHelper = ioHelper;
|
||||
}
|
||||
|
||||
public override void Migrate()
|
||||
{
|
||||
@@ -39,7 +44,7 @@ namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0
|
||||
{
|
||||
// parse configuration, and update everything accordingly
|
||||
if (configurationEditor == null)
|
||||
configurationEditor = new ValueListConfigurationEditor();
|
||||
configurationEditor = new ValueListConfigurationEditor(_ioHelper);
|
||||
try
|
||||
{
|
||||
config = (ValueListConfiguration) configurationEditor.FromDatabase(dataType.Configuration);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
@@ -9,9 +10,12 @@ namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0
|
||||
{
|
||||
public class MergeDateAndDateTimePropertyEditor : MigrationBase
|
||||
{
|
||||
public MergeDateAndDateTimePropertyEditor(IMigrationContext context)
|
||||
private readonly IIOHelper _ioHelper;
|
||||
|
||||
public MergeDateAndDateTimePropertyEditor(IMigrationContext context, IIOHelper ioHelper)
|
||||
: base(context)
|
||||
{
|
||||
_ioHelper = ioHelper;
|
||||
}
|
||||
|
||||
public override void Migrate()
|
||||
@@ -23,7 +27,7 @@ namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0
|
||||
DateTimeConfiguration config;
|
||||
try
|
||||
{
|
||||
config = (DateTimeConfiguration) new CustomDateTimeConfigurationEditor().FromDatabase(
|
||||
config = (DateTimeConfiguration) new CustomDateTimeConfigurationEditor(_ioHelper).FromDatabase(
|
||||
dataType.Configuration);
|
||||
|
||||
// If the Umbraco.Date type is the default from V7 and it has never been updated, then the
|
||||
@@ -69,6 +73,9 @@ namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0
|
||||
|
||||
private class CustomDateTimeConfigurationEditor : ConfigurationEditor<DateTimeConfiguration>
|
||||
{
|
||||
public CustomDateTimeConfigurationEditor(IIOHelper ioHelper) : base(ioHelper)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
@@ -92,6 +93,10 @@ namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0
|
||||
|
||||
// dummy editor for deserialization
|
||||
protected class ValueListConfigurationEditor : ConfigurationEditor<ValueListConfiguration>
|
||||
{ }
|
||||
{
|
||||
public ValueListConfigurationEditor(IIOHelper ioHelper) : base(ioHelper)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+8
-3
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Migrations.PostMigrations;
|
||||
using Umbraco.Core.Models;
|
||||
@@ -12,9 +13,13 @@ namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0
|
||||
{
|
||||
public class RadioAndCheckboxPropertyEditorsMigration : PropertyEditorsMigrationBase
|
||||
{
|
||||
public RadioAndCheckboxPropertyEditorsMigration(IMigrationContext context)
|
||||
private readonly IIOHelper _ioHelper;
|
||||
|
||||
public RadioAndCheckboxPropertyEditorsMigration(IMigrationContext context, IIOHelper ioHelper)
|
||||
: base(context)
|
||||
{ }
|
||||
{
|
||||
_ioHelper = ioHelper;
|
||||
}
|
||||
|
||||
public override void Migrate()
|
||||
{
|
||||
@@ -43,7 +48,7 @@ namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0
|
||||
|
||||
// parse configuration, and update everything accordingly
|
||||
if (configurationEditor == null)
|
||||
configurationEditor = new ValueListConfigurationEditor();
|
||||
configurationEditor = new ValueListConfigurationEditor(_ioHelper);
|
||||
try
|
||||
{
|
||||
config = (ValueListConfiguration) configurationEditor.FromDatabase(dataType.Configuration);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Reflection;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
@@ -11,14 +12,14 @@ namespace Umbraco.Core.Persistence.Factories
|
||||
{
|
||||
internal static class DataTypeFactory
|
||||
{
|
||||
public static IDataType BuildEntity(DataTypeDto dto, PropertyEditorCollection editors, ILogger logger)
|
||||
public static IDataType BuildEntity(DataTypeDto dto, PropertyEditorCollection editors, ILogger logger, IIOHelper ioHelper)
|
||||
{
|
||||
if (!editors.TryGet(dto.EditorAlias, out var editor))
|
||||
{
|
||||
logger.Warn(typeof(DataType), "Could not find an editor with alias {EditorAlias}, treating as Label."
|
||||
+" The site may fail to boot and / or load data types and run.", dto.EditorAlias);
|
||||
//convert to label
|
||||
editor = new LabelPropertyEditor(logger);
|
||||
editor = new LabelPropertyEditor(logger, ioHelper);
|
||||
}
|
||||
|
||||
var dataType = new DataType(editor);
|
||||
|
||||
@@ -7,6 +7,7 @@ using NPoco;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Events;
|
||||
using Umbraco.Core.Exceptions;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Entities;
|
||||
@@ -26,12 +27,14 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
internal class DataTypeRepository : NPocoRepositoryBase<int, IDataType>, IDataTypeRepository
|
||||
{
|
||||
private readonly Lazy<PropertyEditorCollection> _editors;
|
||||
private readonly IIOHelper _ioHelper;
|
||||
|
||||
// TODO: https://github.com/umbraco/Umbraco-CMS/issues/4237 - get rid of Lazy injection and fix circular dependencies
|
||||
public DataTypeRepository(IScopeAccessor scopeAccessor, AppCaches cache, Lazy<PropertyEditorCollection> editors, ILogger logger)
|
||||
public DataTypeRepository(IScopeAccessor scopeAccessor, AppCaches cache, Lazy<PropertyEditorCollection> editors, ILogger logger, IIOHelper ioHelper)
|
||||
: base(scopeAccessor, cache, logger)
|
||||
{
|
||||
_editors = editors;
|
||||
_ioHelper = ioHelper;
|
||||
}
|
||||
|
||||
#region Overrides of RepositoryBase<int,DataTypeDefinition>
|
||||
@@ -55,7 +58,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
}
|
||||
|
||||
var dtos = Database.Fetch<DataTypeDto>(dataTypeSql);
|
||||
return dtos.Select(x => DataTypeFactory.BuildEntity(x, _editors.Value, Logger)).ToArray();
|
||||
return dtos.Select(x => DataTypeFactory.BuildEntity(x, _editors.Value, Logger,_ioHelper)).ToArray();
|
||||
}
|
||||
|
||||
protected override IEnumerable<IDataType> PerformGetByQuery(IQuery<IDataType> query)
|
||||
@@ -66,7 +69,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
|
||||
var dtos = Database.Fetch<DataTypeDto>(sql);
|
||||
|
||||
return dtos.Select(x => DataTypeFactory.BuildEntity(x, _editors.Value, Logger)).ToArray();
|
||||
return dtos.Select(x => DataTypeFactory.BuildEntity(x, _editors.Value, Logger, _ioHelper)).ToArray();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Reflection;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.IO;
|
||||
|
||||
namespace Umbraco.Core.PropertyEditors
|
||||
{
|
||||
@@ -16,14 +17,14 @@ namespace Umbraco.Core.PropertyEditors
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ConfigurationEditor{TConfiguration}"/> class.
|
||||
/// </summary>
|
||||
protected ConfigurationEditor()
|
||||
: base(DiscoverFields())
|
||||
protected ConfigurationEditor(IIOHelper ioHelper)
|
||||
: base(DiscoverFields(ioHelper))
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Discovers fields from configuration properties marked with the field attribute.
|
||||
/// </summary>
|
||||
private static List<ConfigurationField> DiscoverFields()
|
||||
private static List<ConfigurationField> DiscoverFields(IIOHelper ioHelper)
|
||||
{
|
||||
var fields = new List<ConfigurationField>();
|
||||
var properties = TypeHelper.CachedDiscoverableProperties(typeof(TConfiguration));
|
||||
@@ -35,7 +36,7 @@ namespace Umbraco.Core.PropertyEditors
|
||||
|
||||
ConfigurationField field;
|
||||
|
||||
var attributeView = Current.IOHelper.ResolveVirtualUrl(attribute.View);
|
||||
var attributeView = ioHelper.ResolveVirtualUrl(attribute.View);
|
||||
// if the field does not have its own type, use the base type
|
||||
if (attribute.Type == null)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using Umbraco.Core.IO;
|
||||
|
||||
namespace Umbraco.Core.PropertyEditors
|
||||
{
|
||||
@@ -7,6 +8,10 @@ namespace Umbraco.Core.PropertyEditors
|
||||
/// </summary>
|
||||
public class LabelConfigurationEditor : ConfigurationEditor<LabelConfiguration>
|
||||
{
|
||||
public LabelConfigurationEditor(IIOHelper ioHelper) : base(ioHelper)
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override LabelConfiguration FromConfigurationEditor(IDictionary<string, object> editorValues, LabelConfiguration configuration)
|
||||
{
|
||||
@@ -24,5 +29,7 @@ namespace Umbraco.Core.PropertyEditors
|
||||
|
||||
return newConfiguration;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Services;
|
||||
|
||||
@@ -14,18 +15,22 @@ namespace Umbraco.Core.PropertyEditors
|
||||
Icon = "icon-readonly")]
|
||||
public class LabelPropertyEditor : DataEditor
|
||||
{
|
||||
private readonly IIOHelper _ioHelper;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LabelPropertyEditor"/> class.
|
||||
/// </summary>
|
||||
public LabelPropertyEditor(ILogger logger)
|
||||
public LabelPropertyEditor(ILogger logger, IIOHelper ioHelper)
|
||||
: base(logger)
|
||||
{ }
|
||||
{
|
||||
_ioHelper = ioHelper;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override IDataValueEditor CreateValueEditor() => new LabelPropertyValueEditor(Current.Services.DataTypeService, Current.Services.LocalizationService, Attribute);
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override IConfigurationEditor CreateConfigurationEditor() => new LabelConfigurationEditor();
|
||||
protected override IConfigurationEditor CreateConfigurationEditor() => new LabelConfigurationEditor(_ioHelper);
|
||||
|
||||
// provides the property value editor
|
||||
internal class LabelPropertyValueEditor : DataValueEditor
|
||||
|
||||
@@ -154,7 +154,7 @@ namespace Umbraco.Core.Runtime
|
||||
var mainDom = new MainDom(Logger, HostingEnvironment);
|
||||
|
||||
// create the composition
|
||||
composition = new Composition(register, typeLoader, ProfilingLogger, _state, Configs);
|
||||
composition = new Composition(register, typeLoader, ProfilingLogger, _state, Configs, IOHelper, appCaches);
|
||||
composition.RegisterEssentials(Logger, Profiler, ProfilingLogger, mainDom, appCaches, databaseFactory, typeLoader, _state, TypeFinder, IOHelper, UmbracoVersion);
|
||||
|
||||
// run handlers
|
||||
|
||||
@@ -14,51 +14,6 @@ namespace Umbraco.Core
|
||||
///</summary>
|
||||
public static class StringExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Based on the input string, this will detect if the string is a JS path or a JS snippet.
|
||||
/// If a path cannot be determined, then it is assumed to be a snippet the original text is returned
|
||||
/// with an invalid attempt, otherwise a valid attempt is returned with the resolved path
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
/// <remarks>
|
||||
/// This is only used for legacy purposes for the Action.JsSource stuff and shouldn't be needed in v8
|
||||
/// </remarks>
|
||||
internal static Attempt<string> DetectIsJavaScriptPath(this string input)
|
||||
{
|
||||
//validate that this is a url, if it is not, we'll assume that it is a text block and render it as a text
|
||||
//block instead.
|
||||
var isValid = true;
|
||||
|
||||
if (Uri.IsWellFormedUriString(input, UriKind.RelativeOrAbsolute))
|
||||
{
|
||||
//ok it validates, but so does alert('hello'); ! so we need to do more checks
|
||||
|
||||
//here are the valid chars in a url without escaping
|
||||
if (Regex.IsMatch(input, @"[^a-zA-Z0-9-._~:/?#\[\]@!$&'\(\)*\+,%;=]"))
|
||||
isValid = false;
|
||||
|
||||
//we'll have to be smarter and just check for certain js patterns now too!
|
||||
var jsPatterns = new[] { @"\+\s*\=", @"\);", @"function\s*\(", @"!=", @"==" };
|
||||
if (jsPatterns.Any(p => Regex.IsMatch(input, p)))
|
||||
isValid = false;
|
||||
|
||||
if (isValid)
|
||||
{
|
||||
var ioHelper = Current.Factory.GetInstance<IIOHelper>();
|
||||
|
||||
var resolvedUrlResult = ioHelper.TryResolveUrl(input);
|
||||
//if the resolution was success, return it, otherwise just return the path, we've detected
|
||||
// it's a path but maybe it's relative and resolution has failed, etc... in which case we're just
|
||||
// returning what was given to us.
|
||||
return resolvedUrlResult.Success
|
||||
? resolvedUrlResult
|
||||
: Attempt.Succeed(input);
|
||||
}
|
||||
}
|
||||
|
||||
return Attempt.Fail(input);
|
||||
}
|
||||
|
||||
// FORMAT STRINGS
|
||||
|
||||
@@ -227,34 +182,8 @@ namespace Umbraco.Core
|
||||
return Current.ShortStringHelper.CleanStringForSafeFileName(text, culture);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if a given path is a full path including drive letter
|
||||
/// </summary>
|
||||
/// <param name="path"></param>
|
||||
/// <returns></returns>
|
||||
// From: http://stackoverflow.com/a/35046453/5018
|
||||
internal static bool IsFullPath(this string path)
|
||||
{
|
||||
return string.IsNullOrWhiteSpace(path) == false
|
||||
&& path.IndexOfAny(Path.GetInvalidPathChars().ToArray()) == -1
|
||||
&& Path.IsPathRooted(path)
|
||||
&& Path.GetPathRoot(path).Equals(Path.DirectorySeparatorChar.ToString(), StringComparison.Ordinal) == false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ensures that a path has `~/` as prefix
|
||||
/// </summary>
|
||||
/// <param name="path"></param>
|
||||
/// <returns></returns>
|
||||
internal static string EnsurePathIsApplicationRootPrefixed(this string path)
|
||||
{
|
||||
if (path.StartsWith("~/"))
|
||||
return path;
|
||||
if (path.StartsWith("/") == false && path.StartsWith("\\") == false)
|
||||
path = string.Format("/{0}", path);
|
||||
if (path.StartsWith("~") == false)
|
||||
path = string.Format("~{0}", path);
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,7 +159,6 @@
|
||||
<Compile Include="Composing\Current.cs" />
|
||||
<Compile Include="Composing\LightInject\LightInjectContainer.cs" />
|
||||
<Compile Include="Composing\LightInject\MixedLightInjectScopeManagerProvider.cs" />
|
||||
<Compile Include="IO\IOHelper.cs" />
|
||||
<Compile Include="Logging\Viewer\LogTimePeriod.cs" />
|
||||
<Compile Include="Manifest\DashboardAccessRuleConverter.cs" />
|
||||
<Compile Include="Manifest\DataEditorConverter.cs" />
|
||||
@@ -352,7 +351,6 @@
|
||||
<Compile Include="Events\UninstallPackageEventArgs.cs" />
|
||||
<Compile Include="Composing\LightInject\LightInjectException.cs" />
|
||||
<Compile Include="FileResources\Files.Designer.cs" />
|
||||
<Compile Include="IO\SystemFiles.cs" />
|
||||
<Compile Include="Logging\Serilog\SerilogLogger.cs" />
|
||||
<Compile Include="Logging\OwinLogger.cs" />
|
||||
<Compile Include="Logging\OwinLoggerFactory.cs" />
|
||||
@@ -821,6 +819,5 @@
|
||||
<Name>Umbraco.Abstractions</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -20,7 +20,8 @@ namespace Umbraco.Core
|
||||
/// The current application path or VirtualPath
|
||||
/// </param>
|
||||
/// <param name="globalSettings"></param>
|
||||
/// <returns></returns>
|
||||
/// <param name="ioHelper"></param>
|
||||
/// <returns></returns>
|
||||
/// <remarks>
|
||||
/// There are some special routes we need to check to properly determine this:
|
||||
///
|
||||
@@ -39,7 +40,7 @@ namespace Umbraco.Core
|
||||
/// But if we've got this far we'll just have to assume it's front-end anyways.
|
||||
///
|
||||
/// </remarks>
|
||||
internal static bool IsBackOfficeRequest(this Uri url, string applicationPath, IGlobalSettings globalSettings)
|
||||
internal static bool IsBackOfficeRequest(this Uri url, string applicationPath, IGlobalSettings globalSettings, IIOHelper ioHelper)
|
||||
{
|
||||
applicationPath = applicationPath ?? string.Empty;
|
||||
|
||||
@@ -52,7 +53,7 @@ namespace Umbraco.Core
|
||||
//if not, then def not back office
|
||||
if (isUmbracoPath == false) return false;
|
||||
|
||||
var mvcArea = globalSettings.GetUmbracoMvcArea(Current.IOHelper);
|
||||
var mvcArea = globalSettings.GetUmbracoMvcArea(ioHelper);
|
||||
//if its the normal /umbraco path
|
||||
if (urlPath.InvariantEquals("/" + mvcArea)
|
||||
|| urlPath.InvariantEquals("/" + mvcArea + "/"))
|
||||
@@ -107,8 +108,9 @@ namespace Umbraco.Core
|
||||
/// Checks if the current uri is an install request
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="ioHelper"></param>
|
||||
/// <returns></returns>
|
||||
internal static bool IsInstallerRequest(this Uri url)
|
||||
internal static bool IsInstallerRequest(this Uri url, IIOHelper ioHelper)
|
||||
{
|
||||
var authority = url.GetLeftPart(UriPartial.Authority);
|
||||
var afterAuthority = url.GetLeftPart(UriPartial.Query)
|
||||
@@ -116,7 +118,7 @@ namespace Umbraco.Core
|
||||
.TrimStart("/");
|
||||
|
||||
//check if this is in the umbraco back office
|
||||
return afterAuthority.InvariantStartsWith(Current.IOHelper.ResolveUrl("~/install").TrimStart("/"));
|
||||
return afterAuthority.InvariantStartsWith(ioHelper.ResolveUrl("~/install").TrimStart("/"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Reflection;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
using Umbraco.ModelsBuilder.Embedded.Building;
|
||||
using Umbraco.ModelsBuilder.Embedded.Configuration;
|
||||
@@ -28,9 +29,10 @@ namespace Umbraco.ModelsBuilder.Embedded.Compose
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
composition.Components().Append<ModelsBuilderComponent>();
|
||||
composition.Register<UmbracoServices>(Lifetime.Singleton);
|
||||
composition.Configs.Add<IModelsBuilderConfig>(() => new ModelsBuilderConfig());
|
||||
composition.Configs.Add<IModelsBuilderConfig>(() => new ModelsBuilderConfig(composition.IOHelper));
|
||||
composition.RegisterUnique<ModelsGenerator>();
|
||||
composition.RegisterUnique<LiveModelsProvider>();
|
||||
composition.RegisterUnique<OutOfDateModelsStatus>();
|
||||
|
||||
@@ -13,14 +13,17 @@ namespace Umbraco.ModelsBuilder.Embedded.Configuration
|
||||
/// </summary>
|
||||
public class ModelsBuilderConfig : IModelsBuilderConfig
|
||||
{
|
||||
private readonly IIOHelper _ioHelper;
|
||||
public const string DefaultModelsNamespace = "Umbraco.Web.PublishedModels";
|
||||
public const string DefaultModelsDirectory = "~/App_Data/Models";
|
||||
|
||||
public string DefaultModelsDirectory => _ioHelper.MapPath("~/App_Data/Models");
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ModelsBuilderConfig"/> class.
|
||||
/// </summary>
|
||||
public ModelsBuilderConfig()
|
||||
public ModelsBuilderConfig(IIOHelper ioHelper)
|
||||
{
|
||||
_ioHelper = ioHelper ?? throw new ArgumentNullException(nameof(ioHelper));
|
||||
const string prefix = "Umbraco.ModelsBuilder.";
|
||||
|
||||
// giant kill switch, default: false
|
||||
@@ -29,7 +32,7 @@ namespace Umbraco.ModelsBuilder.Embedded.Configuration
|
||||
|
||||
// ensure defaults are initialized for tests
|
||||
ModelsNamespace = DefaultModelsNamespace;
|
||||
ModelsDirectory = Current.IOHelper.MapPath(DefaultModelsDirectory);
|
||||
ModelsDirectory = DefaultModelsDirectory;
|
||||
DebugLevel = 0;
|
||||
|
||||
// stop here, everything is false
|
||||
@@ -101,7 +104,7 @@ namespace Umbraco.ModelsBuilder.Embedded.Configuration
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ModelsBuilderConfig"/> class.
|
||||
/// </summary>
|
||||
public ModelsBuilderConfig(
|
||||
public ModelsBuilderConfig(IIOHelper ioHelper,
|
||||
bool enable = false,
|
||||
ModelsMode modelsMode = ModelsMode.Nothing,
|
||||
string modelsNamespace = null,
|
||||
@@ -111,6 +114,7 @@ namespace Umbraco.ModelsBuilder.Embedded.Configuration
|
||||
bool acceptUnsafeModelsDirectory = false,
|
||||
int debugLevel = 0)
|
||||
{
|
||||
_ioHelper = ioHelper ?? throw new ArgumentNullException(nameof(ioHelper));
|
||||
Enable = enable;
|
||||
ModelsMode = modelsMode;
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Umbraco.Tests.Cache.DistributedCache
|
||||
{
|
||||
var register = TestHelper.GetRegister();
|
||||
|
||||
var composition = new Composition(register, TestHelper.GetMockedTypeLoader(), Mock.Of<IProfilingLogger>(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs());
|
||||
var composition = new Composition(register, TestHelper.GetMockedTypeLoader(), Mock.Of<IProfilingLogger>(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
|
||||
|
||||
composition.RegisterUnique<IServerRegistrar>(_ => new TestServerRegistrar());
|
||||
composition.RegisterUnique<IServerMessenger>(_ => new TestServerMessenger());
|
||||
|
||||
@@ -160,7 +160,8 @@ namespace Umbraco.Tests.Cache
|
||||
TestObjects.GetGlobalSettings(),
|
||||
new UrlProviderCollection(Enumerable.Empty<IUrlProvider>()),
|
||||
new MediaUrlProviderCollection(Enumerable.Empty<IMediaUrlProvider>()),
|
||||
Mock.Of<IUserService>());
|
||||
Mock.Of<IUserService>(),
|
||||
IOHelper);
|
||||
|
||||
// just assert it does not throw
|
||||
var refreshers = new DistributedCacheBinder(null, umbracoContextFactory, null);
|
||||
|
||||
@@ -7,7 +7,6 @@ using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Core.Hosting;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Tests.LegacyXmlPublishedCache;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
@@ -84,7 +83,8 @@ namespace Umbraco.Tests.Cache.PublishedCache
|
||||
Enumerable.Empty<IUrlProvider>(),
|
||||
Enumerable.Empty<IMediaUrlProvider>(),
|
||||
globalSettings,
|
||||
new TestVariationContextAccessor());
|
||||
new TestVariationContextAccessor(),
|
||||
IOHelper);
|
||||
|
||||
_cache = _umbracoContext.Content;
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ namespace Umbraco.Tests.Components
|
||||
public void Boot1A()
|
||||
{
|
||||
var register = MockRegister();
|
||||
var composition = new Composition(register, MockTypeLoader(), Mock.Of<IProfilingLogger>(), MockRuntimeState(RuntimeLevel.Unknown), TestHelper.GetConfigs());
|
||||
var composition = new Composition(register, MockTypeLoader(), Mock.Of<IProfilingLogger>(), MockRuntimeState(RuntimeLevel.Unknown), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
|
||||
|
||||
var types = TypeArray<Composer1, Composer2, Composer3, Composer4>();
|
||||
var composers = new Composers(composition, types, Mock.Of<IProfilingLogger>());
|
||||
@@ -110,7 +110,7 @@ namespace Umbraco.Tests.Components
|
||||
public void Boot1B()
|
||||
{
|
||||
var register = MockRegister();
|
||||
var composition = new Composition(register, MockTypeLoader(), Mock.Of<IProfilingLogger>(), MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs());
|
||||
var composition = new Composition(register, MockTypeLoader(), Mock.Of<IProfilingLogger>(), MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
|
||||
|
||||
var types = TypeArray<Composer1, Composer2, Composer3, Composer4>();
|
||||
var composers = new Composers(composition, types, Mock.Of<IProfilingLogger>());
|
||||
@@ -126,7 +126,7 @@ namespace Umbraco.Tests.Components
|
||||
public void Boot2()
|
||||
{
|
||||
var register = MockRegister();
|
||||
var composition = new Composition(register, MockTypeLoader(), Mock.Of<IProfilingLogger>(), MockRuntimeState(RuntimeLevel.Unknown), TestHelper.GetConfigs());
|
||||
var composition = new Composition(register, MockTypeLoader(), Mock.Of<IProfilingLogger>(), MockRuntimeState(RuntimeLevel.Unknown), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
|
||||
|
||||
var types = TypeArray<Composer20, Composer21>();
|
||||
var composers = new Composers(composition, types, Mock.Of<IProfilingLogger>());
|
||||
@@ -141,7 +141,7 @@ namespace Umbraco.Tests.Components
|
||||
public void Boot3()
|
||||
{
|
||||
var register = MockRegister();
|
||||
var composition = new Composition(register, MockTypeLoader(), Mock.Of<IProfilingLogger>(), MockRuntimeState(RuntimeLevel.Unknown), TestHelper.GetConfigs());
|
||||
var composition = new Composition(register, MockTypeLoader(), Mock.Of<IProfilingLogger>(), MockRuntimeState(RuntimeLevel.Unknown), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
|
||||
|
||||
var types = TypeArray<Composer22, Composer24, Composer25>();
|
||||
var composers = new Composers(composition, types, Mock.Of<IProfilingLogger>());
|
||||
@@ -158,7 +158,7 @@ namespace Umbraco.Tests.Components
|
||||
public void BrokenRequire()
|
||||
{
|
||||
var register = MockRegister();
|
||||
var composition = new Composition(register, MockTypeLoader(), Mock.Of<IProfilingLogger>(), MockRuntimeState(RuntimeLevel.Unknown), TestHelper.GetConfigs());
|
||||
var composition = new Composition(register, MockTypeLoader(), Mock.Of<IProfilingLogger>(), MockRuntimeState(RuntimeLevel.Unknown), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
|
||||
|
||||
var types = TypeArray<Composer1, Composer2, Composer3>();
|
||||
var composers = new Composers(composition, types, Mock.Of<IProfilingLogger>());
|
||||
@@ -181,7 +181,7 @@ namespace Umbraco.Tests.Components
|
||||
public void BrokenRequired()
|
||||
{
|
||||
var register = MockRegister();
|
||||
var composition = new Composition(register, MockTypeLoader(), Mock.Of<IProfilingLogger>(), MockRuntimeState(RuntimeLevel.Unknown), TestHelper.GetConfigs());
|
||||
var composition = new Composition(register, MockTypeLoader(), Mock.Of<IProfilingLogger>(), MockRuntimeState(RuntimeLevel.Unknown), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
|
||||
|
||||
var types = TypeArray<Composer2, Composer4, Composer13>();
|
||||
var composers = new Composers(composition, types, Mock.Of<IProfilingLogger>());
|
||||
@@ -216,7 +216,7 @@ namespace Umbraco.Tests.Components
|
||||
throw new NotSupportedException(type.FullName);
|
||||
});
|
||||
});
|
||||
var composition = new Composition(register, MockTypeLoader(), Mock.Of<IProfilingLogger>(), MockRuntimeState(RuntimeLevel.Unknown), TestHelper.GetConfigs());
|
||||
var composition = new Composition(register, MockTypeLoader(), Mock.Of<IProfilingLogger>(), MockRuntimeState(RuntimeLevel.Unknown), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
|
||||
|
||||
var types = new[] { typeof(Composer1), typeof(Composer5), typeof(Composer5a) };
|
||||
var composers = new Composers(composition, types, Mock.Of<IProfilingLogger>());
|
||||
@@ -242,7 +242,7 @@ namespace Umbraco.Tests.Components
|
||||
public void Requires1()
|
||||
{
|
||||
var register = MockRegister();
|
||||
var composition = new Composition(register, MockTypeLoader(), Mock.Of<IProfilingLogger>(), MockRuntimeState(RuntimeLevel.Unknown), TestHelper.GetConfigs());
|
||||
var composition = new Composition(register, MockTypeLoader(), Mock.Of<IProfilingLogger>(), MockRuntimeState(RuntimeLevel.Unknown), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
|
||||
|
||||
var types = new[] { typeof(Composer6), typeof(Composer7), typeof(Composer8) };
|
||||
var composers = new Composers(composition, types, Mock.Of<IProfilingLogger>());
|
||||
@@ -257,7 +257,7 @@ namespace Umbraco.Tests.Components
|
||||
public void Requires2A()
|
||||
{
|
||||
var register = MockRegister();
|
||||
var composition = new Composition(register, MockTypeLoader(), Mock.Of<IProfilingLogger>(), MockRuntimeState(RuntimeLevel.Unknown), Configs);
|
||||
var composition = new Composition(register, MockTypeLoader(), Mock.Of<IProfilingLogger>(), MockRuntimeState(RuntimeLevel.Unknown), Configs, TestHelper.IOHelper, AppCaches.NoCache);
|
||||
|
||||
var types = new[] { typeof(Composer9), typeof(Composer2), typeof(Composer4) };
|
||||
var composers = new Composers(composition, types, Mock.Of<IProfilingLogger>());
|
||||
@@ -274,7 +274,7 @@ namespace Umbraco.Tests.Components
|
||||
{
|
||||
var register = MockRegister();
|
||||
var factory = MockFactory();
|
||||
var composition = new Composition(register, MockTypeLoader(), Mock.Of<IProfilingLogger>(), MockRuntimeState(RuntimeLevel.Run), Configs);
|
||||
var composition = new Composition(register, MockTypeLoader(), Mock.Of<IProfilingLogger>(), MockRuntimeState(RuntimeLevel.Run), Configs, TestHelper.IOHelper, AppCaches.NoCache);
|
||||
|
||||
var types = new[] { typeof(Composer9), typeof(Composer2), typeof(Composer4) };
|
||||
var composers = new Composers(composition, types, Mock.Of<IProfilingLogger>());
|
||||
@@ -293,7 +293,7 @@ namespace Umbraco.Tests.Components
|
||||
public void WeakDependencies()
|
||||
{
|
||||
var register = MockRegister();
|
||||
var composition = new Composition(register, MockTypeLoader(), Mock.Of<IProfilingLogger>(), MockRuntimeState(RuntimeLevel.Unknown), Configs);
|
||||
var composition = new Composition(register, MockTypeLoader(), Mock.Of<IProfilingLogger>(), MockRuntimeState(RuntimeLevel.Unknown), Configs, TestHelper.IOHelper, AppCaches.NoCache);
|
||||
|
||||
var types = new[] { typeof(Composer10) };
|
||||
var composers = new Composers(composition, types, Mock.Of<IProfilingLogger>());
|
||||
@@ -332,7 +332,7 @@ namespace Umbraco.Tests.Components
|
||||
public void DisableMissing()
|
||||
{
|
||||
var register = MockRegister();
|
||||
var composition = new Composition(register, MockTypeLoader(), Mock.Of<IProfilingLogger>(), MockRuntimeState(RuntimeLevel.Unknown), Configs);
|
||||
var composition = new Composition(register, MockTypeLoader(), Mock.Of<IProfilingLogger>(), MockRuntimeState(RuntimeLevel.Unknown), Configs, TestHelper.IOHelper, AppCaches.NoCache);
|
||||
|
||||
var types = new[] { typeof(Composer6), typeof(Composer8) }; // 8 disables 7 which is not in the list
|
||||
var composers = new Composers(composition, types, Mock.Of<IProfilingLogger>());
|
||||
@@ -347,7 +347,7 @@ namespace Umbraco.Tests.Components
|
||||
public void AttributesPriorities()
|
||||
{
|
||||
var register = MockRegister();
|
||||
var composition = new Composition(register, MockTypeLoader(), Mock.Of<IProfilingLogger>(), MockRuntimeState(RuntimeLevel.Unknown), Configs);
|
||||
var composition = new Composition(register, MockTypeLoader(), Mock.Of<IProfilingLogger>(), MockRuntimeState(RuntimeLevel.Unknown), Configs, TestHelper.IOHelper, AppCaches.NoCache);
|
||||
|
||||
var types = new[] { typeof(Composer26) }; // 26 disabled by assembly attribute
|
||||
var composers = new Composers(composition, types, Mock.Of<IProfilingLogger>());
|
||||
@@ -372,7 +372,8 @@ namespace Umbraco.Tests.Components
|
||||
var typeLoader = new TypeLoader(ioHelper, typeFinder, AppCaches.Disabled.RuntimeCache, new DirectoryInfo(ioHelper.MapPath("~/App_Data/TEMP")), Mock.Of<IProfilingLogger>());
|
||||
|
||||
var register = MockRegister();
|
||||
var composition = new Composition(register, typeLoader, Mock.Of<IProfilingLogger>(), MockRuntimeState(RuntimeLevel.Run), Configs);
|
||||
var composition = new Composition(register, typeLoader, Mock.Of<IProfilingLogger>(),
|
||||
MockRuntimeState(RuntimeLevel.Run), Configs, TestHelper.IOHelper, AppCaches.NoCache);
|
||||
|
||||
var types = typeLoader.GetTypes<IComposer>().Where(x => x.FullName.StartsWith("Umbraco.Core.") || x.FullName.StartsWith("Umbraco.Web"));
|
||||
var composers = new Composers(composition, types, Mock.Of<IProfilingLogger>());
|
||||
|
||||
@@ -5,6 +5,7 @@ using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Tests.Components;
|
||||
@@ -23,7 +24,7 @@ namespace Umbraco.Tests.Composing
|
||||
Current.Reset();
|
||||
|
||||
var register = TestHelper.GetRegister();
|
||||
_composition = new Composition(register, TestHelper.GetMockedTypeLoader(), Mock.Of<IProfilingLogger>(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs());
|
||||
_composition = new Composition(register, TestHelper.GetMockedTypeLoader(), Mock.Of<IProfilingLogger>(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace Umbraco.Tests.Composing
|
||||
var typeFinder = new TypeFinder(Mock.Of<ILogger>());
|
||||
var ioHelper = TestHelper.IOHelper;
|
||||
var typeLoader = new TypeLoader(ioHelper, typeFinder, Mock.Of<IAppPolicyCache>(), new DirectoryInfo(ioHelper.MapPath("~/App_Data/TEMP")), logger);
|
||||
var composition = new Composition(mockedRegister, typeLoader, logger, Mock.Of<IRuntimeState>(), TestHelper.GetConfigs());
|
||||
var composition = new Composition(mockedRegister, typeLoader, logger, Mock.Of<IRuntimeState>(), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
|
||||
|
||||
// create the factory, ensure it is the mocked factory
|
||||
var factory = composition.CreateFactory();
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace Umbraco.Tests.Composing
|
||||
public void LazyCollectionBuilderHandlesTypes()
|
||||
{
|
||||
var container = CreateRegister();
|
||||
var composition = new Composition(container, TestHelper.GetMockedTypeLoader(), Mock.Of<IProfilingLogger>(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs());
|
||||
var composition = new Composition(container, TestHelper.GetMockedTypeLoader(), Mock.Of<IProfilingLogger>(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
|
||||
|
||||
composition.WithCollectionBuilder<TestCollectionBuilder>()
|
||||
.Add<TransientObject3>()
|
||||
@@ -67,7 +67,7 @@ namespace Umbraco.Tests.Composing
|
||||
public void LazyCollectionBuilderHandlesProducers()
|
||||
{
|
||||
var container = CreateRegister();
|
||||
var composition = new Composition(container, TestHelper.GetMockedTypeLoader(), Mock.Of<IProfilingLogger>(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs());
|
||||
var composition = new Composition(container, TestHelper.GetMockedTypeLoader(), Mock.Of<IProfilingLogger>(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
|
||||
|
||||
composition.WithCollectionBuilder<TestCollectionBuilder>()
|
||||
.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<IProfilingLogger>(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs());
|
||||
var composition = new Composition(container, TestHelper.GetMockedTypeLoader(), Mock.Of<IProfilingLogger>(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
|
||||
|
||||
composition.WithCollectionBuilder<TestCollectionBuilder>()
|
||||
.Add<TransientObject3>()
|
||||
@@ -118,7 +118,7 @@ namespace Umbraco.Tests.Composing
|
||||
public void LazyCollectionBuilderThrowsOnIllegalTypes()
|
||||
{
|
||||
var container = CreateRegister();
|
||||
var composition = new Composition(container, TestHelper.GetMockedTypeLoader(), Mock.Of<IProfilingLogger>(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs());
|
||||
var composition = new Composition(container, TestHelper.GetMockedTypeLoader(), Mock.Of<IProfilingLogger>(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
|
||||
|
||||
composition.WithCollectionBuilder<TestCollectionBuilder>()
|
||||
.Add<TransientObject3>()
|
||||
@@ -140,7 +140,7 @@ namespace Umbraco.Tests.Composing
|
||||
public void LazyCollectionBuilderCanExcludeTypes()
|
||||
{
|
||||
var container = CreateRegister();
|
||||
var composition = new Composition(container, TestHelper.GetMockedTypeLoader(), Mock.Of<IProfilingLogger>(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs());
|
||||
var composition = new Composition(container, TestHelper.GetMockedTypeLoader(), Mock.Of<IProfilingLogger>(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
|
||||
|
||||
composition.WithCollectionBuilder<TestCollectionBuilder>()
|
||||
.Add<TransientObject3>()
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Xml.Linq;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.PackageActions;
|
||||
@@ -21,7 +22,7 @@ namespace Umbraco.Tests.Composing
|
||||
{
|
||||
var container = TestHelper.GetRegister();
|
||||
|
||||
var composition = new Composition(container, TestHelper.GetMockedTypeLoader(), Mock.Of<IProfilingLogger>(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs());
|
||||
var composition = new Composition(container, TestHelper.GetMockedTypeLoader(), Mock.Of<IProfilingLogger>(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
|
||||
|
||||
composition.WithCollectionBuilder<PackageActionCollectionBuilder>()
|
||||
.Add(() => TypeLoader.GetPackageActions());
|
||||
|
||||
@@ -45,10 +45,11 @@ namespace Umbraco.Tests.CoreThings
|
||||
[TestCase("http://www.domain.com/umbraco/test/legacyAjaxCalls.ashx?some=query&blah=js", "", true)]
|
||||
public void Is_Back_Office_Request(string input, string virtualPath, bool expected)
|
||||
{
|
||||
Current.IOHelper.Root = virtualPath;
|
||||
var ioHelper = TestHelper.IOHelper;
|
||||
ioHelper.Root = virtualPath;
|
||||
var globalConfig = SettingsForTests.GenerateMockGlobalSettings();
|
||||
var source = new Uri(input);
|
||||
Assert.AreEqual(expected, source.IsBackOfficeRequest(virtualPath, globalConfig));
|
||||
Assert.AreEqual(expected, source.IsBackOfficeRequest(virtualPath, globalConfig, ioHelper));
|
||||
}
|
||||
|
||||
[TestCase("http://www.domain.com/install", true)]
|
||||
@@ -63,7 +64,7 @@ namespace Umbraco.Tests.CoreThings
|
||||
public void Is_Installer_Request(string input, bool expected)
|
||||
{
|
||||
var source = new Uri(input);
|
||||
Assert.AreEqual(expected, source.IsInstallerRequest());
|
||||
Assert.AreEqual(expected, source.IsInstallerRequest(TestHelper.IOHelper));
|
||||
}
|
||||
|
||||
[TestCase("http://www.domain.com/foo/bar", "/", "http://www.domain.com/")]
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Text;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.IO;
|
||||
@@ -13,6 +14,7 @@ using Umbraco.Core.Services;
|
||||
using Umbraco.Tests.Components;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Core.Composing.CompositionExtensions;
|
||||
using Umbraco.Core.Strings;
|
||||
using FileSystems = Umbraco.Core.IO.FileSystems;
|
||||
|
||||
namespace Umbraco.Tests.IO
|
||||
@@ -28,11 +30,12 @@ namespace Umbraco.Tests.IO
|
||||
{
|
||||
_register = TestHelper.GetRegister();
|
||||
|
||||
var composition = new Composition(_register, TestHelper.GetMockedTypeLoader(), Mock.Of<IProfilingLogger>(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs());
|
||||
var composition = new Composition(_register, TestHelper.GetMockedTypeLoader(), Mock.Of<IProfilingLogger>(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
|
||||
|
||||
composition.Register(_ => Mock.Of<ILogger>());
|
||||
composition.Register(_ => Mock.Of<IDataTypeService>());
|
||||
composition.Register(_ => Mock.Of<IContentSection>());
|
||||
composition.Register(_ => TestHelper.ShortStringHelper);
|
||||
composition.Register(_ => TestHelper.IOHelper);
|
||||
composition.RegisterUnique<IMediaPathScheme, UniqueMediaPathScheme>();
|
||||
composition.RegisterUnique(TestHelper.IOHelper);
|
||||
|
||||
@@ -4,6 +4,7 @@ using Umbraco.Core.IO;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Strings;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
|
||||
namespace Umbraco.Tests.IO
|
||||
@@ -30,35 +31,13 @@ namespace Umbraco.Tests.IO
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for MapPath verifying that HttpContext method (which includes vdirs) matches non-HttpContext method
|
||||
///</summary>
|
||||
[Test]
|
||||
public void IOHelper_MapPathTestVDirTraversal()
|
||||
{
|
||||
//System.Diagnostics.Debugger.Break();
|
||||
var globalSettings = SettingsForTests.GenerateMockGlobalSettings();
|
||||
|
||||
Assert.AreEqual(_ioHelper.MapPath(Constants.SystemDirectories.Bin, true), _ioHelper.MapPath(Constants.SystemDirectories.Bin, false));
|
||||
Assert.AreEqual(_ioHelper.MapPath(Constants.SystemDirectories.Config, true), _ioHelper.MapPath(Constants.SystemDirectories.Config, false));
|
||||
Assert.AreEqual(_ioHelper.MapPath(globalSettings.UmbracoCssPath, true), _ioHelper.MapPath(globalSettings.UmbracoCssPath, false));
|
||||
Assert.AreEqual(_ioHelper.MapPath(Constants.SystemDirectories.Data, true), _ioHelper.MapPath(Constants.SystemDirectories.Data, false));
|
||||
Assert.AreEqual(_ioHelper.MapPath(Constants.SystemDirectories.Install, true), _ioHelper.MapPath(Constants.SystemDirectories.Install, false));
|
||||
Assert.AreEqual(_ioHelper.MapPath(globalSettings.UmbracoMediaPath, true), _ioHelper.MapPath(globalSettings.UmbracoMediaPath, false));
|
||||
Assert.AreEqual(_ioHelper.MapPath(Constants.SystemDirectories.Packages, true), _ioHelper.MapPath(Constants.SystemDirectories.Packages, false));
|
||||
Assert.AreEqual(_ioHelper.MapPath(Constants.SystemDirectories.Preview, true), _ioHelper.MapPath(Constants.SystemDirectories.Preview, false));
|
||||
Assert.AreEqual(_ioHelper.MapPath(_ioHelper.Root, true), _ioHelper.MapPath(_ioHelper.Root, false));
|
||||
Assert.AreEqual(_ioHelper.MapPath(globalSettings.UmbracoScriptsPath, true), _ioHelper.MapPath(globalSettings.UmbracoScriptsPath, false));
|
||||
Assert.AreEqual(_ioHelper.MapPath(globalSettings.UmbracoPath, true), _ioHelper.MapPath(globalSettings.UmbracoPath, false));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EnsurePathIsApplicationRootPrefixed()
|
||||
{
|
||||
//Assert
|
||||
Assert.AreEqual("~/Views/Template.cshtml", "Views/Template.cshtml".EnsurePathIsApplicationRootPrefixed());
|
||||
Assert.AreEqual("~/Views/Template.cshtml", "/Views/Template.cshtml".EnsurePathIsApplicationRootPrefixed());
|
||||
Assert.AreEqual("~/Views/Template.cshtml", "~/Views/Template.cshtml".EnsurePathIsApplicationRootPrefixed());
|
||||
Assert.AreEqual("~/Views/Template.cshtml", PathUtility.EnsurePathIsApplicationRootPrefixed("Views/Template.cshtml"));
|
||||
Assert.AreEqual("~/Views/Template.cshtml", PathUtility.EnsurePathIsApplicationRootPrefixed("/Views/Template.cshtml"));
|
||||
Assert.AreEqual("~/Views/Template.cshtml", PathUtility.EnsurePathIsApplicationRootPrefixed("~/Views/Template.cshtml"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Umbraco.Tests.Macros
|
||||
//Current.ApplicationContext = new ApplicationContext(cacheHelper, new ProfilingLogger(Mock.Of<ILogger>(), Mock.Of<IProfiler>()));
|
||||
|
||||
Current.Reset();
|
||||
Current.UnlockConfigs(TestHelper.GetConfigsFactory());
|
||||
Current.UnlockConfigs(TestHelper.GetConfigsFactory(), TestHelper.IOHelper);
|
||||
Current.Configs.Add(SettingsForTests.GetDefaultUmbracoSettings);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ using Umbraco.Core.Models;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Services.Implement;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Tests.TestHelpers.Entities;
|
||||
using Umbraco.Tests.Testing;
|
||||
using Umbraco.Web.PropertyEditors;
|
||||
@@ -32,7 +33,7 @@ namespace Umbraco.Tests.Models
|
||||
Composition.Register(_ => Mock.Of<IContentSection>());
|
||||
|
||||
// all this is required so we can validate properties...
|
||||
var editor = new TextboxPropertyEditor(Mock.Of<ILogger>(), Mock.Of<IDataTypeService>(), Mock.Of<ILocalizationService>()) { Alias = "test" };
|
||||
var editor = new TextboxPropertyEditor(Mock.Of<ILogger>(), Mock.Of<IDataTypeService>(), Mock.Of<ILocalizationService>(), IOHelper) { Alias = "test" };
|
||||
Composition.Register(_ => new DataEditorCollection(new[] { editor }));
|
||||
Composition.Register<PropertyEditorCollection>();
|
||||
var dataType = Mock.Of<IDataType>();
|
||||
|
||||
@@ -19,6 +19,7 @@ using Umbraco.Core.PropertyEditors;
|
||||
using Umbraco.Core.Serialization;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Services.Implement;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Tests.TestHelpers.Entities;
|
||||
using Umbraco.Tests.TestHelpers.Stubs;
|
||||
using Umbraco.Tests.Testing;
|
||||
@@ -43,7 +44,7 @@ namespace Umbraco.Tests.Models
|
||||
Composition.Register(_ => Mock.Of<IContentSection>());
|
||||
|
||||
// all this is required so we can validate properties...
|
||||
var editor = new TextboxPropertyEditor(Mock.Of<ILogger>(), Mock.Of<IDataTypeService>(), Mock.Of<ILocalizationService>()) { Alias = "test" };
|
||||
var editor = new TextboxPropertyEditor(Mock.Of<ILogger>(), Mock.Of<IDataTypeService>(), Mock.Of<ILocalizationService>(), TestHelper.IOHelper) { Alias = "test" };
|
||||
Composition.Register(_ => new DataEditorCollection(new [] { editor }));
|
||||
Composition.Register<PropertyEditorCollection>();
|
||||
var dataType = Mock.Of<IDataType>();
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Umbraco.Tests.Models
|
||||
public void Init()
|
||||
{
|
||||
Current.Reset();
|
||||
Current.UnlockConfigs(TestHelper.GetConfigsFactory());
|
||||
Current.UnlockConfigs(TestHelper.GetConfigsFactory(), TestHelper.IOHelper);
|
||||
Current.Configs.Add(SettingsForTests.GetDefaultUmbracoSettings);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Tests.TestHelpers.Entities;
|
||||
using Umbraco.Tests.Testing;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
@@ -32,7 +33,7 @@ namespace Umbraco.Tests.Models.Mapping
|
||||
base.Compose();
|
||||
|
||||
// create and register a fake property editor collection to return fake property editors
|
||||
var editors = new DataEditor[] { new TextboxPropertyEditor(Mock.Of<ILogger>(), _dataTypeService.Object, _localizationService.Object), };
|
||||
var editors = new DataEditor[] { new TextboxPropertyEditor(Mock.Of<ILogger>(), _dataTypeService.Object, _localizationService.Object, IOHelper), };
|
||||
var dataEditors = new DataEditorCollection(editors);
|
||||
_editorsMock = new Mock<PropertyEditorCollection>(dataEditors);
|
||||
_editorsMock.Setup(x => x[It.IsAny<string>()]).Returns(editors[0]);
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Umbraco.Tests.Models.Mapping
|
||||
Composition.Register(_ => Mock.Of<IContentSection>());
|
||||
|
||||
// all this is required so we can validate properties...
|
||||
var editor = new TextboxPropertyEditor(Mock.Of<ILogger>(), Mock.Of<IDataTypeService>(), Mock.Of<ILocalizationService>()) { Alias = "test" };
|
||||
var editor = new TextboxPropertyEditor(Mock.Of<ILogger>(), Mock.Of<IDataTypeService>(), Mock.Of<ILocalizationService>(), IOHelper) { Alias = "test" };
|
||||
Composition.Register(_ => new DataEditorCollection(new[] { editor }));
|
||||
Composition.Register<PropertyEditorCollection>();
|
||||
var dataType = Mock.Of<IDataType>();
|
||||
|
||||
@@ -31,13 +31,13 @@ namespace Umbraco.Tests.Models
|
||||
// reference, so static ctor runs, so event handlers register
|
||||
// and then, this will reset the width, height... because the file does not exist, of course ;-(
|
||||
var logger = Mock.Of<ILogger>();
|
||||
var ioHelper = Mock.Of<IIOHelper>();
|
||||
var shortStringHelper = Mock.Of<IShortStringHelper>();
|
||||
var scheme = Mock.Of<IMediaPathScheme>();
|
||||
var config = Mock.Of<IContentSection>();
|
||||
var dataTypeService = Mock.Of<IDataTypeService>();
|
||||
var localizationService = Mock.Of<ILocalizationService>();
|
||||
|
||||
var mediaFileSystem = new MediaFileSystem(Mock.Of<IFileSystem>(), config, scheme, logger, ioHelper);
|
||||
var mediaFileSystem = new MediaFileSystem(Mock.Of<IFileSystem>(), scheme, logger, shortStringHelper);
|
||||
var ignored = new FileUploadPropertyEditor(Mock.Of<ILogger>(), mediaFileSystem, config, dataTypeService, localizationService);
|
||||
|
||||
var media = MockedMedia.CreateMediaImage(mediaType, -1);
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Umbraco.Tests.Models
|
||||
public void Setup()
|
||||
{
|
||||
Current.Reset();
|
||||
Current.UnlockConfigs(TestHelper.GetConfigsFactory());
|
||||
Current.UnlockConfigs(TestHelper.GetConfigsFactory(), TestHelper.IOHelper);
|
||||
Current.Configs.Add(SettingsForTests.GetDefaultGlobalSettings);
|
||||
Current.Configs.Add(SettingsForTests.GetDefaultUmbracoSettings);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Umbraco.Tests.Models
|
||||
public void Setup()
|
||||
{
|
||||
Current.Reset();
|
||||
Current.UnlockConfigs(TestHelper.GetConfigsFactory());
|
||||
Current.UnlockConfigs(TestHelper.GetConfigsFactory(), TestHelper.IOHelper);
|
||||
Current.Configs.Add(SettingsForTests.GetDefaultGlobalSettings);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Configuration;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.ModelsBuilder.Embedded.Configuration;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
|
||||
namespace Umbraco.Tests.ModelsBuilder
|
||||
{
|
||||
@@ -10,21 +11,21 @@ namespace Umbraco.Tests.ModelsBuilder
|
||||
[Test]
|
||||
public void Test1()
|
||||
{
|
||||
var config = new ModelsBuilderConfig(modelsNamespace: "test1");
|
||||
var config = new ModelsBuilderConfig(TestHelper.IOHelper, modelsNamespace: "test1");
|
||||
Assert.AreEqual("test1", config.ModelsNamespace);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test2()
|
||||
{
|
||||
var config = new ModelsBuilderConfig(modelsNamespace: "test2");
|
||||
var config = new ModelsBuilderConfig(TestHelper.IOHelper, modelsNamespace: "test2");
|
||||
Assert.AreEqual("test2", config.ModelsNamespace);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DefaultModelsNamespace()
|
||||
{
|
||||
var config = new ModelsBuilderConfig();
|
||||
var config = new ModelsBuilderConfig(TestHelper.IOHelper);
|
||||
Assert.AreEqual(ModelsBuilderConfig.DefaultModelsNamespace, config.ModelsNamespace);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ using NUnit.Framework;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Packaging;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
|
||||
namespace Umbraco.Tests.Packaging
|
||||
{
|
||||
@@ -16,7 +17,7 @@ namespace Umbraco.Tests.Packaging
|
||||
private static FileInfo GetTestPackagePath(string packageName)
|
||||
{
|
||||
const string testPackagesDirName = "Packaging\\Packages";
|
||||
string path = Path.Combine(Current.IOHelper.GetRootDirectorySafe(), testPackagesDirName, packageName);
|
||||
string path = Path.Combine(TestHelper.IOHelper.GetRootDirectorySafe(), testPackagesDirName, packageName);
|
||||
return new FileInfo(path);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,9 +36,9 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
using (provider.CreateScope())
|
||||
{
|
||||
var dtRepo = CreateRepository();
|
||||
IDataType dataType1 = new DataType(new RadioButtonsPropertyEditor(Logger, ServiceContext.TextService)) { Name = "dt1" };
|
||||
IDataType dataType1 = new DataType(new RadioButtonsPropertyEditor(Logger, ServiceContext.TextService, IOHelper)) { Name = "dt1" };
|
||||
dtRepo.Save(dataType1);
|
||||
IDataType dataType2 = new DataType(new RadioButtonsPropertyEditor(Logger, ServiceContext.TextService)) { Name = "dt2" };
|
||||
IDataType dataType2 = new DataType(new RadioButtonsPropertyEditor(Logger, ServiceContext.TextService, IOHelper)) { Name = "dt2" };
|
||||
dtRepo.Save(dataType2);
|
||||
|
||||
var ctRepo = Factory.GetInstance<IContentTypeRepository>();
|
||||
@@ -106,14 +106,14 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var container2 = new EntityContainer(Constants.ObjectTypes.DataType) { Name = "blah2", ParentId = container1.Id };
|
||||
containerRepository.Save(container2);
|
||||
|
||||
var dataType = (IDataType) new DataType(new RadioButtonsPropertyEditor(Logger, ServiceContext.TextService), container2.Id)
|
||||
var dataType = (IDataType) new DataType(new RadioButtonsPropertyEditor(Logger, ServiceContext.TextService, IOHelper), container2.Id)
|
||||
{
|
||||
Name = "dt1"
|
||||
};
|
||||
repository.Save(dataType);
|
||||
|
||||
//create a
|
||||
var dataType2 = (IDataType)new DataType(new RadioButtonsPropertyEditor(Logger, ServiceContext.TextService), dataType.Id)
|
||||
var dataType2 = (IDataType)new DataType(new RadioButtonsPropertyEditor(Logger, ServiceContext.TextService, IOHelper), dataType.Id)
|
||||
{
|
||||
Name = "dt2"
|
||||
};
|
||||
@@ -185,7 +185,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var container = new EntityContainer(Constants.ObjectTypes.DataType) { Name = "blah" };
|
||||
containerRepository.Save(container);
|
||||
|
||||
var dataTypeDefinition = new DataType(new RadioButtonsPropertyEditor(Logger, ServiceContext.TextService), container.Id) { Name = "test" };
|
||||
var dataTypeDefinition = new DataType(new RadioButtonsPropertyEditor(Logger, ServiceContext.TextService, IOHelper), container.Id) { Name = "test" };
|
||||
repository.Save(dataTypeDefinition);
|
||||
|
||||
Assert.AreEqual(container.Id, dataTypeDefinition.ParentId);
|
||||
@@ -205,7 +205,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var container = new EntityContainer(Constants.ObjectTypes.DataType) { Name = "blah" };
|
||||
containerRepository.Save(container);
|
||||
|
||||
IDataType dataType = new DataType(new RadioButtonsPropertyEditor(Logger, ServiceContext.TextService), container.Id) { Name = "test" };
|
||||
IDataType dataType = new DataType(new RadioButtonsPropertyEditor(Logger, ServiceContext.TextService, IOHelper), container.Id) { Name = "test" };
|
||||
repository.Save(dataType);
|
||||
|
||||
// Act
|
||||
@@ -228,7 +228,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
using (provider.CreateScope())
|
||||
{
|
||||
var repository = CreateRepository();
|
||||
IDataType dataType = new DataType(new RadioButtonsPropertyEditor(Logger, ServiceContext.TextService)) {Name = "test"};
|
||||
IDataType dataType = new DataType(new RadioButtonsPropertyEditor(Logger, ServiceContext.TextService, IOHelper)) {Name = "test"};
|
||||
|
||||
repository.Save(dataType);
|
||||
|
||||
@@ -349,7 +349,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
using (provider.CreateScope())
|
||||
{
|
||||
var repository = CreateRepository();
|
||||
var dataTypeDefinition = new DataType(new LabelPropertyEditor(Logger))
|
||||
var dataTypeDefinition = new DataType(new LabelPropertyEditor(Logger, IOHelper))
|
||||
{
|
||||
DatabaseType = ValueStorageType.Integer,
|
||||
Name = "AgeDataType",
|
||||
@@ -398,7 +398,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
// Act
|
||||
var definition = repository.Get(dataTypeDefinition.Id);
|
||||
definition.Name = "AgeDataType Updated";
|
||||
definition.Editor = new LabelPropertyEditor(Logger); //change
|
||||
definition.Editor = new LabelPropertyEditor(Logger, IOHelper); //change
|
||||
repository.Save(definition);
|
||||
|
||||
var definitionUpdated = repository.Get(dataTypeDefinition.Id);
|
||||
@@ -418,7 +418,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
using (provider.CreateScope())
|
||||
{
|
||||
var repository = CreateRepository();
|
||||
var dataTypeDefinition = new DataType(new LabelPropertyEditor(Logger))
|
||||
var dataTypeDefinition = new DataType(new LabelPropertyEditor(Logger, IOHelper))
|
||||
{
|
||||
DatabaseType = ValueStorageType.Integer,
|
||||
Name = "AgeDataType",
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
TemplateRepository tr;
|
||||
var ctRepository = CreateRepository(scopeAccessor, out contentTypeRepository, out tr);
|
||||
var editors = new PropertyEditorCollection(new DataEditorCollection(Enumerable.Empty<IDataEditor>()));
|
||||
dtdRepository = new DataTypeRepository(scopeAccessor, appCaches, new Lazy<PropertyEditorCollection>(() => editors), Logger);
|
||||
dtdRepository = new DataTypeRepository(scopeAccessor, appCaches, new Lazy<PropertyEditorCollection>(() => editors), Logger, TestHelper.IOHelper);
|
||||
return ctRepository;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ using NUnit.Framework;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Web.PropertyEditors;
|
||||
|
||||
namespace Umbraco.Tests.PropertyEditors
|
||||
@@ -15,7 +16,7 @@ namespace Umbraco.Tests.PropertyEditors
|
||||
public void Only_Tests_On_JArray()
|
||||
{
|
||||
var validator = new ColorPickerConfigurationEditor.ColorListValidator();
|
||||
var result = validator.Validate("hello", null, new ColorPickerPropertyEditor(Mock.Of<ILogger>()));
|
||||
var result = validator.Validate("hello", null, new ColorPickerPropertyEditor(Mock.Of<ILogger>(), TestHelper.IOHelper));
|
||||
Assert.AreEqual(0, result.Count());
|
||||
}
|
||||
|
||||
@@ -23,7 +24,7 @@ namespace Umbraco.Tests.PropertyEditors
|
||||
public void Only_Tests_On_JArray_Of_Item_JObject()
|
||||
{
|
||||
var validator = new ColorPickerConfigurationEditor.ColorListValidator();
|
||||
var result = validator.Validate(new JArray("hello", "world"), null, new ColorPickerPropertyEditor(Mock.Of<ILogger>()));
|
||||
var result = validator.Validate(new JArray("hello", "world"), null, new ColorPickerPropertyEditor(Mock.Of<ILogger>(), TestHelper.IOHelper));
|
||||
Assert.AreEqual(0, result.Count());
|
||||
}
|
||||
|
||||
@@ -36,7 +37,7 @@ namespace Umbraco.Tests.PropertyEditors
|
||||
JObject.FromObject(new { value = "zxcvzxcvxzcv" }),
|
||||
JObject.FromObject(new { value = "ABC" }),
|
||||
JObject.FromObject(new { value = "1234567" })),
|
||||
null, new ColorPickerPropertyEditor(Mock.Of<ILogger>()));
|
||||
null, new ColorPickerPropertyEditor(Mock.Of<ILogger>(), TestHelper.IOHelper));
|
||||
Assert.AreEqual(2, result.Count());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ using NUnit.Framework;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Web.PropertyEditors;
|
||||
|
||||
namespace Umbraco.Tests.PropertyEditors
|
||||
@@ -15,7 +16,7 @@ namespace Umbraco.Tests.PropertyEditors
|
||||
public void Only_Tests_On_JArray()
|
||||
{
|
||||
var validator = new ValueListUniqueValueValidator();
|
||||
var result = validator.Validate("hello", null, new ColorPickerPropertyEditor(Mock.Of<ILogger>()));
|
||||
var result = validator.Validate("hello", null, new ColorPickerPropertyEditor(Mock.Of<ILogger>(), TestHelper.IOHelper));
|
||||
Assert.AreEqual(0, result.Count());
|
||||
}
|
||||
|
||||
@@ -23,7 +24,7 @@ namespace Umbraco.Tests.PropertyEditors
|
||||
public void Only_Tests_On_JArray_Of_Item_JObject()
|
||||
{
|
||||
var validator = new ValueListUniqueValueValidator();
|
||||
var result = validator.Validate(new JArray("hello", "world"), null, new ColorPickerPropertyEditor(Mock.Of<ILogger>()));
|
||||
var result = validator.Validate(new JArray("hello", "world"), null, new ColorPickerPropertyEditor(Mock.Of<ILogger>(), TestHelper.IOHelper));
|
||||
Assert.AreEqual(0, result.Count());
|
||||
}
|
||||
|
||||
@@ -31,7 +32,7 @@ namespace Umbraco.Tests.PropertyEditors
|
||||
public void Allows_Unique_Values()
|
||||
{
|
||||
var validator = new ValueListUniqueValueValidator();
|
||||
var result = validator.Validate(new JArray(JObject.FromObject(new { value = "hello" }), JObject.FromObject(new { value = "world" })), null, new ColorPickerPropertyEditor(Mock.Of<ILogger>()));
|
||||
var result = validator.Validate(new JArray(JObject.FromObject(new { value = "hello" }), JObject.FromObject(new { value = "world" })), null, new ColorPickerPropertyEditor(Mock.Of<ILogger>(), TestHelper.IOHelper));
|
||||
Assert.AreEqual(0, result.Count());
|
||||
}
|
||||
|
||||
@@ -40,7 +41,7 @@ namespace Umbraco.Tests.PropertyEditors
|
||||
{
|
||||
var validator = new ValueListUniqueValueValidator();
|
||||
var result = validator.Validate(new JArray(JObject.FromObject(new { value = "hello" }), JObject.FromObject(new { value = "hello" })),
|
||||
null, new ColorPickerPropertyEditor(Mock.Of<ILogger>()));
|
||||
null, new ColorPickerPropertyEditor(Mock.Of<ILogger>(), TestHelper.IOHelper));
|
||||
Assert.AreEqual(1, result.Count());
|
||||
}
|
||||
|
||||
@@ -53,7 +54,7 @@ namespace Umbraco.Tests.PropertyEditors
|
||||
JObject.FromObject(new { value = "hello" }),
|
||||
JObject.FromObject(new { value = "world" }),
|
||||
JObject.FromObject(new { value = "world" })),
|
||||
null, new ColorPickerPropertyEditor(Mock.Of<ILogger>()));
|
||||
null, new ColorPickerPropertyEditor(Mock.Of<ILogger>(), TestHelper.IOHelper));
|
||||
Assert.AreEqual(2, result.Count());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ using Umbraco.Core.Models.PublishedContent;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
using Umbraco.Core.PropertyEditors.ValueConverters;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Strings;
|
||||
using Umbraco.Tests.Components;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Web.Models;
|
||||
@@ -71,7 +72,7 @@ namespace Umbraco.Tests.PropertyEditors
|
||||
try
|
||||
{
|
||||
var container = TestHelper.GetRegister();
|
||||
var composition = new Composition(container, TestHelper.GetMockedTypeLoader(), Mock.Of<IProfilingLogger>(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs());
|
||||
var composition = new Composition(container, TestHelper.GetMockedTypeLoader(), Mock.Of<IProfilingLogger>(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
|
||||
|
||||
composition.WithCollectionBuilder<PropertyValueConverterCollectionBuilder>();
|
||||
|
||||
@@ -79,13 +80,12 @@ namespace Umbraco.Tests.PropertyEditors
|
||||
|
||||
var logger = Mock.Of<ILogger>();
|
||||
var scheme = Mock.Of<IMediaPathScheme>();
|
||||
var config = Mock.Of<IContentSection>();
|
||||
var ioHelper = Mock.Of<IIOHelper>();
|
||||
var shortStringHelper = Mock.Of<IShortStringHelper>();
|
||||
|
||||
var mediaFileSystem = new MediaFileSystem(Mock.Of<IFileSystem>(), config, scheme, logger, ioHelper);
|
||||
var mediaFileSystem = new MediaFileSystem(Mock.Of<IFileSystem>(), scheme, logger, shortStringHelper);
|
||||
|
||||
var dataTypeService = new TestObjects.TestDataTypeService(
|
||||
new DataType(new ImageCropperPropertyEditor(Mock.Of<ILogger>(), mediaFileSystem, Mock.Of<IContentSection>(), Mock.Of<IDataTypeService>(), Mock.Of<ILocalizationService>())) { Id = 1 });
|
||||
new DataType(new ImageCropperPropertyEditor(Mock.Of<ILogger>(), mediaFileSystem, Mock.Of<IContentSection>(), Mock.Of<IDataTypeService>(), Mock.Of<ILocalizationService>(), TestHelper.IOHelper)) { Id = 1 });
|
||||
|
||||
var factory = new PublishedContentTypeFactory(Mock.Of<IPublishedModelFactory>(), new PropertyValueConverterCollection(Array.Empty<IPropertyValueConverter>()), dataTypeService);
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace Umbraco.Tests.PropertyEditors
|
||||
[Test]
|
||||
public void DropDownMultipleValueEditor_Format_Data_For_Cache()
|
||||
{
|
||||
var dataType = new DataType(new CheckBoxListPropertyEditor(Mock.Of<ILogger>(), Mock.Of<ILocalizedTextService>(), Mock.Of<IDataTypeService>(), Mock.Of<ILocalizationService>()))
|
||||
var dataType = new DataType(new CheckBoxListPropertyEditor(Mock.Of<ILogger>(), Mock.Of<ILocalizedTextService>(), Mock.Of<IDataTypeService>(), Mock.Of<ILocalizationService>(), TestHelper.IOHelper))
|
||||
{
|
||||
Configuration = new ValueListConfiguration
|
||||
{
|
||||
@@ -59,7 +59,7 @@ namespace Umbraco.Tests.PropertyEditors
|
||||
[Test]
|
||||
public void DropDownValueEditor_Format_Data_For_Cache()
|
||||
{
|
||||
var dataType = new DataType(new CheckBoxListPropertyEditor(Mock.Of<ILogger>(), Mock.Of<ILocalizedTextService>(), Mock.Of<IDataTypeService>(), Mock.Of<ILocalizationService>()))
|
||||
var dataType = new DataType(new CheckBoxListPropertyEditor(Mock.Of<ILogger>(), Mock.Of<ILocalizedTextService>(), Mock.Of<IDataTypeService>(), Mock.Of<ILocalizationService>(), TestHelper.IOHelper))
|
||||
{
|
||||
Configuration = new ValueListConfiguration
|
||||
{
|
||||
@@ -113,7 +113,7 @@ namespace Umbraco.Tests.PropertyEditors
|
||||
}
|
||||
};
|
||||
|
||||
var editor = new ValueListConfigurationEditor(Mock.Of<ILocalizedTextService>());
|
||||
var editor = new ValueListConfigurationEditor(Mock.Of<ILocalizedTextService>(), TestHelper.IOHelper);
|
||||
|
||||
var result = editor.ToConfigurationEditor(configuration);
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Threading;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models;
|
||||
@@ -24,7 +25,7 @@ namespace Umbraco.Tests.PropertyEditors
|
||||
Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;
|
||||
|
||||
var register = TestHelper.GetRegister();
|
||||
var composition = new Composition(register, TestHelper.GetMockedTypeLoader(), Mock.Of<IProfilingLogger>(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs());
|
||||
var composition = new Composition(register, TestHelper.GetMockedTypeLoader(), Mock.Of<IProfilingLogger>(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
|
||||
|
||||
register.Register<IShortStringHelper>(_
|
||||
=> new DefaultShortStringHelper(new DefaultShortStringHelperConfig().WithDefault(SettingsForTests.GetDefaultUmbracoSettings())));
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Linq;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models;
|
||||
@@ -178,7 +179,7 @@ namespace Umbraco.Tests.Published
|
||||
Current.Reset();
|
||||
var register = TestHelper.GetRegister();
|
||||
|
||||
var composition = new Composition(register, TestHelper.GetMockedTypeLoader(), Mock.Of<IProfilingLogger>(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs());
|
||||
var composition = new Composition(register, TestHelper.GetMockedTypeLoader(), Mock.Of<IProfilingLogger>(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
|
||||
|
||||
composition.WithCollectionBuilder<PropertyValueConverterCollectionBuilder>()
|
||||
.Append<SimpleConverter3A>()
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace Umbraco.Tests.Published
|
||||
var localizationService = Mock.Of<ILocalizationService>();
|
||||
|
||||
PropertyEditorCollection editors = null;
|
||||
var editor = new NestedContentPropertyEditor(logger, new Lazy<PropertyEditorCollection>(() => editors), Mock.Of<IDataTypeService>(), Mock.Of<IContentTypeService>(), localizationService);
|
||||
var editor = new NestedContentPropertyEditor(logger, new Lazy<PropertyEditorCollection>(() => editors), Mock.Of<IDataTypeService>(), Mock.Of<IContentTypeService>(), localizationService, TestHelper.IOHelper);
|
||||
editors = new PropertyEditorCollection(new DataEditorCollection(new DataEditor[] { editor }));
|
||||
|
||||
var dataType1 = new DataType(editor)
|
||||
@@ -66,7 +66,7 @@ namespace Umbraco.Tests.Published
|
||||
}
|
||||
};
|
||||
|
||||
var dataType3 = new DataType(new TextboxPropertyEditor(logger, Mock.Of<IDataTypeService>(), localizationService))
|
||||
var dataType3 = new DataType(new TextboxPropertyEditor(logger, Mock.Of<IDataTypeService>(), localizationService, TestHelper.IOHelper))
|
||||
{
|
||||
Id = 3
|
||||
};
|
||||
|
||||
@@ -76,7 +76,8 @@ namespace Umbraco.Tests.PublishedContent
|
||||
Enumerable.Empty<IUrlProvider>(),
|
||||
Enumerable.Empty<IMediaUrlProvider>(),
|
||||
globalSettings,
|
||||
new TestVariationContextAccessor());
|
||||
new TestVariationContextAccessor(),
|
||||
IOHelper);
|
||||
|
||||
return umbracoContext;
|
||||
}
|
||||
|
||||
@@ -53,7 +53,10 @@ namespace Umbraco.Tests.PublishedContent
|
||||
Mock.Of<IUmbracoContextAccessor>(),
|
||||
Mock.Of<IDataTypeService>(),
|
||||
Mock.Of<ILocalizationService>(),
|
||||
imageSourceParser, localLinkParser, pastedImages)) { Id = 1 });
|
||||
imageSourceParser,
|
||||
localLinkParser,
|
||||
pastedImages,
|
||||
IOHelper)) { Id = 1 });
|
||||
|
||||
|
||||
var publishedContentTypeFactory = new PublishedContentTypeFactory(Mock.Of<IPublishedModelFactory>(), converters, dataTypeService);
|
||||
|
||||
@@ -58,11 +58,11 @@ namespace Umbraco.Tests.PublishedContent
|
||||
|
||||
var dataTypeService = new TestObjects.TestDataTypeService(
|
||||
new DataType(new VoidEditor(logger)) { Id = 1 },
|
||||
new DataType(new TrueFalsePropertyEditor(logger)) { Id = 1001 },
|
||||
new DataType(new RichTextPropertyEditor(logger, mediaService, contentTypeBaseServiceProvider, umbracoContextAccessor, Mock.Of<IDataTypeService>(), localizationService, imageSourceParser, linkParser, pastedImages)) { Id = 1002 },
|
||||
new DataType(new TrueFalsePropertyEditor(logger, IOHelper)) { Id = 1001 },
|
||||
new DataType(new RichTextPropertyEditor(logger, mediaService, contentTypeBaseServiceProvider, umbracoContextAccessor, Mock.Of<IDataTypeService>(), localizationService, imageSourceParser, linkParser, pastedImages, IOHelper)) { Id = 1002 },
|
||||
new DataType(new IntegerPropertyEditor(logger)) { Id = 1003 },
|
||||
new DataType(new TextboxPropertyEditor(logger, Mock.Of<IDataTypeService>(), localizationService)) { Id = 1004 },
|
||||
new DataType(new MediaPickerPropertyEditor(logger, Mock.Of<IDataTypeService>(), localizationService)) { Id = 1005 });
|
||||
new DataType(new TextboxPropertyEditor(logger, Mock.Of<IDataTypeService>(), localizationService, IOHelper)) { Id = 1004 },
|
||||
new DataType(new MediaPickerPropertyEditor(logger, Mock.Of<IDataTypeService>(), localizationService, IOHelper)) { Id = 1005 });
|
||||
Composition.RegisterUnique<IDataTypeService>(f => dataTypeService);
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace Umbraco.Tests.Runtimes
|
||||
// test application
|
||||
public class TestUmbracoApplication : UmbracoApplicationBase
|
||||
{
|
||||
public TestUmbracoApplication() : base(_logger, _configs, _ioHelper, _profiler, new AspNetHostingEnvironment(_globalSettings, _ioHelper), new AspNetBackOfficeInfo(_globalSettings, _ioHelper, _settings, _logger))
|
||||
public TestUmbracoApplication() : base(_logger, _configs, _ioHelper, _profiler, new AspNetHostingEnvironment(_hostingSettings), new AspNetBackOfficeInfo(_globalSettings, _ioHelper, _settings, _logger))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -93,13 +93,15 @@ namespace Umbraco.Tests.Runtimes
|
||||
private static readonly IProfiler _profiler = new TestProfiler();
|
||||
private static readonly Configs _configs = GetConfigs();
|
||||
private static readonly IGlobalSettings _globalSettings = _configs.Global();
|
||||
private static readonly IHostingSettings _hostingSettings = _configs.Hosting();
|
||||
private static readonly IUmbracoSettingsSection _settings = _configs.Settings();
|
||||
|
||||
private static Configs GetConfigs()
|
||||
{
|
||||
var configs = new ConfigsFactory(_ioHelper).Create();
|
||||
var configs = new ConfigsFactory().Create(_ioHelper);
|
||||
configs.Add(SettingsForTests.GetDefaultGlobalSettings);
|
||||
configs.Add(SettingsForTests.GetDefaultUmbracoSettings);
|
||||
configs.Add(SettingsForTests.GetDefaultHostingSettings);
|
||||
return configs;
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace Umbraco.Tests.Runtimes
|
||||
|
||||
// create the register and the composition
|
||||
var register = TestHelper.GetRegister();
|
||||
var composition = new Composition(register, typeLoader, profilingLogger, runtimeState, configs);
|
||||
var composition = new Composition(register, typeLoader, profilingLogger, runtimeState, configs, ioHelper, appCaches);
|
||||
composition.RegisterEssentials(logger, profiler, profilingLogger, mainDom, appCaches, databaseFactory, typeLoader, runtimeState, typeFinder, ioHelper, umbracoVersion);
|
||||
|
||||
// create the core runtime and have it compose itself
|
||||
@@ -268,7 +268,7 @@ namespace Umbraco.Tests.Runtimes
|
||||
|
||||
// create the register and the composition
|
||||
var register = TestHelper.GetRegister();
|
||||
var composition = new Composition(register, typeLoader, profilingLogger, runtimeState, configs);
|
||||
var composition = new Composition(register, typeLoader, profilingLogger, runtimeState, configs, ioHelper, appCaches);
|
||||
var umbracoVersion = TestHelper.GetUmbracoVersion();
|
||||
composition.RegisterEssentials(logger, profiler, profilingLogger, mainDom, appCaches, databaseFactory, typeLoader, runtimeState, typeFinder, ioHelper, umbracoVersion);
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Web.Mvc;
|
||||
using NUnit.Framework;
|
||||
using NUnit.Framework.Internal;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Web.Mvc;
|
||||
using Umbraco.Web.Runtime;
|
||||
|
||||
@@ -14,7 +16,7 @@ namespace Umbraco.Tests.Runtimes
|
||||
{
|
||||
IList<IViewEngine> engines = new List<IViewEngine>
|
||||
{
|
||||
new RenderViewEngine(),
|
||||
new RenderViewEngine(TestHelper.IOHelper),
|
||||
new PluginViewEngine()
|
||||
};
|
||||
|
||||
@@ -30,7 +32,7 @@ namespace Umbraco.Tests.Runtimes
|
||||
{
|
||||
IList<IViewEngine> engines = new List<IViewEngine>
|
||||
{
|
||||
new RenderViewEngine(),
|
||||
new RenderViewEngine(TestHelper.IOHelper),
|
||||
new PluginViewEngine()
|
||||
};
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Linq;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Events;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.IO;
|
||||
@@ -32,7 +33,7 @@ namespace Umbraco.Tests.Scoping
|
||||
|
||||
var register = TestHelper.GetRegister();
|
||||
|
||||
var composition = new Composition(register, TestHelper.GetMockedTypeLoader(), Mock.Of<IProfilingLogger>(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs());
|
||||
var composition = new Composition(register, TestHelper.GetMockedTypeLoader(), Mock.Of<IProfilingLogger>(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
|
||||
|
||||
_testObjects = new TestObjects(register);
|
||||
|
||||
|
||||
@@ -123,7 +123,8 @@ namespace Umbraco.Tests.Scoping
|
||||
urlProviders ?? Enumerable.Empty<IUrlProvider>(),
|
||||
Enumerable.Empty<IMediaUrlProvider>(),
|
||||
globalSettings,
|
||||
new TestVariationContextAccessor());
|
||||
new TestVariationContextAccessor(),
|
||||
IOHelper);
|
||||
|
||||
if (setSingleton)
|
||||
Umbraco.Web.Composing.Current.UmbracoContextAccessor.UmbracoContext = umbracoContext;
|
||||
|
||||
@@ -9,6 +9,7 @@ using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Tests.Testing;
|
||||
using Umbraco.Tests.Testing.Objects.Accessors;
|
||||
using Umbraco.Web;
|
||||
@@ -35,11 +36,11 @@ namespace Umbraco.Tests.Security
|
||||
Mock.Of<IPublishedSnapshotService>(),
|
||||
new WebSecurity(Mock.Of<HttpContextBase>(), Current.Services.UserService, globalSettings),
|
||||
TestObjects.GetUmbracoSettings(), new List<IUrlProvider>(), Enumerable.Empty<IMediaUrlProvider>(), globalSettings,
|
||||
new TestVariationContextAccessor());
|
||||
new TestVariationContextAccessor(), IOHelper);
|
||||
|
||||
var runtime = Mock.Of<IRuntimeState>(x => x.Level == RuntimeLevel.Install);
|
||||
var mgr = new BackOfficeCookieManager(
|
||||
Mock.Of<IUmbracoContextAccessor>(accessor => accessor.UmbracoContext == umbracoContext), runtime, TestObjects.GetGlobalSettings());
|
||||
Mock.Of<IUmbracoContextAccessor>(accessor => accessor.UmbracoContext == umbracoContext), runtime, TestObjects.GetGlobalSettings(), TestHelper.IOHelper);
|
||||
|
||||
var result = mgr.ShouldAuthenticateRequest(Mock.Of<IOwinContext>(), new Uri("http://localhost/umbraco"));
|
||||
|
||||
@@ -55,10 +56,10 @@ namespace Umbraco.Tests.Security
|
||||
Mock.Of<IPublishedSnapshotService>(),
|
||||
new WebSecurity(Mock.Of<HttpContextBase>(), Current.Services.UserService, globalSettings),
|
||||
TestObjects.GetUmbracoSettings(), new List<IUrlProvider>(), Enumerable.Empty<IMediaUrlProvider>(), globalSettings,
|
||||
new TestVariationContextAccessor());
|
||||
new TestVariationContextAccessor(), IOHelper);
|
||||
|
||||
var runtime = Mock.Of<IRuntimeState>(x => x.Level == RuntimeLevel.Run);
|
||||
var mgr = new BackOfficeCookieManager(Mock.Of<IUmbracoContextAccessor>(accessor => accessor.UmbracoContext == umbCtx), runtime, TestObjects.GetGlobalSettings());
|
||||
var mgr = new BackOfficeCookieManager(Mock.Of<IUmbracoContextAccessor>(accessor => accessor.UmbracoContext == umbCtx), runtime, TestObjects.GetGlobalSettings(), TestHelper.IOHelper);
|
||||
|
||||
var request = new Mock<OwinRequest>();
|
||||
request.Setup(owinRequest => owinRequest.Uri).Returns(new Uri("http://localhost/umbraco"));
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
using System.Threading;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
using Umbraco.Tests.Testing;
|
||||
using Umbraco.Web.PropertyEditors;
|
||||
|
||||
namespace Umbraco.Tests.Services
|
||||
{
|
||||
@@ -25,7 +23,7 @@ namespace Umbraco.Tests.Services
|
||||
{
|
||||
var dataTypeService = ServiceContext.DataTypeService;
|
||||
|
||||
IDataType dataType = new DataType(new LabelPropertyEditor(Logger)) { Name = "Testing Textfield", DatabaseType = ValueStorageType.Ntext };
|
||||
IDataType dataType = new DataType(new LabelPropertyEditor(Logger, IOHelper)) { Name = "Testing Textfield", DatabaseType = ValueStorageType.Ntext };
|
||||
dataTypeService.Save(dataType);
|
||||
|
||||
//Get all the first time (no cache)
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Tests.Testing;
|
||||
using Umbraco.Web.PropertyEditors;
|
||||
|
||||
namespace Umbraco.Tests.Services
|
||||
{
|
||||
@@ -28,7 +24,7 @@ namespace Umbraco.Tests.Services
|
||||
var dataTypeService = ServiceContext.DataTypeService;
|
||||
|
||||
// Act
|
||||
IDataType dataType = new DataType(new LabelPropertyEditor(Logger)) { Name = "Testing Textfield", DatabaseType = ValueStorageType.Ntext };
|
||||
IDataType dataType = new DataType(new LabelPropertyEditor(Logger, IOHelper)) { Name = "Testing Textfield", DatabaseType = ValueStorageType.Ntext };
|
||||
dataTypeService.Save(dataType);
|
||||
|
||||
// Assert
|
||||
@@ -70,7 +66,7 @@ namespace Umbraco.Tests.Services
|
||||
var dataTypeService = ServiceContext.DataTypeService;
|
||||
|
||||
// Act
|
||||
var dataTypeDefinition = new DataType(new LabelPropertyEditor(Logger)) { Name = string.Empty, DatabaseType = ValueStorageType.Ntext };
|
||||
var dataTypeDefinition = new DataType(new LabelPropertyEditor(Logger, IOHelper)) { Name = string.Empty, DatabaseType = ValueStorageType.Ntext };
|
||||
|
||||
// Act & Assert
|
||||
Assert.Throws<ArgumentException>(() => dataTypeService.Save(dataTypeDefinition));
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace Umbraco.Tests.Strings
|
||||
[TestCase("/Test.js function(){return true;}", false)]
|
||||
public void Detect_Is_JavaScript_Path(string input, bool result)
|
||||
{
|
||||
var output = input.DetectIsJavaScriptPath();
|
||||
var output = input.DetectIsJavaScriptPath(IOHelper);
|
||||
Assert.AreEqual(result, output.Success);
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace Umbraco.Tests.TestHelpers
|
||||
logger,
|
||||
false);
|
||||
|
||||
var composition = new Composition(container, typeLoader, Mock.Of<IProfilingLogger>(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs());
|
||||
var composition = new Composition(container, typeLoader, Mock.Of<IProfilingLogger>(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
|
||||
|
||||
composition.RegisterUnique<ILogger>(_ => Mock.Of<ILogger>());
|
||||
composition.RegisterUnique<IProfiler>(_ => Mock.Of<IProfiler>());
|
||||
|
||||
@@ -142,7 +142,8 @@ namespace Umbraco.Tests.TestHelpers.ControllerTesting
|
||||
Enumerable.Empty<IUrlProvider>(),
|
||||
Enumerable.Empty<IMediaUrlProvider>(),
|
||||
globalSettings,
|
||||
new TestVariationContextAccessor());
|
||||
new TestVariationContextAccessor(),
|
||||
TestHelper.IOHelper);
|
||||
|
||||
//replace it
|
||||
umbracoContextAccessor.UmbracoContext = umbCtx;
|
||||
|
||||
@@ -21,7 +21,6 @@ namespace Umbraco.Tests.TestHelpers
|
||||
settings.Path == TestHelper.IOHelper.ResolveUrl("~/umbraco") &&
|
||||
settings.TimeOutInMinutes == 20 &&
|
||||
settings.DefaultUILanguage == "en" &&
|
||||
settings.LocalTempStorageLocation == LocalTempStorage.Default &&
|
||||
settings.ReservedPaths == (GlobalSettings.StaticReservedPaths + "~/umbraco") &&
|
||||
settings.ReservedUrls == GlobalSettings.StaticReservedUrls &&
|
||||
settings.UmbracoPath == "~/umbraco" &&
|
||||
@@ -116,6 +115,7 @@ namespace Umbraco.Tests.TestHelpers
|
||||
|
||||
private static IUmbracoSettingsSection _defaultUmbracoSettings;
|
||||
private static IGlobalSettings _defaultGlobalSettings;
|
||||
private static IHostingSettings _defaultHostingSettings;
|
||||
|
||||
internal static IGlobalSettings GetDefaultGlobalSettings()
|
||||
{
|
||||
@@ -126,6 +126,25 @@ namespace Umbraco.Tests.TestHelpers
|
||||
return _defaultGlobalSettings;
|
||||
}
|
||||
|
||||
internal static IHostingSettings GetDefaultHostingSettings()
|
||||
{
|
||||
if (_defaultHostingSettings == null)
|
||||
{
|
||||
_defaultHostingSettings = GenerateMockHostingSettings();
|
||||
}
|
||||
return _defaultHostingSettings;
|
||||
}
|
||||
|
||||
private static IHostingSettings GenerateMockHostingSettings()
|
||||
{
|
||||
var config = Mock.Of<IHostingSettings>(
|
||||
settings =>
|
||||
settings.LocalTempStorageLocation == LocalTempStorage.EnvironmentTemp &&
|
||||
settings.DebugMode == false
|
||||
);
|
||||
return config;
|
||||
}
|
||||
|
||||
internal static IUmbracoSettingsSection GetDefaultUmbracoSettings()
|
||||
{
|
||||
if (_defaultUmbracoSettings == null)
|
||||
|
||||
@@ -20,6 +20,7 @@ using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Entities;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Strings;
|
||||
using Umbraco.Core.Sync;
|
||||
using Umbraco.Net;
|
||||
using Umbraco.Web;
|
||||
@@ -41,7 +42,7 @@ namespace Umbraco.Tests.TestHelpers
|
||||
|
||||
public static Configs GetConfigs()
|
||||
{
|
||||
return GetConfigsFactory().Create();
|
||||
return GetConfigsFactory().Create(IOHelper);
|
||||
}
|
||||
public static IRuntimeState GetRuntimeState()
|
||||
{
|
||||
@@ -64,7 +65,7 @@ namespace Umbraco.Tests.TestHelpers
|
||||
|
||||
public static IConfigsFactory GetConfigsFactory()
|
||||
{
|
||||
return new ConfigsFactory(IOHelper);
|
||||
return new ConfigsFactory();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -82,7 +83,9 @@ namespace Umbraco.Tests.TestHelpers
|
||||
}
|
||||
}
|
||||
|
||||
public static IIOHelper IOHelper = new IOHelper();
|
||||
public static IShortStringHelper ShortStringHelper => new DefaultShortStringHelper(new DefaultShortStringHelperConfig());
|
||||
|
||||
public static IIOHelper IOHelper = new IOHelper(GetHostingEnvironment());
|
||||
|
||||
/// <summary>
|
||||
/// Maps the given <paramref name="relativePath"/> making it rooted on <see cref="CurrentAssemblyDirectory"/>. <paramref name="relativePath"/> must start with <code>~/</code>
|
||||
@@ -313,7 +316,7 @@ namespace Umbraco.Tests.TestHelpers
|
||||
|
||||
public static IHostingEnvironment GetHostingEnvironment()
|
||||
{
|
||||
return new AspNetHostingEnvironment(SettingsForTests.GetDefaultGlobalSettings(), TestHelper.IOHelper);
|
||||
return new AspNetHostingEnvironment(SettingsForTests.GetDefaultHostingSettings());
|
||||
}
|
||||
|
||||
public static IIpResolver GetIpResolver()
|
||||
|
||||
@@ -136,7 +136,8 @@ namespace Umbraco.Tests.TestHelpers
|
||||
globalSettings,
|
||||
urlProviders,
|
||||
mediaUrlProviders,
|
||||
Mock.Of<IUserService>());
|
||||
Mock.Of<IUserService>(),
|
||||
TestHelper.IOHelper);
|
||||
|
||||
return umbracoContextFactory.EnsureUmbracoContext(httpContext).UmbracoContext;
|
||||
}
|
||||
|
||||
@@ -108,9 +108,10 @@ namespace Umbraco.Tests.TestHelpers
|
||||
if (eventMessagesFactory == null) throw new ArgumentNullException(nameof(eventMessagesFactory));
|
||||
|
||||
var scheme = Mock.Of<IMediaPathScheme>();
|
||||
var config = Mock.Of<IContentSection>();
|
||||
|
||||
var mediaFileSystem = new MediaFileSystem(Mock.Of<IFileSystem>(), config, scheme, logger, ioHelper);
|
||||
var shortStringHelper = Mock.Of<IShortStringHelper>();
|
||||
|
||||
var mediaFileSystem = new MediaFileSystem(Mock.Of<IFileSystem>(), scheme, logger, shortStringHelper);
|
||||
|
||||
var externalLoginService = GetLazyService<IExternalLoginService>(factory, c => new ExternalLoginService(scopeProvider, logger, eventMessagesFactory, GetRepo<IExternalLoginRepository>(c)));
|
||||
var publicAccessService = GetLazyService<IPublicAccessService>(factory, c => new PublicAccessService(scopeProvider, logger, eventMessagesFactory, GetRepo<IPublicAccessRepository>(c)));
|
||||
|
||||
@@ -385,7 +385,8 @@ namespace Umbraco.Tests.TestHelpers
|
||||
urlProviders ?? Enumerable.Empty<IUrlProvider>(),
|
||||
mediaUrlProviders ?? Enumerable.Empty<IMediaUrlProvider>(),
|
||||
globalSettings ?? Factory.GetInstance<IGlobalSettings>(),
|
||||
new TestVariationContextAccessor());
|
||||
new TestVariationContextAccessor(),
|
||||
IOHelper);
|
||||
|
||||
if (setSingleton)
|
||||
Umbraco.Web.Composing.Current.UmbracoContextAccessor.UmbracoContext = umbracoContext;
|
||||
|
||||
@@ -25,13 +25,13 @@ namespace Umbraco.Tests.Testing.Objects
|
||||
if (umbracoContextAccessor == null) umbracoContextAccessor = new TestUmbracoContextAccessor();
|
||||
|
||||
var contentCache = new Mock<IPublishedContentCache>();
|
||||
var mediaCache = new Mock<IPublishedMediaCache>();
|
||||
var mediaCache = new Mock<IPublishedMediaCache>();
|
||||
var snapshot = new Mock<IPublishedSnapshot>();
|
||||
snapshot.Setup(x => x.Content).Returns(contentCache.Object);
|
||||
snapshot.Setup(x => x.Media).Returns(mediaCache.Object);
|
||||
var snapshotService = new Mock<IPublishedSnapshotService>();
|
||||
snapshotService.Setup(x => x.CreatePublishedSnapshot(It.IsAny<string>())).Returns(snapshot.Object);
|
||||
|
||||
snapshotService.Setup(x => x.CreatePublishedSnapshot(It.IsAny<string>())).Returns(snapshot.Object);
|
||||
|
||||
var umbracoContextFactory = new UmbracoContextFactory(
|
||||
umbracoContextAccessor,
|
||||
snapshotService.Object,
|
||||
@@ -41,7 +41,8 @@ namespace Umbraco.Tests.Testing.Objects
|
||||
globalSettings,
|
||||
new UrlProviderCollection(new[] { urlProvider }),
|
||||
new MediaUrlProviderCollection(new[] { mediaUrlProvider }),
|
||||
Mock.Of<IUserService>());
|
||||
Mock.Of<IUserService>(),
|
||||
TestHelper.IOHelper);
|
||||
|
||||
return umbracoContextFactory;
|
||||
}
|
||||
|
||||
@@ -106,6 +106,7 @@ namespace Umbraco.Tests.Testing
|
||||
protected ILogger Logger => Factory.GetInstance<ILogger>();
|
||||
|
||||
protected IIOHelper IOHelper { get; private set; }
|
||||
protected IShortStringHelper ShortStringHelper { get; private set; }
|
||||
protected IUmbracoVersion UmbracoVersion { get; private set; }
|
||||
|
||||
protected ITypeFinder TypeFinder { get; private set; }
|
||||
@@ -145,12 +146,14 @@ namespace Umbraco.Tests.Testing
|
||||
var (logger, profiler) = GetLoggers(Options.Logger);
|
||||
var proflogger = new ProfilingLogger(logger, profiler);
|
||||
IOHelper = TestHelper.IOHelper;
|
||||
ShortStringHelper = TestHelper.ShortStringHelper;
|
||||
|
||||
TypeFinder = new TypeFinder(logger);
|
||||
var appCaches = GetAppCaches();
|
||||
var globalSettings = SettingsForTests.GetDefaultGlobalSettings();
|
||||
var hostingSettings = SettingsForTests.GetDefaultHostingSettings();
|
||||
var settings = SettingsForTests.GetDefaultUmbracoSettings();
|
||||
IHostingEnvironment hostingEnvironment = new AspNetHostingEnvironment(globalSettings, IOHelper);
|
||||
IHostingEnvironment hostingEnvironment = new AspNetHostingEnvironment(hostingSettings);
|
||||
IBackOfficeInfo backOfficeInfo = new AspNetBackOfficeInfo(globalSettings, IOHelper, settings, logger);
|
||||
IIpResolver ipResolver = new AspNetIpResolver();
|
||||
UmbracoVersion = new UmbracoVersion(globalSettings);
|
||||
@@ -158,9 +161,10 @@ namespace Umbraco.Tests.Testing
|
||||
|
||||
var register = TestHelper.GetRegister();
|
||||
|
||||
Composition = new Composition(register, typeLoader, proflogger, ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs());
|
||||
Composition = new Composition(register, typeLoader, proflogger, ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
|
||||
|
||||
|
||||
Composition.RegisterUnique(ShortStringHelper);
|
||||
Composition.RegisterUnique(IOHelper);
|
||||
Composition.RegisterUnique(UmbracoVersion);
|
||||
Composition.RegisterUnique(TypeFinder);
|
||||
@@ -347,6 +351,7 @@ namespace Umbraco.Tests.Testing
|
||||
{
|
||||
Composition.Configs.Add(SettingsForTests.GetDefaultUmbracoSettings);
|
||||
Composition.Configs.Add(SettingsForTests.GetDefaultGlobalSettings);
|
||||
Composition.Configs.Add(SettingsForTests.GetDefaultHostingSettings);
|
||||
//Composition.Configs.Add<IUserPasswordConfiguration>(() => new DefaultUserPasswordConfig());
|
||||
}
|
||||
|
||||
@@ -372,10 +377,8 @@ namespace Umbraco.Tests.Testing
|
||||
|
||||
var logger = Mock.Of<ILogger>();
|
||||
var scheme = Mock.Of<IMediaPathScheme>();
|
||||
var config = Mock.Of<IContentSection>();
|
||||
var ioHelper = Mock.Of<IIOHelper>();
|
||||
|
||||
var mediaFileSystem = new MediaFileSystem(Mock.Of<IFileSystem>(), config, scheme, logger, ioHelper);
|
||||
var mediaFileSystem = new MediaFileSystem(Mock.Of<IFileSystem>(), scheme, logger, ShortStringHelper);
|
||||
Composition.RegisterUnique<IMediaFileSystem>(factory => mediaFileSystem);
|
||||
|
||||
// no factory (noop)
|
||||
|
||||
@@ -71,7 +71,7 @@ namespace Umbraco.Tests.Web.Controllers
|
||||
}
|
||||
else
|
||||
{
|
||||
var baseDir = IOHelper.MapPath("", false).TrimEnd(IOHelper.DirSepChar);
|
||||
var baseDir = IOHelper.MapPath("").TrimEnd(IOHelper.DirSepChar);
|
||||
HttpContext.Current = new HttpContext(new SimpleWorkerRequest("/", baseDir, "", "", new StringWriter()));
|
||||
}
|
||||
IOHelper.ForceNotHosted = true;
|
||||
|
||||
@@ -73,7 +73,8 @@ namespace Umbraco.Tests.Web.Mvc
|
||||
globalSettings,
|
||||
new UrlProviderCollection(Enumerable.Empty<IUrlProvider>()),
|
||||
new MediaUrlProviderCollection(Enumerable.Empty<IMediaUrlProvider>()),
|
||||
Mock.Of<IUserService>());
|
||||
Mock.Of<IUserService>(),
|
||||
TestHelper.IOHelper);
|
||||
|
||||
var umbracoContextReference = umbracoContextFactory.EnsureUmbracoContext(Mock.Of<HttpContextBase>());
|
||||
var umbCtx = umbracoContextReference.UmbracoContext;
|
||||
@@ -103,7 +104,8 @@ namespace Umbraco.Tests.Web.Mvc
|
||||
globalSettings,
|
||||
new UrlProviderCollection(Enumerable.Empty<IUrlProvider>()),
|
||||
new MediaUrlProviderCollection(Enumerable.Empty<IMediaUrlProvider>()),
|
||||
Mock.Of<IUserService>());
|
||||
Mock.Of<IUserService>(),
|
||||
TestHelper.IOHelper);
|
||||
|
||||
var umbracoContextReference = umbracoContextFactory.EnsureUmbracoContext(Mock.Of<HttpContextBase>());
|
||||
var umbCtx = umbracoContextReference.UmbracoContext;
|
||||
@@ -133,7 +135,8 @@ namespace Umbraco.Tests.Web.Mvc
|
||||
globalSettings,
|
||||
new UrlProviderCollection(Enumerable.Empty<IUrlProvider>()),
|
||||
new MediaUrlProviderCollection(Enumerable.Empty<IMediaUrlProvider>()),
|
||||
Mock.Of<IUserService>());
|
||||
Mock.Of<IUserService>(),
|
||||
TestHelper.IOHelper);
|
||||
|
||||
var umbracoContextReference = umbracoContextFactory.EnsureUmbracoContext(Mock.Of<HttpContextBase>());
|
||||
var umbCtx = umbracoContextReference.UmbracoContext;
|
||||
@@ -163,7 +166,8 @@ namespace Umbraco.Tests.Web.Mvc
|
||||
globalSettings,
|
||||
new UrlProviderCollection(Enumerable.Empty<IUrlProvider>()),
|
||||
new MediaUrlProviderCollection(Enumerable.Empty<IMediaUrlProvider>()),
|
||||
Mock.Of<IUserService>());
|
||||
Mock.Of<IUserService>(),
|
||||
TestHelper.IOHelper);
|
||||
|
||||
var umbracoContextReference = umbracoContextFactory.EnsureUmbracoContext(Mock.Of<HttpContextBase>());
|
||||
var umbCtx = umbracoContextReference.UmbracoContext;
|
||||
|
||||
@@ -49,7 +49,8 @@ namespace Umbraco.Tests.Web.Mvc
|
||||
globalSettings,
|
||||
new UrlProviderCollection(Enumerable.Empty<IUrlProvider>()),
|
||||
new MediaUrlProviderCollection(Enumerable.Empty<IMediaUrlProvider>()),
|
||||
Mock.Of<IUserService>());
|
||||
Mock.Of<IUserService>(),
|
||||
IOHelper);
|
||||
|
||||
var umbracoContextReference = umbracoContextFactory.EnsureUmbracoContext(Mock.Of<HttpContextBase>());
|
||||
var umbracoContext = umbracoContextReference.UmbracoContext;
|
||||
@@ -77,7 +78,8 @@ namespace Umbraco.Tests.Web.Mvc
|
||||
globalSettings,
|
||||
new UrlProviderCollection(Enumerable.Empty<IUrlProvider>()),
|
||||
new MediaUrlProviderCollection(Enumerable.Empty<IMediaUrlProvider>()),
|
||||
Mock.Of<IUserService>());
|
||||
Mock.Of<IUserService>(),
|
||||
IOHelper);
|
||||
|
||||
var umbracoContextReference = umbracoContextFactory.EnsureUmbracoContext(Mock.Of<HttpContextBase>());
|
||||
var umbCtx = umbracoContextReference.UmbracoContext;
|
||||
@@ -108,7 +110,8 @@ namespace Umbraco.Tests.Web.Mvc
|
||||
globalSettings,
|
||||
new UrlProviderCollection(Enumerable.Empty<IUrlProvider>()),
|
||||
new MediaUrlProviderCollection(Enumerable.Empty<IMediaUrlProvider>()),
|
||||
Mock.Of<IUserService>());
|
||||
Mock.Of<IUserService>(),
|
||||
IOHelper);
|
||||
|
||||
var umbracoContextReference = umbracoContextFactory.EnsureUmbracoContext(Mock.Of<HttpContextBase>());
|
||||
var umbracoContext = umbracoContextReference.UmbracoContext;
|
||||
@@ -146,7 +149,8 @@ namespace Umbraco.Tests.Web.Mvc
|
||||
globalSettings,
|
||||
new UrlProviderCollection(Enumerable.Empty<IUrlProvider>()),
|
||||
new MediaUrlProviderCollection(Enumerable.Empty<IMediaUrlProvider>()),
|
||||
Mock.Of<IUserService>());
|
||||
Mock.Of<IUserService>(),
|
||||
IOHelper);
|
||||
|
||||
var umbracoContextReference = umbracoContextFactory.EnsureUmbracoContext(Mock.Of<HttpContextBase>());
|
||||
var umbracoContext = umbracoContextReference.UmbracoContext;
|
||||
|
||||
@@ -444,7 +444,8 @@ namespace Umbraco.Tests.Web.Mvc
|
||||
Enumerable.Empty<IUrlProvider>(),
|
||||
Enumerable.Empty<IMediaUrlProvider>(),
|
||||
globalSettings,
|
||||
new TestVariationContextAccessor());
|
||||
new TestVariationContextAccessor(),
|
||||
IOHelper);
|
||||
|
||||
//if (setSingleton)
|
||||
//{
|
||||
|
||||
@@ -34,7 +34,8 @@ namespace Umbraco.Tests.Web
|
||||
new List<IUrlProvider>(),
|
||||
Enumerable.Empty<IMediaUrlProvider>(),
|
||||
TestObjects.GetGlobalSettings(),
|
||||
new TestVariationContextAccessor());
|
||||
new TestVariationContextAccessor(),
|
||||
IOHelper);
|
||||
var r1 = new RouteData();
|
||||
r1.DataTokens.Add(Core.Constants.Web.UmbracoContextDataToken, umbCtx);
|
||||
|
||||
@@ -53,7 +54,8 @@ namespace Umbraco.Tests.Web
|
||||
new List<IUrlProvider>(),
|
||||
Enumerable.Empty<IMediaUrlProvider>(),
|
||||
TestObjects.GetGlobalSettings(),
|
||||
new TestVariationContextAccessor());
|
||||
new TestVariationContextAccessor(),
|
||||
IOHelper);
|
||||
|
||||
var r1 = new RouteData();
|
||||
r1.DataTokens.Add(Core.Constants.Web.UmbracoContextDataToken, umbCtx);
|
||||
@@ -82,7 +84,8 @@ namespace Umbraco.Tests.Web
|
||||
new List<IUrlProvider>(),
|
||||
Enumerable.Empty<IMediaUrlProvider>(),
|
||||
TestObjects.GetGlobalSettings(),
|
||||
new TestVariationContextAccessor());
|
||||
new TestVariationContextAccessor(),
|
||||
IOHelper);
|
||||
|
||||
var httpContext = Mock.Of<HttpContextBase>();
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ using System.Web.Compilation;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Core.Hosting;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Logging;
|
||||
|
||||
@@ -24,15 +25,16 @@ namespace Umbraco.Web.Composing
|
||||
/// </remarks>
|
||||
internal class BuildManagerTypeFinder : TypeFinder, ITypeFinder
|
||||
{
|
||||
|
||||
public BuildManagerTypeFinder(IIOHelper ioHelper, ILogger logger, ITypeFinderConfig typeFinderConfig = null) : base(logger, typeFinderConfig)
|
||||
|
||||
public BuildManagerTypeFinder(IIOHelper ioHelper, IHostingEnvironment hostingEnvironment, ILogger logger, ITypeFinderConfig typeFinderConfig = null) : base(logger, typeFinderConfig)
|
||||
{
|
||||
if (ioHelper == null) throw new ArgumentNullException(nameof(ioHelper));
|
||||
if (hostingEnvironment == null) throw new ArgumentNullException(nameof(hostingEnvironment));
|
||||
if (logger == null) throw new ArgumentNullException(nameof(logger));
|
||||
|
||||
_allAssemblies = new Lazy<HashSet<Assembly>>(() =>
|
||||
{
|
||||
var isHosted = ioHelper.IsHosted;
|
||||
var isHosted = hostingEnvironment.IsHosted;
|
||||
try
|
||||
{
|
||||
if (isHosted)
|
||||
|
||||
@@ -10,21 +10,16 @@ namespace Umbraco.Web.Hosting
|
||||
{
|
||||
public class AspNetHostingEnvironment : IHostingEnvironment
|
||||
{
|
||||
private readonly IGlobalSettings _globalSettings;
|
||||
private readonly IIOHelper _ioHelper;
|
||||
private readonly IHostingSettings _hostingSettings;
|
||||
private string _localTempPath;
|
||||
|
||||
public AspNetHostingEnvironment(IGlobalSettings globalSettings, IIOHelper ioHelper)
|
||||
public AspNetHostingEnvironment(IHostingSettings hostingSettings)
|
||||
{
|
||||
_globalSettings = globalSettings ?? throw new ArgumentNullException(nameof(globalSettings));
|
||||
_ioHelper = ioHelper ?? throw new ArgumentNullException(nameof(ioHelper));
|
||||
|
||||
_hostingSettings = hostingSettings ?? throw new ArgumentNullException(nameof(hostingSettings));
|
||||
SiteName = HostingEnvironment.SiteName;
|
||||
ApplicationId = HostingEnvironment.ApplicationID;
|
||||
ApplicationPhysicalPath = HostingEnvironment.ApplicationPhysicalPath;
|
||||
ApplicationVirtualPath = HostingEnvironment.ApplicationVirtualPath;
|
||||
|
||||
IsDebugMode = HttpContext.Current?.IsDebuggingEnabled ?? globalSettings.DebugMode;
|
||||
}
|
||||
|
||||
public string SiteName { get; }
|
||||
@@ -32,9 +27,20 @@ namespace Umbraco.Web.Hosting
|
||||
public string ApplicationPhysicalPath { get; }
|
||||
|
||||
public string ApplicationVirtualPath { get; }
|
||||
public bool IsDebugMode { get; }
|
||||
public bool IsHosted => HostingEnvironment.IsHosted;
|
||||
public string MapPath(string path) => HostingEnvironment.MapPath(path);
|
||||
public bool IsDebugMode => HttpContext.Current?.IsDebuggingEnabled ?? _hostingSettings.DebugMode;
|
||||
/// <inheritdoc/>
|
||||
public bool IsHosted => (HttpContext.Current != null || HostingEnvironment.IsHosted);
|
||||
public string MapPath(string path)
|
||||
{
|
||||
return HostingEnvironment.MapPath(path);
|
||||
}
|
||||
|
||||
public string ToAbsolute(string virtualPath, string root) => VirtualPathUtility.ToAbsolute(virtualPath, root);
|
||||
public void LazyRestartApplication()
|
||||
{
|
||||
HttpRuntime.UnloadAppDomain();
|
||||
}
|
||||
|
||||
|
||||
public string LocalTempPath
|
||||
{
|
||||
@@ -43,7 +49,7 @@ namespace Umbraco.Web.Hosting
|
||||
if (_localTempPath != null)
|
||||
return _localTempPath;
|
||||
|
||||
switch (_globalSettings.LocalTempStorageLocation)
|
||||
switch (_hostingSettings.LocalTempStorageLocation)
|
||||
{
|
||||
case LocalTempStorage.AspNetTemp:
|
||||
return _localTempPath = System.IO.Path.Combine(HttpRuntime.CodegenDir, "UmbracoData");
|
||||
@@ -69,7 +75,7 @@ namespace Umbraco.Web.Hosting
|
||||
//case LocalTempStorage.Default:
|
||||
//case LocalTempStorage.Unknown:
|
||||
default:
|
||||
return _localTempPath = _ioHelper.MapPath("~/App_Data/TEMP");
|
||||
return _localTempPath = MapPath("~/App_Data/TEMP");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ namespace Umbraco.Web.Mvc
|
||||
/// </summary>
|
||||
public class RenderViewEngine : RazorViewEngine
|
||||
{
|
||||
private readonly IIOHelper _ioHelper;
|
||||
|
||||
private readonly IEnumerable<string> _supplementedViewLocations = new[] { "/{0}.cshtml" };
|
||||
//NOTE: we will make the main view location the last to be searched since if it is the first to be searched and there is both a view and a partial
|
||||
// view in both locations and the main view is rendering a partial view with the same name, we will get a stack overflow exception.
|
||||
@@ -24,8 +26,10 @@ namespace Umbraco.Web.Mvc
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
public RenderViewEngine()
|
||||
public RenderViewEngine(IIOHelper ioHelper)
|
||||
{
|
||||
_ioHelper = ioHelper ?? throw new ArgumentNullException(nameof(ioHelper));
|
||||
|
||||
const string templateFolder = Constants.ViewLocation;
|
||||
|
||||
// the Render view engine doesn't support Area's so make those blank
|
||||
@@ -41,9 +45,9 @@ namespace Umbraco.Web.Mvc
|
||||
/// <summary>
|
||||
/// Ensures that the correct web.config for razor exists in the /Views folder, the partials folder exist and the ViewStartPage exists.
|
||||
/// </summary>
|
||||
private static void EnsureFoldersAndFiles()
|
||||
private void EnsureFoldersAndFiles()
|
||||
{
|
||||
var viewFolder = Current.IOHelper.MapPath(Constants.ViewLocation);
|
||||
var viewFolder = _ioHelper.MapPath(Constants.ViewLocation);
|
||||
|
||||
// ensure the web.config file is in the ~/Views folder
|
||||
Directory.CreateDirectory(viewFolder);
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
using System.Web.WebPages;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
|
||||
namespace Umbraco.Web.Mvc
|
||||
{
|
||||
public abstract class UmbracoViewPage : UmbracoViewPage<IPublishedContent>
|
||||
{ }
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user