Let IOHelper use IHostingEnvironment

This commit is contained in:
Bjarke Berg
2019-12-04 14:03:39 +01:00
parent d2bf64195e
commit 28ecb355dd
134 changed files with 697 additions and 352 deletions
@@ -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>
@@ -10,7 +10,11 @@ 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);
}
}
-5
View File
@@ -6,11 +6,6 @@ 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);
+1 -1
View File
@@ -208,7 +208,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>();
+23 -16
View File
@@ -4,13 +4,19 @@ using System.Globalization;
using System.Reflection;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Hosting;
using Umbraco.Core.Hosting;
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 +28,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 +59,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 +70,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)
{
@@ -79,7 +81,7 @@ namespace Umbraco.Core.IO
public string MapPath(string path, bool useHttpContext)
{
if (path == null) throw new ArgumentNullException("path");
useHttpContext = useHttpContext && IsHosted;
useHttpContext = useHttpContext && _hostingEnvironment.IsHosted;
// 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 (useHttpContext && _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;
@@ -294,7 +301,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;
+4 -2
View File
@@ -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<IFactory> _factoryGetter;
public HttpRequestIdEnricher(Func<IFactory> factoryGetter)
{
_factoryGetter = factoryGetter;
}
/// <summary>
/// The property name added to enriched log events.
/// </summary>
@@ -25,12 +34,17 @@ namespace Umbraco.Core.Logging.Serilog.Enrichers
{
if (logEvent == null) throw new ArgumentNullException("logEvent");
var factory = _factoryGetter();
if(factory is null) return;
var requestCache = factory.GetInstance<IRequestCache>();
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<IFactory> _factoryFunc;
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<IFactory> factoryFunc)
{
_requestCache = requestCache;
_factoryFunc = factoryFunc;
}
/// <summary>
@@ -36,9 +37,13 @@ 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 factory = _factoryFunc();
if (factory is null) return;
var requestCache = factory.GetInstance<IRequestCache>();
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<IFactory> factoryFunc)
{
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(factoryFunc))
.Enrich.With(new HttpRequestIdEnricher(factoryFunc));
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<IFactory> factoryFunc)
{
var loggerConfig = new LoggerConfiguration();
loggerConfig
.MinimalConfiguration(hostingEnvironment)
.MinimalConfiguration(hostingEnvironment, sessionIdResolver, factoryFunc)
.ReadFromConfigFile()
.ReadFromUserConfigFile();
@@ -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)
{
}
}
}
}
@@ -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
+1 -1
View File
@@ -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
+7 -5
View File
@@ -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;
}
+15 -14
View File
@@ -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/")]
+2 -1
View File
@@ -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;
@@ -28,7 +29,7 @@ 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>());
@@ -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>();
+2 -1
View File
@@ -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>();
@@ -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>();
@@ -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());
}
}
@@ -70,7 +70,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>();
@@ -84,7 +84,7 @@ namespace Umbraco.Tests.PropertyEditors
var mediaFileSystem = new MediaFileSystem(Mock.Of<IFileSystem>(), config, scheme, logger, ioHelper);
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>(), localizationService);
var editor = new NestedContentPropertyEditor(logger, new Lazy<PropertyEditorCollection>(() => editors), Mock.Of<IDataTypeService>(), 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;
}
@@ -46,7 +46,7 @@ namespace Umbraco.Tests.PublishedContent
Mock.Of<IContentTypeBaseServiceProvider>(),
Mock.Of<IUmbracoContextAccessor>(),
Mock.Of<IDataTypeService>(),
Mock.Of<ILocalizationService>())) { Id = 1 });
Mock.Of<ILocalizationService>(), IOHelper)) { Id = 1 });
var publishedContentTypeFactory = new PublishedContentTypeFactory(Mock.Of<IPublishedModelFactory>(), converters, dataTypeService);
@@ -53,11 +53,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)) { Id = 1002 },
new DataType(new TrueFalsePropertyEditor(logger, IOHelper)) { Id = 1001 },
new DataType(new RichTextPropertyEditor(logger, mediaService, contentTypeBaseServiceProvider, umbracoContextAccessor, Mock.Of<IDataTypeService>(), localizationService, 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)) { Id = 1005 });
new DataType(new TextboxPropertyEditor(logger, Mock.Of<IDataTypeService>(), localizationService, TestHelper.IOHelper)) { Id = 1004 },
new DataType(new MediaPickerPropertyEditor(logger, 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(new Lazy<IGlobalSettings>(() => _globalSettings)), new AspNetBackOfficeInfo(_globalSettings, _ioHelper, _settings, _logger))
{
}
@@ -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));
@@ -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,7 @@ namespace Umbraco.Tests.TestHelpers
settings.Path == TestHelper.IOHelper.ResolveUrl("~/umbraco") &&
settings.TimeOutInMinutes == 20 &&
settings.DefaultUILanguage == "en" &&
settings.LocalTempStorageLocation == LocalTempStorage.Default &&
settings.LocalTempStorageLocation == LocalTempStorage.EnvironmentTemp &&
settings.ReservedPaths == (GlobalSettings.StaticReservedPaths + "~/umbraco") &&
settings.ReservedUrls == GlobalSettings.StaticReservedUrls &&
settings.UmbracoPath == "~/umbraco" &&
+2 -2
View File
@@ -82,7 +82,7 @@ namespace Umbraco.Tests.TestHelpers
}
}
public static IIOHelper IOHelper = new IOHelper();
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 +313,7 @@ namespace Umbraco.Tests.TestHelpers
public static IHostingEnvironment GetHostingEnvironment()
{
return new AspNetHostingEnvironment(SettingsForTests.GetDefaultGlobalSettings(), TestHelper.IOHelper);
return new AspNetHostingEnvironment(new Lazy<IGlobalSettings>(() => SettingsForTests.GetDefaultGlobalSettings()));
}
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;
}
@@ -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;
+2 -2
View File
@@ -148,7 +148,7 @@ namespace Umbraco.Tests.Testing
var appCaches = GetAppCaches();
var globalSettings = SettingsForTests.GetDefaultGlobalSettings();
var settings = SettingsForTests.GetDefaultUmbracoSettings();
IHostingEnvironment hostingEnvironment = new AspNetHostingEnvironment(globalSettings, IOHelper);
IHostingEnvironment hostingEnvironment = new AspNetHostingEnvironment(new Lazy<IGlobalSettings>(() => globalSettings));
IBackOfficeInfo backOfficeInfo = new AspNetBackOfficeInfo(globalSettings, IOHelper, settings, logger);
IIpResolver ipResolver = new AspNetIpResolver();
UmbracoVersion = new UmbracoVersion(globalSettings);
@@ -156,7 +156,7 @@ 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(IOHelper);
@@ -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)
//{
@@ -36,7 +36,7 @@ namespace Umbraco.Tests.Web
[TestCase("hello href=\"{localLink:umb^://document/9931BDE0-AAC3-4BAB-B838-909A7B47570E}\" world ", "hello href=\"{localLink:umb^://document/9931BDE0-AAC3-4BAB-B838-909A7B47570E}\" world ")]
[TestCase("hello href=\"{localLink:umb://document-type/9931BDE0-AAC3-4BAB-B838-909A7B47570E}\" world ", "hello href=\"#\" world ")]
public void ParseLocalLinks(string input, string result)
{
{
//setup a mock url provider which we'll use for testing
var testUrlProvider = new Mock<IUrlProvider>();
testUrlProvider
@@ -71,7 +71,8 @@ namespace Umbraco.Tests.Web
globalSettings,
new UrlProviderCollection(new[] { testUrlProvider.Object }),
new MediaUrlProviderCollection(Enumerable.Empty<IMediaUrlProvider>()),
Mock.Of<IUserService>());
Mock.Of<IUserService>(),
TestHelper.IOHelper);
using (var reference = umbracoContextFactory.EnsureUmbracoContext(Mock.Of<HttpContextBase>()))
{
@@ -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 Lazy<IGlobalSettings> _globalSettings;
private string _localTempPath;
public AspNetHostingEnvironment(IGlobalSettings globalSettings, IIOHelper ioHelper)
public AspNetHostingEnvironment(Lazy<IGlobalSettings> globalSettings)
{
_globalSettings = globalSettings ?? throw new ArgumentNullException(nameof(globalSettings));
_ioHelper = ioHelper ?? throw new ArgumentNullException(nameof(ioHelper));
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,16 @@ 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 ?? _globalSettings.Value.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 string LocalTempPath
{
@@ -43,7 +45,7 @@ namespace Umbraco.Web.Hosting
if (_localTempPath != null)
return _localTempPath;
switch (_globalSettings.LocalTempStorageLocation)
switch (_globalSettings.Value.LocalTempStorageLocation)
{
case LocalTempStorage.AspNetTemp:
return _localTempPath = System.IO.Path.Combine(HttpRuntime.CodegenDir, "UmbracoData");
@@ -69,7 +71,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");
}
}
}
+7 -3
View File
@@ -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);
+5 -2
View File
@@ -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>
{ }
{
}
}
@@ -11,6 +11,7 @@ using Umbraco.Core.Dictionary;
using Umbraco.Core.IO;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Core.Services;
using Umbraco.Core.Strings;
using Umbraco.Web.Models;
using Umbraco.Web.Routing;
using Umbraco.Web.Security;
@@ -235,6 +236,18 @@ namespace Umbraco.Web.Mvc
base.WriteLiteral(value);
}
public override void Write(object value)
{
if (value is IHtmlEncodedString)
{
base.WriteLiteral(value);
}
else
{
base.Write(value);
}
}
public HelperResult RenderSection(string name, Func<dynamic, HelperResult> defaultContents)
{
return WebViewPageExtensions.RenderSection(this, name, defaultContents);
@@ -1,4 +1,5 @@
using Umbraco.Core;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Services;
@@ -19,20 +20,22 @@ namespace Umbraco.Web.PropertyEditors
private readonly ILocalizedTextService _textService;
private readonly IDataTypeService _dataTypeService;
private readonly ILocalizationService _localizationService;
private readonly IIOHelper _ioHelper;
/// <summary>
/// The constructor will setup the property editor based on the attribute if one is found
/// </summary>
public CheckBoxListPropertyEditor(ILogger logger, ILocalizedTextService textService, IDataTypeService dataTypeService, ILocalizationService localizationService)
public CheckBoxListPropertyEditor(ILogger logger, ILocalizedTextService textService, IDataTypeService dataTypeService, ILocalizationService localizationService, IIOHelper ioHelper)
: base(logger)
{
_textService = textService;
_dataTypeService = dataTypeService;
_localizationService = localizationService;
_ioHelper = ioHelper;
}
/// <inheritdoc />
protected override IConfigurationEditor CreateConfigurationEditor() => new ValueListConfigurationEditor(_textService);
protected override IConfigurationEditor CreateConfigurationEditor() => new ValueListConfigurationEditor(_textService, _ioHelper);
/// <inheritdoc />
protected override IDataValueEditor CreateValueEditor() => new MultipleValueEditor(Logger, _dataTypeService, _localizationService, Attribute);
@@ -5,13 +5,14 @@ using System.Text.RegularExpressions;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Umbraco.Core;
using Umbraco.Core.IO;
using Umbraco.Core.PropertyEditors;
namespace Umbraco.Web.PropertyEditors
{
internal class ColorPickerConfigurationEditor : ConfigurationEditor<ColorPickerConfiguration>
{
public ColorPickerConfigurationEditor()
public ColorPickerConfigurationEditor(IIOHelper ioHelper) : base(ioHelper)
{
var items = Fields.First(x => x.Key == "items");
@@ -109,7 +110,7 @@ namespace Umbraco.Web.PropertyEditors
var convertBool = useLabelObj.TryConvertTo<bool>();
if (convertBool.Success)
output.UseLabel = convertBool.Result;
}
}
// auto-assigning our ids, get next id from existing values
var nextId = 1;
@@ -1,4 +1,5 @@
using Umbraco.Core;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.PropertyEditors;
@@ -12,11 +13,15 @@ namespace Umbraco.Web.PropertyEditors
Group = Constants.PropertyEditors.Groups.Pickers)]
public class ColorPickerPropertyEditor : DataEditor
{
public ColorPickerPropertyEditor(ILogger logger)
private readonly IIOHelper _ioHelper;
public ColorPickerPropertyEditor(ILogger logger, IIOHelper ioHelper)
: base(logger)
{ }
{
_ioHelper = ioHelper;
}
/// <inheritdoc />
protected override IConfigurationEditor CreateConfigurationEditor() => new ColorPickerConfigurationEditor();
protected override IConfigurationEditor CreateConfigurationEditor() => new ColorPickerConfigurationEditor(_ioHelper);
}
}
@@ -1,11 +1,12 @@
using System.Collections.Generic;
using Umbraco.Core.IO;
using Umbraco.Core.PropertyEditors;
namespace Umbraco.Web.PropertyEditors
{
internal class ContentPickerConfigurationEditor : ConfigurationEditor<ContentPickerConfiguration>
{
public ContentPickerConfigurationEditor()
public ContentPickerConfigurationEditor(IIOHelper ioHelper) : base(ioHelper)
{
// configure fields
// this is not part of ContentPickerConfiguration,
@@ -23,7 +24,7 @@ namespace Umbraco.Web.PropertyEditors
// not part of ContentPickerConfiguration but used to configure the UI editor
d["showEditButton"] = false;
d["showPathOnHover"] = false;
d["idType"] = "udi";
d["idType"] = "udi";
return d;
}
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using Umbraco.Core;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.PropertyEditors;
@@ -17,13 +18,17 @@ namespace Umbraco.Web.PropertyEditors
Group = Constants.PropertyEditors.Groups.Pickers)]
public class ContentPickerPropertyEditor : DataEditor
{
public ContentPickerPropertyEditor(ILogger logger)
private readonly IIOHelper _ioHelper;
public ContentPickerPropertyEditor(ILogger logger, IIOHelper ioHelper)
: base(logger)
{ }
{
_ioHelper = ioHelper;
}
protected override IConfigurationEditor CreateConfigurationEditor()
{
return new ContentPickerConfigurationEditor();
return new ContentPickerConfigurationEditor(_ioHelper);
}
}
}
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using Umbraco.Core;
using Umbraco.Core.IO;
using Umbraco.Core.PropertyEditors;
namespace Umbraco.Web.PropertyEditors
@@ -19,5 +20,9 @@ namespace Umbraco.Web.PropertyEditors
return d;
}
public DateTimeConfigurationEditor(IIOHelper ioHelper) : base(ioHelper)
{
}
}
}
@@ -1,4 +1,5 @@
using Umbraco.Core;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.PropertyEditors;
@@ -15,13 +16,17 @@ namespace Umbraco.Web.PropertyEditors
Icon = "icon-time")]
public class DateTimePropertyEditor : DataEditor
{
private readonly IIOHelper _ioHelper;
/// <summary>
/// Initializes a new instance of the <see cref="DateTimePropertyEditor"/> class.
/// </summary>
/// <param name="logger"></param>
public DateTimePropertyEditor(ILogger logger)
public DateTimePropertyEditor(ILogger logger, IIOHelper ioHelper)
: base(logger)
{ }
{
_ioHelper = ioHelper;
}
/// <inheritdoc />
protected override IDataValueEditor CreateValueEditor()
@@ -32,6 +37,6 @@ namespace Umbraco.Web.PropertyEditors
}
/// <inheritdoc />
protected override IConfigurationEditor CreateConfigurationEditor() => new DateTimeConfigurationEditor();
protected override IConfigurationEditor CreateConfigurationEditor() => new DateTimeConfigurationEditor(_ioHelper);
}
}
@@ -2,6 +2,7 @@
using System.Linq;
using Newtonsoft.Json.Linq;
using Umbraco.Core;
using Umbraco.Core.IO;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Services;
@@ -9,7 +10,7 @@ namespace Umbraco.Web.PropertyEditors
{
internal class DropDownFlexibleConfigurationEditor : ConfigurationEditor<DropDownFlexibleConfiguration>
{
public DropDownFlexibleConfigurationEditor(ILocalizedTextService textService)
public DropDownFlexibleConfigurationEditor(ILocalizedTextService textService, IIOHelper ioHelper): base(ioHelper)
{
var items = Fields.First(x => x.Key == "items");
@@ -33,7 +34,7 @@ namespace Umbraco.Web.PropertyEditors
{
output.Multiple = convertBool.Result;
}
}
}
// auto-assigning our ids, get next id from existing values
var nextId = 1;
@@ -65,7 +66,7 @@ namespace Umbraco.Web.PropertyEditors
// map to what the editor expects
var i = 1;
var items = configuration?.Items.ToDictionary(x => x.Id.ToString(), x => new { value = x.Value, sortOrder = i++ }) ?? new object();
var multiple = configuration?.Multiple ?? false;
return new Dictionary<string, object>
@@ -1,4 +1,5 @@
using Umbraco.Core;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Services;
@@ -16,13 +17,15 @@ namespace Umbraco.Web.PropertyEditors
private readonly ILocalizedTextService _textService;
private readonly IDataTypeService _dataTypeService;
private readonly ILocalizationService _localizationService;
private readonly IIOHelper _ioHelper;
public DropDownFlexiblePropertyEditor(ILocalizedTextService textService, ILogger logger, IDataTypeService dataTypeService, ILocalizationService localizationService)
public DropDownFlexiblePropertyEditor(ILocalizedTextService textService, ILogger logger, IDataTypeService dataTypeService, ILocalizationService localizationService, IIOHelper ioHelper)
: base(logger)
{
_textService = textService;
_dataTypeService = dataTypeService;
_localizationService = localizationService;
_ioHelper = ioHelper;
}
protected override IDataValueEditor CreateValueEditor()
@@ -30,6 +33,6 @@ namespace Umbraco.Web.PropertyEditors
return new MultipleValueEditor(Logger, _dataTypeService, _localizationService, Attribute);
}
protected override IConfigurationEditor CreateConfigurationEditor() => new DropDownFlexibleConfigurationEditor(_textService);
protected override IConfigurationEditor CreateConfigurationEditor() => new DropDownFlexibleConfigurationEditor(_textService, _ioHelper);
}
}
@@ -1,4 +1,5 @@
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.IO;
using Umbraco.Core.PropertyEditors;
namespace Umbraco.Web.PropertyEditors
{
@@ -6,5 +7,9 @@ namespace Umbraco.Web.PropertyEditors
/// Represents the configuration editor for the email address value editor.
/// </summary>
public class EmailAddressConfigurationEditor : ConfigurationEditor<EmailAddressConfiguration>
{ }
}
{
public EmailAddressConfigurationEditor(IIOHelper ioHelper) : base(ioHelper)
{
}
}
}
@@ -1,4 +1,5 @@
using Umbraco.Core;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.PropertyEditors.Validators;
@@ -13,11 +14,14 @@ namespace Umbraco.Web.PropertyEditors
Icon = "icon-message")]
public class EmailAddressPropertyEditor : DataEditor
{
private readonly IIOHelper _ioHelper;
/// <summary>
/// The constructor will setup the property editor based on the attribute if one is found
/// </summary>
public EmailAddressPropertyEditor(ILogger logger) : base(logger)
public EmailAddressPropertyEditor(ILogger logger, IIOHelper ioHelper) : base(logger)
{
_ioHelper = ioHelper;
}
protected override IDataValueEditor CreateValueEditor()
@@ -30,7 +34,7 @@ namespace Umbraco.Web.PropertyEditors
protected override IConfigurationEditor CreateConfigurationEditor()
{
return new EmailAddressConfigurationEditor();
return new EmailAddressConfigurationEditor(_ioHelper);
}
}
}
@@ -2,6 +2,7 @@
using System.ComponentModel.DataAnnotations;
using System.Linq;
using Newtonsoft.Json;
using Umbraco.Core.IO;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.PropertyEditors.Validators;
@@ -12,7 +13,7 @@ namespace Umbraco.Web.PropertyEditors
/// </summary>
public class GridConfigurationEditor : ConfigurationEditor<GridConfiguration>
{
public GridConfigurationEditor()
public GridConfigurationEditor(IIOHelper ioHelper) : base(ioHelper)
{
var items = Fields.First(x => x.Key == "items");
@@ -3,6 +3,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using Umbraco.Core;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
using Umbraco.Core.Models.Editors;
@@ -30,9 +31,10 @@ namespace Umbraco.Web.PropertyEditors
private IUmbracoContextAccessor _umbracoContextAccessor;
private readonly IDataTypeService _dataTypeService;
private readonly ILocalizationService _localizationService;
private readonly IIOHelper _ioHelper;
private ILogger _logger;
public GridPropertyEditor(ILogger logger, IMediaService mediaService, IContentTypeBaseServiceProvider contentTypeBaseServiceProvider, IUmbracoContextAccessor umbracoContextAccessor, IDataTypeService dataTypeService, ILocalizationService localizationService)
public GridPropertyEditor(ILogger logger, IMediaService mediaService, IContentTypeBaseServiceProvider contentTypeBaseServiceProvider, IUmbracoContextAccessor umbracoContextAccessor, IDataTypeService dataTypeService, ILocalizationService localizationService, IIOHelper ioHelper)
: base(logger)
{
_mediaService = mediaService;
@@ -40,6 +42,7 @@ namespace Umbraco.Web.PropertyEditors
_umbracoContextAccessor = umbracoContextAccessor;
_dataTypeService = dataTypeService;
_localizationService = localizationService;
_ioHelper = ioHelper;
_logger = logger;
}
@@ -51,7 +54,7 @@ namespace Umbraco.Web.PropertyEditors
/// <returns></returns>
protected override IDataValueEditor CreateValueEditor() => new GridPropertyValueEditor(Attribute, _mediaService, _contentTypeBaseServiceProvider, _umbracoContextAccessor, _logger, _dataTypeService, _localizationService);
protected override IConfigurationEditor CreateConfigurationEditor() => new GridConfigurationEditor();
protected override IConfigurationEditor CreateConfigurationEditor() => new GridConfigurationEditor(_ioHelper);
internal class GridPropertyValueEditor : DataValueEditor
{
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using Umbraco.Core.IO;
using Umbraco.Core.PropertyEditors;
namespace Umbraco.Web.PropertyEditors
@@ -16,5 +17,9 @@ namespace Umbraco.Web.PropertyEditors
if (!d.ContainsKey("src")) d["src"] = "";
return d;
}
public ImageCropperConfigurationEditor(IIOHelper ioHelper) : base(ioHelper)
{
}
}
}
}
@@ -33,18 +33,20 @@ namespace Umbraco.Web.PropertyEditors
private readonly IContentSection _contentSettings;
private readonly IDataTypeService _dataTypeService;
private readonly ILocalizationService _localizationService;
private readonly IIOHelper _ioHelper;
private readonly UploadAutoFillProperties _autoFillProperties;
/// <summary>
/// Initializes a new instance of the <see cref="ImageCropperPropertyEditor"/> class.
/// </summary>
public ImageCropperPropertyEditor(ILogger logger, IMediaFileSystem mediaFileSystem, IContentSection contentSettings, IDataTypeService dataTypeService, ILocalizationService localizationService)
public ImageCropperPropertyEditor(ILogger logger, IMediaFileSystem mediaFileSystem, IContentSection contentSettings, IDataTypeService dataTypeService, ILocalizationService localizationService, IIOHelper ioHelper)
: base(logger)
{
_mediaFileSystem = mediaFileSystem ?? throw new ArgumentNullException(nameof(mediaFileSystem));
_contentSettings = contentSettings ?? throw new ArgumentNullException(nameof(contentSettings));
_dataTypeService = dataTypeService;
_localizationService = localizationService;
_ioHelper = ioHelper;
// TODO: inject?
_autoFillProperties = new UploadAutoFillProperties(_mediaFileSystem, logger, _contentSettings);
@@ -60,7 +62,7 @@ namespace Umbraco.Web.PropertyEditors
/// Creates the corresponding preValue editor.
/// </summary>
/// <returns>The corresponding preValue editor.</returns>
protected override IConfigurationEditor CreateConfigurationEditor() => new ImageCropperConfigurationEditor();
protected override IConfigurationEditor CreateConfigurationEditor() => new ImageCropperConfigurationEditor(_ioHelper);
/// <summary>
/// Gets a value indicating whether a property is an image cropper field.
@@ -1,4 +1,5 @@
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.IO;
using Umbraco.Core.PropertyEditors;
namespace Umbraco.Web.PropertyEditors
{
@@ -6,5 +7,9 @@ namespace Umbraco.Web.PropertyEditors
/// Represents the configuration editor for the listview value editor.
/// </summary>
public class ListViewConfigurationEditor : ConfigurationEditor<ListViewConfiguration>
{ }
{
public ListViewConfigurationEditor(IIOHelper ioHelper) : base(ioHelper)
{
}
}
}
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using Umbraco.Core;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.PropertyEditors;
@@ -17,15 +18,19 @@ namespace Umbraco.Web.PropertyEditors
Icon = Constants.Icons.ListView)]
public class ListViewPropertyEditor : DataEditor
{
private readonly IIOHelper _iioHelper;
/// <summary>
/// Initializes a new instance of the <see cref="ListViewPropertyEditor"/> class.
/// </summary>
/// <param name="logger"></param>
public ListViewPropertyEditor(ILogger logger)
public ListViewPropertyEditor(ILogger logger, IIOHelper iioHelper)
: base(logger)
{ }
{
_iioHelper = iioHelper;
}
/// <inheritdoc />
protected override IConfigurationEditor CreateConfigurationEditor() => new ListViewConfigurationEditor();
protected override IConfigurationEditor CreateConfigurationEditor() => new ListViewConfigurationEditor(_iioHelper);
}
}
@@ -1,4 +1,5 @@
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.IO;
using Umbraco.Core.PropertyEditors;
namespace Umbraco.Web.PropertyEditors
{
@@ -6,5 +7,9 @@ namespace Umbraco.Web.PropertyEditors
/// Represents the configuration editorfor the markdown value editor.
/// </summary>
internal class MarkdownConfigurationEditor : ConfigurationEditor<MarkdownConfiguration>
{ }
}
{
public MarkdownConfigurationEditor(IIOHelper ioHelper) : base(ioHelper)
{
}
}
}
@@ -1,4 +1,5 @@
using Umbraco.Core;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.PropertyEditors;
@@ -16,14 +17,18 @@ namespace Umbraco.Web.PropertyEditors
Icon = "icon-code")]
public class MarkdownPropertyEditor : DataEditor
{
private readonly IIOHelper _ioHelper;
/// <summary>
/// Initializes a new instance of the <see cref="MarkdownPropertyEditor"/> class.
/// </summary>
public MarkdownPropertyEditor(ILogger logger)
public MarkdownPropertyEditor(ILogger logger, IIOHelper ioHelper)
: base(logger)
{ }
{
_ioHelper = ioHelper;
}
/// <inheritdoc />
protected override IConfigurationEditor CreateConfigurationEditor() => new MarkdownConfigurationEditor();
protected override IConfigurationEditor CreateConfigurationEditor() => new MarkdownConfigurationEditor(_ioHelper);
}
}
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using Umbraco.Core.IO;
using Umbraco.Core.PropertyEditors;
namespace Umbraco.Web.PropertyEditors
@@ -11,7 +12,7 @@ namespace Umbraco.Web.PropertyEditors
/// <summary>
/// Initializes a new instance of the <see cref="MediaPickerConfigurationEditor"/> class.
/// </summary>
public MediaPickerConfigurationEditor()
public MediaPickerConfigurationEditor(IIOHelper ioHelper): base(ioHelper)
{
// configure fields
// this is not part of ContentPickerConfiguration,
@@ -1,4 +1,5 @@
using Umbraco.Core;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.PropertyEditors;
@@ -17,14 +18,18 @@ namespace Umbraco.Web.PropertyEditors
Icon = Constants.Icons.MediaImage)]
public class MediaPickerPropertyEditor : DataEditor
{
private readonly IIOHelper _ioHelper;
/// <summary>
/// Initializes a new instance of the <see cref="MediaPickerPropertyEditor"/> class.
/// </summary>
public MediaPickerPropertyEditor(ILogger logger)
public MediaPickerPropertyEditor(ILogger logger, IIOHelper ioHelper)
: base(logger)
{ }
{
_ioHelper = ioHelper;
}
/// <inheritdoc />
protected override IConfigurationEditor CreateConfigurationEditor() => new MediaPickerConfigurationEditor();
protected override IConfigurationEditor CreateConfigurationEditor() => new MediaPickerConfigurationEditor(_ioHelper);
}
}
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using Umbraco.Core.IO;
using Umbraco.Core.PropertyEditors;
namespace Umbraco.Web.PropertyEditors
@@ -8,7 +9,7 @@ namespace Umbraco.Web.PropertyEditors
/// </summary>
public class MultiNodePickerConfigurationEditor : ConfigurationEditor<MultiNodePickerConfiguration>
{
public MultiNodePickerConfigurationEditor()
public MultiNodePickerConfigurationEditor(IIOHelper ioHelper) : base(ioHelper)
{
Field(nameof(MultiNodePickerConfiguration.TreeSource))
.Config = new Dictionary<string, object> { { "idType", "udi" } };
@@ -1,4 +1,5 @@
using Umbraco.Core;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.PropertyEditors;
@@ -13,10 +14,14 @@ namespace Umbraco.Web.PropertyEditors
Icon = "icon-page-add")]
public class MultiNodeTreePickerPropertyEditor : DataEditor
{
public MultiNodeTreePickerPropertyEditor(ILogger logger)
: base(logger)
{ }
private readonly IIOHelper _ioHelper;
protected override IConfigurationEditor CreateConfigurationEditor() => new MultiNodePickerConfigurationEditor();
public MultiNodeTreePickerPropertyEditor(ILogger logger, IIOHelper ioHelper)
: base(logger)
{
_ioHelper = ioHelper;
}
protected override IConfigurationEditor CreateConfigurationEditor() => new MultiNodePickerConfigurationEditor(_ioHelper);
}
}

Some files were not shown because too many files have changed in this diff Show More