Merge remote-tracking branch 'origin/temp8' into temp8-3708
This commit is contained in:
@@ -452,9 +452,22 @@
|
||||
if ($this.OnError()) { return }
|
||||
$this.PrepareAzureGallery()
|
||||
if ($this.OnError()) { return }
|
||||
$this.PostPackageHook()
|
||||
if ($this.OnError()) { return }
|
||||
Write-Host "Done"
|
||||
})
|
||||
|
||||
$ubuild.DefineMethod("PostPackageHook",
|
||||
{
|
||||
# run hook
|
||||
if ($this.HasMethod("PostPackage"))
|
||||
{
|
||||
Write-Host "Run PostPackage hook"
|
||||
$this.PostPackage();
|
||||
if (-not $?) { throw "Failed to run hook." }
|
||||
}
|
||||
})
|
||||
|
||||
# ################################################################
|
||||
# RUN
|
||||
# ################################################################
|
||||
|
||||
+1
-1
@@ -19,4 +19,4 @@ using System.Resources;
|
||||
|
||||
// these are FYI and changed automatically
|
||||
[assembly: AssemblyFileVersion("8.0.0")]
|
||||
[assembly: AssemblyInformationalVersion("8.0.0-alpha.56")]
|
||||
[assembly: AssemblyInformationalVersion("8.0.0-alpha.58")]
|
||||
|
||||
@@ -23,7 +23,10 @@ namespace Umbraco.Core.Components
|
||||
_auditService = auditService;
|
||||
_userService = userService;
|
||||
_entityService = entityService;
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
UserService.SavedUserGroup += OnSavedUserGroupWithUsers;
|
||||
|
||||
UserService.SavedUser += OnSavedUser;
|
||||
@@ -37,6 +40,9 @@ namespace Umbraco.Core.Components
|
||||
MemberService.Exported += OnMemberExported;
|
||||
}
|
||||
|
||||
public void Terminate()
|
||||
{ }
|
||||
|
||||
private IUser CurrentPerformingUser
|
||||
{
|
||||
get
|
||||
|
||||
@@ -20,6 +20,21 @@ namespace Umbraco.Core.Components
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
using (_logger.DebugDuration<ComponentCollection>($"Initializing. (log components when >{LogThresholdMilliseconds}ms)", "Initialized."))
|
||||
{
|
||||
foreach (var component in this.Reverse()) // terminate components in reverse order
|
||||
{
|
||||
var componentType = component.GetType();
|
||||
using (_logger.DebugDuration<ComponentCollection>($"Initializing {componentType.FullName}.", $"Initialized {componentType.FullName}.", thresholdMilliseconds: LogThresholdMilliseconds))
|
||||
{
|
||||
component.Initialize();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Terminate()
|
||||
{
|
||||
using (_logger.DebugDuration<ComponentCollection>($"Terminating. (log components when >{LogThresholdMilliseconds}ms)", "Terminated."))
|
||||
@@ -29,6 +44,7 @@ namespace Umbraco.Core.Components
|
||||
var componentType = component.GetType();
|
||||
using (_logger.DebugDuration<ComponentCollection>($"Terminating {componentType.FullName}.", $"Terminated {componentType.FullName}.", thresholdMilliseconds: LogThresholdMilliseconds))
|
||||
{
|
||||
component.Terminate();
|
||||
component.DisposeIfDisposable();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Logging;
|
||||
|
||||
namespace Umbraco.Core.Components
|
||||
@@ -26,12 +27,21 @@ namespace Umbraco.Core.Components
|
||||
/// <param name="typeLoader">A type loader.</param>
|
||||
/// <param name="logger">A logger.</param>
|
||||
/// <param name="runtimeState">The runtime state.</param>
|
||||
public Composition(IRegister register, TypeLoader typeLoader, IProfilingLogger logger, IRuntimeState runtimeState)
|
||||
/// <param name="configs">Optional configs.</param>
|
||||
public Composition(IRegister register, TypeLoader typeLoader, IProfilingLogger logger, IRuntimeState runtimeState, Configs configs = null)
|
||||
{
|
||||
_register = register;
|
||||
TypeLoader = typeLoader;
|
||||
Logger = logger;
|
||||
RuntimeState = runtimeState;
|
||||
|
||||
if (configs == null)
|
||||
{
|
||||
configs = new Configs();
|
||||
configs.AddCoreConfigs();
|
||||
}
|
||||
|
||||
Configs = configs;
|
||||
}
|
||||
|
||||
#region Services
|
||||
@@ -51,6 +61,11 @@ namespace Umbraco.Core.Components
|
||||
/// </summary>
|
||||
public IRuntimeState RuntimeState { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the configurations.
|
||||
/// </summary>
|
||||
public Configs Configs { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region IRegister
|
||||
@@ -94,6 +109,8 @@ namespace Umbraco.Core.Components
|
||||
foreach (var builder in _builders.Values)
|
||||
builder.RegisterWith(_register);
|
||||
|
||||
Configs.RegisterWith(_register);
|
||||
|
||||
return _register.CreateFactory();
|
||||
}
|
||||
|
||||
|
||||
@@ -5,11 +5,21 @@
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>Components are created by DI and therefore must have a public constructor.</para>
|
||||
/// <para>All components which are also disposable, will be disposed in reverse
|
||||
/// order, when Umbraco terminates.</para>
|
||||
/// <para>All components are terminated in reverse order when Umbraco terminates, and
|
||||
/// disposable components are disposed.</para>
|
||||
/// <para>The Dispose method may be invoked more than once, and components
|
||||
/// should ensure they support this.</para>
|
||||
/// </remarks>
|
||||
public interface IComponent
|
||||
{ }
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes the component.
|
||||
/// </summary>
|
||||
void Initialize();
|
||||
|
||||
/// <summary>
|
||||
/// Terminates the component.
|
||||
/// </summary>
|
||||
void Terminate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,28 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.IO;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Manifest;
|
||||
|
||||
namespace Umbraco.Core.Components
|
||||
{
|
||||
public sealed class ManifestWatcherComponent : IComponent, IDisposable
|
||||
public sealed class ManifestWatcherComponent : IComponent
|
||||
{
|
||||
private readonly IRuntimeState _runtimeState;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
// if configured and in debug mode, a ManifestWatcher watches App_Plugins folders for
|
||||
// package.manifest chances and restarts the application on any change
|
||||
private ManifestWatcher _mw;
|
||||
|
||||
public ManifestWatcherComponent(IRuntimeState runtimeState, ILogger logger)
|
||||
{
|
||||
if (runtimeState.Debug == false) return;
|
||||
_runtimeState = runtimeState;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
if (_runtimeState.Debug == false) return;
|
||||
|
||||
//if (ApplicationContext.Current.IsConfigured == false || GlobalSettings.DebugMode == false)
|
||||
// return;
|
||||
@@ -22,11 +30,11 @@ namespace Umbraco.Core.Components
|
||||
var appPlugins = IOHelper.MapPath("~/App_Plugins/");
|
||||
if (Directory.Exists(appPlugins) == false) return;
|
||||
|
||||
_mw = new ManifestWatcher(logger);
|
||||
_mw = new ManifestWatcher(_logger);
|
||||
_mw.Start(Directory.GetDirectories(appPlugins));
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
public void Terminate()
|
||||
{
|
||||
if (_mw == null) return;
|
||||
|
||||
|
||||
@@ -8,11 +8,14 @@ namespace Umbraco.Core.Components
|
||||
//TODO: This should just exist in the content service/repo!
|
||||
public sealed class RelateOnCopyComponent : IComponent
|
||||
{
|
||||
public RelateOnCopyComponent()
|
||||
public void Initialize()
|
||||
{
|
||||
ContentService.Copied += ContentServiceCopied;
|
||||
}
|
||||
|
||||
public void Terminate()
|
||||
{ }
|
||||
|
||||
private static void ContentServiceCopied(IContentService sender, Events.CopyEventArgs<IContent> e)
|
||||
{
|
||||
if (e.RelateToOriginal == false) return;
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Umbraco.Core.Components
|
||||
{
|
||||
public sealed class RelateOnTrashComponent : IComponent
|
||||
{
|
||||
public RelateOnTrashComponent()
|
||||
public void Initialize()
|
||||
{
|
||||
ContentService.Moved += ContentService_Moved;
|
||||
ContentService.Trashed += ContentService_Trashed;
|
||||
@@ -17,6 +17,9 @@ namespace Umbraco.Core.Components
|
||||
MediaService.Trashed += MediaService_Trashed;
|
||||
}
|
||||
|
||||
public void Terminate()
|
||||
{ }
|
||||
|
||||
private static void ContentService_Moved(IContentService sender, MoveEventArgs<IContent> e)
|
||||
{
|
||||
foreach (var item in e.MoveInfoCollection.Where(x => x.OriginalPath.Contains(Constants.System.RecycleBinContent.ToInvariantString())))
|
||||
|
||||
@@ -5,24 +5,19 @@ using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
namespace Umbraco.Core.Composing.Composers
|
||||
{
|
||||
/// <summary>
|
||||
/// Sets up IoC container for Umbraco configuration classes
|
||||
/// Compose configurations.
|
||||
/// </summary>
|
||||
public static class ConfigurationComposer
|
||||
{
|
||||
public static Composition ComposeConfiguration(this Composition composition)
|
||||
{
|
||||
composition.RegisterUnique<UmbracoConfig>();
|
||||
composition.RegisterUnique(factory => factory.GetInstance<UmbracoConfig>().Umbraco());
|
||||
// common configurations are already registered
|
||||
// register others
|
||||
|
||||
composition.RegisterUnique(factory => factory.GetInstance<IUmbracoSettingsSection>().Content);
|
||||
composition.RegisterUnique(factory => factory.GetInstance<IUmbracoSettingsSection>().Templates);
|
||||
composition.RegisterUnique(factory => factory.GetInstance<IUmbracoSettingsSection>().RequestHandler);
|
||||
composition.RegisterUnique(factory => factory.GetInstance<IUmbracoSettingsSection>().Security);
|
||||
composition.RegisterUnique(factory => factory.GetInstance<UmbracoConfig>().Global());
|
||||
composition.RegisterUnique(factory => factory.GetInstance<UmbracoConfig>().Dashboards());
|
||||
composition.RegisterUnique(factory => factory.GetInstance<UmbracoConfig>().HealthChecks());
|
||||
composition.RegisterUnique(factory => factory.GetInstance<UmbracoConfig>().Grids());
|
||||
|
||||
// fixme - other sections we need to add?
|
||||
|
||||
return composition;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace Umbraco.Core.Composing
|
||||
private static IProfiler _profiler;
|
||||
private static IProfilingLogger _profilingLogger;
|
||||
private static IPublishedValueFallback _publishedValueFallback;
|
||||
private static UmbracoConfig _config;
|
||||
private static Configs _configs;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the factory.
|
||||
@@ -48,25 +48,32 @@ namespace Umbraco.Core.Composing
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_factory == null) throw new Exception("No factory has been set.");
|
||||
if (_factory == null) throw new InvalidOperationException("No factory has been set.");
|
||||
return _factory;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_factory != null) throw new Exception("A factory has already been set.");
|
||||
if (_factory != null) throw new InvalidOperationException("A factory has already been set.");
|
||||
if (_configs != null) throw new InvalidOperationException("Configs are unlocked.");
|
||||
_factory = value;
|
||||
}
|
||||
}
|
||||
|
||||
internal static bool HasContainer => _factory != null;
|
||||
internal static bool HasFactory => _factory != null;
|
||||
|
||||
// for UNIT TESTS exclusively!
|
||||
// resets *everything* that is 'current'
|
||||
internal static void Reset()
|
||||
/// <summary>
|
||||
/// Resets <see cref="Current"/>. Indented for testing only, and not supported in production code.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>For UNIT TESTS exclusively.</para>
|
||||
/// <para>Resets everything that is 'current'.</para>
|
||||
/// </remarks>
|
||||
public static void Reset()
|
||||
{
|
||||
_factory.DisposeIfDisposable();
|
||||
_factory = null;
|
||||
|
||||
_configs = null;
|
||||
_shortStringHelper = null;
|
||||
_logger = null;
|
||||
_profiler = null;
|
||||
@@ -76,21 +83,36 @@ namespace Umbraco.Core.Composing
|
||||
Resetted?.Invoke(null, EventArgs.Empty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unlocks <see cref="Configs"/>. Intended for testing only, and not supported in production code.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>For UNIT TESTS exclusively.</para>
|
||||
/// <para>Unlocks <see cref="Configs"/> so that it is possible to add configurations
|
||||
/// directly to <see cref="Current"/> without having to wire composition.</para>
|
||||
/// </remarks>
|
||||
public static void UnlockConfigs()
|
||||
{
|
||||
if (_factory != null)
|
||||
throw new InvalidOperationException("Cannot unlock configs when a factory has been set.");
|
||||
_configs = new Configs();
|
||||
}
|
||||
|
||||
internal static event EventHandler Resetted;
|
||||
|
||||
#region Getters
|
||||
|
||||
public static IShortStringHelper ShortStringHelper
|
||||
=> _shortStringHelper ?? (_shortStringHelper = _factory?.TryGetInstance<IShortStringHelper>()
|
||||
?? new DefaultShortStringHelper(new DefaultShortStringHelperConfig().WithDefault(Config.Umbraco())));
|
||||
?? new DefaultShortStringHelper(new DefaultShortStringHelperConfig().WithDefault(Configs.Settings())));
|
||||
|
||||
public static ILogger Logger
|
||||
=> _logger ?? (_logger = _factory?.TryGetInstance<ILogger>()
|
||||
?? new DebugDiagnosticsLogger());
|
||||
?? new DebugDiagnosticsLogger());
|
||||
|
||||
public static IProfiler Profiler
|
||||
=> _profiler ?? (_profiler = _factory?.TryGetInstance<IProfiler>()
|
||||
?? new LogProfiler(Logger));
|
||||
?? new LogProfiler(Logger));
|
||||
|
||||
public static IProfilingLogger ProfilingLogger
|
||||
=> _profilingLogger ?? (_profilingLogger = _factory?.TryGetInstance<IProfilingLogger>())
|
||||
@@ -102,9 +124,15 @@ namespace Umbraco.Core.Composing
|
||||
public static TypeLoader TypeLoader
|
||||
=> Factory.GetInstance<TypeLoader>();
|
||||
|
||||
public static UmbracoConfig Config
|
||||
=> _config ?? (_config = _factory?.TryGetInstance<UmbracoConfig>()
|
||||
?? new UmbracoConfig(Logger, _factory?.TryGetInstance<IRuntimeCacheProvider>(), _factory?.TryGetInstance<IRuntimeState>()));
|
||||
public static Configs Configs
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_configs != null) return _configs;
|
||||
if (_factory == null) throw new InvalidOperationException("Can not get Current.Config during composition. Use composition.Config.");
|
||||
return _factory.GetInstance<Configs>();
|
||||
}
|
||||
}
|
||||
|
||||
public static IFileSystems FileSystems
|
||||
=> Factory.GetInstance<IFileSystems>();
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
using System.IO;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Configuration.Dashboard;
|
||||
using Umbraco.Core.Configuration.Grid;
|
||||
using Umbraco.Core.Configuration.HealthChecks;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Logging;
|
||||
|
||||
namespace Umbraco.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides extension methods for the <see cref="Configs"/> class.
|
||||
/// </summary>
|
||||
public static class ConfigsExtensions
|
||||
{
|
||||
public static IGlobalSettings Global(this Configs configs)
|
||||
=> configs.GetConfig<IGlobalSettings>();
|
||||
|
||||
public static IUmbracoSettingsSection Settings(this Configs configs)
|
||||
=> configs.GetConfig<IUmbracoSettingsSection>();
|
||||
|
||||
public static IDashboardSection Dashboards(this Configs configs)
|
||||
=> configs.GetConfig<IDashboardSection>();
|
||||
|
||||
public static IHealthChecks HealthChecks(this Configs configs)
|
||||
=> configs.GetConfig<IHealthChecks>();
|
||||
|
||||
public static IGridConfig Grids(this Configs configs)
|
||||
=> configs.GetConfig<IGridConfig>();
|
||||
|
||||
internal static CoreDebug CoreDebug(this Configs configs)
|
||||
=> configs.GetConfig<CoreDebug>();
|
||||
|
||||
public static void AddCoreConfigs(this Configs configs)
|
||||
{
|
||||
var configDir = new DirectoryInfo(IOHelper.MapPath(SystemDirectories.Config));
|
||||
|
||||
configs.Add<IGlobalSettings>(() => new GlobalSettings());
|
||||
configs.Add<IUmbracoSettingsSection>("umbracoConfiguration/settings");
|
||||
configs.Add<IDashboardSection>("umbracoConfiguration/dashBoard");
|
||||
configs.Add<IHealthChecks>("umbracoConfiguration/HealthChecks");
|
||||
|
||||
configs.Add(() => new CoreDebug());
|
||||
|
||||
// GridConfig depends on runtime caches, manifest parsers... and cannot be available during composition
|
||||
configs.Add<IGridConfig>(factory => new GridConfig(factory.GetInstance<ILogger>(), factory.GetInstance<IRuntimeCacheProvider>(), configDir, factory.GetInstance<IRuntimeState>().Debug));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Logging;
|
||||
|
||||
namespace Umbraco.Core.Configuration
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents Umbraco configurations.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>During composition, use composition.Configs. When running, either inject the required configuration,
|
||||
/// or use Current.Configs.</para>
|
||||
/// </remarks>
|
||||
public class Configs
|
||||
{
|
||||
private readonly Dictionary<Type, Lazy<object>> _configs = new Dictionary<Type, Lazy<object>>();
|
||||
private Dictionary<Type, Action<IRegister>> _registerings = new Dictionary<Type, Action<IRegister>>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a configuration.
|
||||
/// </summary>
|
||||
public TConfig GetConfig<TConfig>()
|
||||
where TConfig : class
|
||||
{
|
||||
if (!_configs.TryGetValue(typeof(TConfig), out var configFactory))
|
||||
throw new InvalidOperationException($"No configuration of type {typeof(TConfig)} has been added.");
|
||||
|
||||
return (TConfig) configFactory.Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a configuration, provided by a factory.
|
||||
/// </summary>
|
||||
public void Add<TConfig>(Func<TConfig> configFactory)
|
||||
where TConfig : class
|
||||
{
|
||||
// make sure it is not too late
|
||||
if (_registerings == null)
|
||||
throw new InvalidOperationException("Configurations have already been registered.");
|
||||
|
||||
var typeOfConfig = typeof(TConfig);
|
||||
|
||||
var lazyConfigFactory = _configs[typeOfConfig] = new Lazy<object>(configFactory);
|
||||
_registerings[typeOfConfig] = register => register.Register(_ => (TConfig) lazyConfigFactory.Value, Lifetime.Singleton);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a configuration, provided by a factory.
|
||||
/// </summary>
|
||||
public void Add<TConfig>(Func<IFactory, TConfig> configFactory)
|
||||
where TConfig : class
|
||||
{
|
||||
// make sure it is not too late
|
||||
if (_registerings == null)
|
||||
throw new InvalidOperationException("Configurations have already been registered.");
|
||||
|
||||
var typeOfConfig = typeof(TConfig);
|
||||
|
||||
_configs[typeOfConfig] = new Lazy<object>(() =>
|
||||
{
|
||||
if (Current.HasFactory) return Current.Factory.GetInstance<TConfig>();
|
||||
throw new InvalidOperationException($"Cannot get configuration of type {typeOfConfig} during composition.");
|
||||
});
|
||||
_registerings[typeOfConfig] = register => register.Register(configFactory, Lifetime.Singleton);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a configuration, provided by a configuration section.
|
||||
/// </summary>
|
||||
public void Add<TConfig>(string sectionName)
|
||||
where TConfig : class
|
||||
{
|
||||
Add(() => GetConfig<TConfig>(sectionName));
|
||||
}
|
||||
|
||||
private static TConfig GetConfig<TConfig>(string sectionName)
|
||||
where TConfig : class
|
||||
{
|
||||
// note: need to use SafeCallContext here because ConfigurationManager.GetSection ends up getting AppDomain.Evidence
|
||||
// which will want to serialize the call context including anything that is in there - what a mess!
|
||||
|
||||
using (new SafeCallContext())
|
||||
{
|
||||
if ((ConfigurationManager.GetSection(sectionName) is TConfig config))
|
||||
return config;
|
||||
var ex = new ConfigurationErrorsException($"Could not get configuration section \"{sectionName}\" from config files.");
|
||||
Current.Logger.Error<Configs>(ex, "Config error");
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers configurations in a register.
|
||||
/// </summary>
|
||||
public void RegisterWith(IRegister register)
|
||||
{
|
||||
// do it only once
|
||||
if (_registerings == null)
|
||||
throw new InvalidOperationException("Configurations have already been registered.");
|
||||
|
||||
register.RegisterInstance(this);
|
||||
|
||||
foreach (var registering in _registerings.Values)
|
||||
registering(register);
|
||||
|
||||
// no need to keep them around
|
||||
_registerings = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,16 +2,6 @@
|
||||
|
||||
namespace Umbraco.Core.Configuration
|
||||
{
|
||||
internal static class CoreDebugExtensions
|
||||
{
|
||||
private static CoreDebug _coreDebug;
|
||||
|
||||
public static CoreDebug CoreDebug(this UmbracoConfig config)
|
||||
{
|
||||
return _coreDebug ?? (_coreDebug = new CoreDebug());
|
||||
}
|
||||
}
|
||||
|
||||
internal class CoreDebug
|
||||
{
|
||||
public CoreDebug()
|
||||
|
||||
@@ -6,11 +6,11 @@ namespace Umbraco.Core.Configuration.Grid
|
||||
{
|
||||
class GridConfig : IGridConfig
|
||||
{
|
||||
public GridConfig(ILogger logger, IRuntimeCacheProvider runtimeCache, DirectoryInfo appPlugins, DirectoryInfo configFolder, bool isDebug)
|
||||
public GridConfig(ILogger logger, IRuntimeCacheProvider runtimeCache, DirectoryInfo configFolder, bool isDebug)
|
||||
{
|
||||
EditorsConfig = new GridEditorsConfig(logger, runtimeCache, appPlugins, configFolder, isDebug);
|
||||
EditorsConfig = new GridEditorsConfig(logger, runtimeCache, configFolder, isDebug);
|
||||
}
|
||||
|
||||
public IGridEditorsConfig EditorsConfig { get; private set; }
|
||||
public IGridEditorsConfig EditorsConfig { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,15 +14,13 @@ namespace Umbraco.Core.Configuration.Grid
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IRuntimeCacheProvider _runtimeCache;
|
||||
private readonly DirectoryInfo _appPlugins;
|
||||
private readonly DirectoryInfo _configFolder;
|
||||
private readonly bool _isDebug;
|
||||
|
||||
public GridEditorsConfig(ILogger logger, IRuntimeCacheProvider runtimeCache, DirectoryInfo appPlugins, DirectoryInfo configFolder, bool isDebug)
|
||||
public GridEditorsConfig(ILogger logger, IRuntimeCacheProvider runtimeCache, DirectoryInfo configFolder, bool isDebug)
|
||||
{
|
||||
_logger = logger;
|
||||
_runtimeCache = runtimeCache;
|
||||
_appPlugins = appPlugins;
|
||||
_configFolder = configFolder;
|
||||
_isDebug = isDebug;
|
||||
}
|
||||
@@ -31,7 +29,7 @@ namespace Umbraco.Core.Configuration.Grid
|
||||
{
|
||||
get
|
||||
{
|
||||
Func<List<GridEditor>> getResult = () =>
|
||||
List<GridEditor> GetResult()
|
||||
{
|
||||
// fixme - should use the common one somehow! + ignoring _appPlugins here!
|
||||
var parser = new ManifestParser(_runtimeCache, Current.ManifestValidators, _logger);
|
||||
@@ -55,20 +53,16 @@ namespace Umbraco.Core.Configuration.Grid
|
||||
// add manifest editors, skip duplicates
|
||||
foreach (var gridEditor in parser.Manifest.GridEditors)
|
||||
{
|
||||
if (editors.Contains(gridEditor) == false)
|
||||
editors.Add(gridEditor);
|
||||
if (editors.Contains(gridEditor) == false) editors.Add(gridEditor);
|
||||
}
|
||||
|
||||
return editors;
|
||||
};
|
||||
}
|
||||
|
||||
//cache the result if debugging is disabled
|
||||
var result = _isDebug
|
||||
? getResult()
|
||||
: _runtimeCache.GetCacheItem<List<GridEditor>>(
|
||||
typeof(GridEditorsConfig) + "Editors",
|
||||
() => getResult(),
|
||||
TimeSpan.FromMinutes(10));
|
||||
? GetResult()
|
||||
: _runtimeCache.GetCacheItem<List<GridEditor>>(typeof(GridEditorsConfig) + ".Editors",GetResult, TimeSpan.FromMinutes(10));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1,138 +0,0 @@
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Configuration.Dashboard;
|
||||
using Umbraco.Core.Configuration.Grid;
|
||||
using Umbraco.Core.Configuration.HealthChecks;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Logging;
|
||||
|
||||
namespace Umbraco.Core.Configuration
|
||||
{
|
||||
/// <summary>
|
||||
/// The gateway to all umbraco configuration.
|
||||
/// </summary>
|
||||
/// <remarks>This should be registered as a unique service in the container.</remarks>
|
||||
public class UmbracoConfig
|
||||
{
|
||||
private IGlobalSettings _global;
|
||||
private Lazy<IUmbracoSettingsSection> _umbraco;
|
||||
private Lazy<IHealthChecks> _healthChecks;
|
||||
private Lazy<IDashboardSection> _dashboards;
|
||||
private Lazy<IGridConfig> _grids;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UmbracoConfig"/> class.
|
||||
/// </summary>
|
||||
public UmbracoConfig(ILogger logger, IRuntimeCacheProvider runtimeCache, IRuntimeState runtimeState)
|
||||
{
|
||||
_global = new GlobalSettings();
|
||||
|
||||
var appPluginsDir = new DirectoryInfo(IOHelper.MapPath(SystemDirectories.AppPlugins));
|
||||
var configDir = new DirectoryInfo(IOHelper.MapPath(SystemDirectories.Config));
|
||||
|
||||
_umbraco = new Lazy<IUmbracoSettingsSection>(() => GetConfig<IUmbracoSettingsSection>("umbracoConfiguration/settings"));
|
||||
_dashboards = new Lazy<IDashboardSection>(() =>GetConfig<IDashboardSection>("umbracoConfiguration/dashBoard"));
|
||||
_healthChecks = new Lazy<IHealthChecks>(() => GetConfig<IHealthChecks>("umbracoConfiguration/HealthChecks"));
|
||||
_grids = new Lazy<IGridConfig>(() => new GridConfig(logger, runtimeCache, appPluginsDir, configDir, runtimeState.Debug));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a typed and named config section.
|
||||
/// </summary>
|
||||
/// <typeparam name="TConfig">The type of the configuration section.</typeparam>
|
||||
/// <param name="sectionName">The name of the configuration section.</param>
|
||||
/// <returns>The configuration section.</returns>
|
||||
public static TConfig GetConfig<TConfig>(string sectionName)
|
||||
where TConfig : class
|
||||
{
|
||||
// note: need to use SafeCallContext here because ConfigurationManager.GetSection ends up getting AppDomain.Evidence
|
||||
// which will want to serialize the call context including anything that is in there - what a mess!
|
||||
|
||||
using (new SafeCallContext())
|
||||
{
|
||||
if ((ConfigurationManager.GetSection(sectionName) is TConfig config))
|
||||
return config;
|
||||
var ex = new ConfigurationErrorsException($"Could not get configuration section \"{sectionName}\" from config files.");
|
||||
Current.Logger.Error<UmbracoConfig>(ex, "Config error");
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the global configuration.
|
||||
/// </summary>
|
||||
public IGlobalSettings Global()
|
||||
=> _global;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Umbraco configuration.
|
||||
/// </summary>
|
||||
public IUmbracoSettingsSection Umbraco()
|
||||
=> _umbraco.Value;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the dashboards configuration.
|
||||
/// </summary>
|
||||
public IDashboardSection Dashboards()
|
||||
=> _dashboards.Value;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the health checks configuration.
|
||||
/// </summary>
|
||||
public IHealthChecks HealthChecks()
|
||||
=> _healthChecks.Value;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the grids configuration.
|
||||
/// </summary>
|
||||
public IGridConfig Grids()
|
||||
=> _grids.Value;
|
||||
|
||||
/// <summary>
|
||||
/// Sets the global configuration, for tests only.
|
||||
/// </summary>
|
||||
public void SetGlobalConfig(IGlobalSettings value)
|
||||
{
|
||||
_global = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the Umbraco configuration, for tests only.
|
||||
/// </summary>
|
||||
public void SetUmbracoConfig(IUmbracoSettingsSection value)
|
||||
{
|
||||
_umbraco = new Lazy<IUmbracoSettingsSection>(() => value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the dashboards configuration, for tests only.
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public void SetDashboardsConfig(IDashboardSection value)
|
||||
{
|
||||
_dashboards = new Lazy<IDashboardSection>(() => value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the health checks configuration, for tests only.
|
||||
/// </summary>
|
||||
public void SetHealthChecksConfig(IHealthChecks value)
|
||||
{
|
||||
_healthChecks = new Lazy<IHealthChecks>(() => value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the grids configuration, for tests only.
|
||||
/// </summary>
|
||||
public void SetGridsConfig(IGridConfig value)
|
||||
{
|
||||
_grids = new Lazy<IGridConfig>(() => value);
|
||||
}
|
||||
|
||||
//TODO: Add other configurations here !
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ namespace Umbraco.Core.IO.MediaPathSchemes
|
||||
// prevpath should be "<int>/<filename>" OR "<int>-<filename>"
|
||||
// and we want to reuse the "<int>" part, so try to find it
|
||||
|
||||
var sep = Current.Config.Umbraco().Content.UploadAllowDirectories ? "/" : "-";
|
||||
var sep = Current.Configs.Settings().Content.UploadAllowDirectories ? "/" : "-";
|
||||
var pos = previous.IndexOf(sep, StringComparison.Ordinal);
|
||||
var s = pos > 0 ? previous.Substring(0, pos) : null;
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace Umbraco.Core.IO.MediaPathSchemes
|
||||
if (directory == null)
|
||||
throw new InvalidOperationException("Cannot use a null directory.");
|
||||
|
||||
return Current.Config.Umbraco().Content.UploadAllowDirectories
|
||||
return Current.Configs.Settings().Content.UploadAllowDirectories
|
||||
? Path.Combine(directory, filename).Replace('\\', '/')
|
||||
: directory + "-" + filename;
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ namespace Umbraco.Core.Logging.Serilog
|
||||
messageTemplate += "\r\nThe thread has been aborted, because the request has timed out.";
|
||||
|
||||
// dump if configured, or if stacktrace contains Monitor.ReliableEnter
|
||||
dump = Current.Config.CoreDebug().DumpOnTimeoutThreadAbort || IsMonitorEnterThreadAbortException(exception);
|
||||
dump = Current.Configs.CoreDebug().DumpOnTimeoutThreadAbort || IsMonitorEnterThreadAbortException(exception);
|
||||
|
||||
// dump if it is ok to dump (might have a cap on number of dump...)
|
||||
dump &= MiniDump.OkToDump();
|
||||
@@ -217,9 +217,9 @@ namespace Umbraco.Core.Logging.Serilog
|
||||
/// <inheritdoc/>
|
||||
public void Warn(Type reporting, string message)
|
||||
{
|
||||
LoggerFor(reporting).Warning(message);
|
||||
LoggerFor(reporting).Warning(message);
|
||||
}
|
||||
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Warn(Type reporting, string message, params object[] propertyValues)
|
||||
{
|
||||
@@ -231,7 +231,7 @@ namespace Umbraco.Core.Logging.Serilog
|
||||
{
|
||||
LoggerFor(reporting).Warning(exception, message);
|
||||
}
|
||||
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Warn(Type reporting, Exception exception, string messageTemplate, params object[] propertyValues)
|
||||
{
|
||||
@@ -255,7 +255,7 @@ namespace Umbraco.Core.Logging.Serilog
|
||||
{
|
||||
LoggerFor(reporting).Debug(message);
|
||||
}
|
||||
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Debug(Type reporting, string messageTemplate, params object[] propertyValues)
|
||||
{
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace Umbraco.Core.Models.Identity
|
||||
_startContentIds = new int[] { };
|
||||
_groups = new IReadOnlyUserGroup[] { };
|
||||
_allowedSections = new string[] { };
|
||||
_culture = Current.Config.Global().DefaultUILanguage; //fixme inject somehow?
|
||||
_culture = Current.Configs.Global().DefaultUILanguage; //fixme inject somehow?
|
||||
_groups = new IReadOnlyUserGroup[0];
|
||||
_roles = new ObservableCollection<IdentityUserRole<string>>();
|
||||
_roles.CollectionChanged += _roles_CollectionChanged;
|
||||
@@ -84,7 +84,7 @@ namespace Umbraco.Core.Models.Identity
|
||||
_startContentIds = new int[] { };
|
||||
_groups = new IReadOnlyUserGroup[] { };
|
||||
_allowedSections = new string[] { };
|
||||
_culture = Current.Config.Global().DefaultUILanguage; //fixme inject somehow?
|
||||
_culture = Current.Configs.Global().DefaultUILanguage; //fixme inject somehow?
|
||||
_groups = groups.ToArray();
|
||||
_roles = new ObservableCollection<IdentityUserRole<string>>(_groups.Select(x => new IdentityUserRole<string>
|
||||
{
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Umbraco.Core.Models.Membership
|
||||
{
|
||||
SessionTimeout = 60;
|
||||
_userGroups = new HashSet<IReadOnlyUserGroup>();
|
||||
_language = Current.Config.Global().DefaultUILanguage; //fixme inject somehow?
|
||||
_language = Current.Configs.Global().DefaultUILanguage; //fixme inject somehow?
|
||||
_isApproved = true;
|
||||
_isLockedOut = false;
|
||||
_startContentIds = new int[] { };
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Umbraco.Core.Models.PublishedContent
|
||||
// in order to provide a nice, "fluent" experience, this extension method
|
||||
// needs to access Current, which is not always initialized in tests - not
|
||||
// very elegant, but works
|
||||
if (!Current.HasContainer) return content;
|
||||
if (!Current.HasFactory) return content;
|
||||
|
||||
// get model
|
||||
// if factory returns nothing, throw
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
@@ -106,16 +107,18 @@ namespace Umbraco.Core.Runtime
|
||||
// database factory
|
||||
var databaseFactory = GetDatabaseFactory();
|
||||
|
||||
// configs
|
||||
var configs = GetConfigs();
|
||||
|
||||
// type loader
|
||||
var globalSettings = Current.Config.Global();
|
||||
var localTempStorage = globalSettings.LocalTempStorageLocation;
|
||||
var localTempStorage = configs.Global().LocalTempStorageLocation;
|
||||
var typeLoader = new TypeLoader(runtimeCache, localTempStorage, ProfilingLogger);
|
||||
|
||||
// runtime state
|
||||
// beware! must use '() => _factory.GetInstance<T>()' and NOT '_factory.GetInstance<T>'
|
||||
// as the second one captures the current value (null) and therefore fails
|
||||
_state = new RuntimeState(Logger,
|
||||
Current.Config.Umbraco(), Current.Config.Global(),
|
||||
configs.Settings(), configs.Global(),
|
||||
new Lazy<IMainDom>(() => _factory.GetInstance<IMainDom>()),
|
||||
new Lazy<IServerRegistrar>(() => _factory.GetInstance<IServerRegistrar>()))
|
||||
{
|
||||
@@ -126,7 +129,7 @@ namespace Umbraco.Core.Runtime
|
||||
var mainDom = new MainDom(Logger);
|
||||
|
||||
// create the composition
|
||||
composition = new Composition(register, typeLoader, ProfilingLogger, _state);
|
||||
composition = new Composition(register, typeLoader, ProfilingLogger, _state, configs);
|
||||
composition.RegisterEssentials(Logger, Profiler, ProfilingLogger, mainDom, appCaches, databaseFactory, typeLoader, _state);
|
||||
|
||||
// register runtime-level services
|
||||
@@ -146,14 +149,20 @@ namespace Umbraco.Core.Runtime
|
||||
// create the factory
|
||||
_factory = Current.Factory = composition.CreateFactory();
|
||||
|
||||
// create the components
|
||||
// create & initialize the components
|
||||
_components = _factory.GetInstance<ComponentCollection>();
|
||||
_components.Initialize();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_state.Level = RuntimeLevel.BootFailed;
|
||||
var bfe = e as BootFailedException ?? new BootFailedException("Boot failed.", e);
|
||||
_state.BootFailedException = bfe;
|
||||
|
||||
if (_state != null)
|
||||
{
|
||||
_state.Level = RuntimeLevel.BootFailed;
|
||||
_state.BootFailedException = bfe;
|
||||
}
|
||||
|
||||
timer.Fail(exception: bfe); // be sure to log the exception - even if we repeat ourselves
|
||||
|
||||
// if something goes wrong above, we may end up with no factory
|
||||
@@ -168,6 +177,8 @@ namespace Umbraco.Core.Runtime
|
||||
catch { /* yea */ }
|
||||
}
|
||||
|
||||
Debugger.Break();
|
||||
|
||||
// throwing here can cause w3wp to hard-crash and we want to avoid it.
|
||||
// instead, we're logging the exception and setting level to BootFailed.
|
||||
// various parts of Umbraco such as UmbracoModule and UmbracoDefaultOwinStartup
|
||||
@@ -338,6 +349,16 @@ namespace Umbraco.Core.Runtime
|
||||
protected internal virtual IUmbracoDatabaseFactory GetDatabaseFactory()
|
||||
=> new UmbracoDatabaseFactory(Logger, new Lazy<IMapperCollection>(() => _factory.GetInstance<IMapperCollection>()));
|
||||
|
||||
/// <summary>
|
||||
/// Gets the configurations.
|
||||
/// </summary>
|
||||
protected virtual Configs GetConfigs()
|
||||
{
|
||||
var configs = new Configs();
|
||||
configs.AddCoreConfigs();
|
||||
return configs;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,12 +7,19 @@ namespace Umbraco.Core.Runtime
|
||||
{
|
||||
public class CoreRuntimeComponent : IComponent
|
||||
{
|
||||
private readonly IEnumerable<Profile> _mapperProfiles;
|
||||
|
||||
public CoreRuntimeComponent(IEnumerable<Profile> mapperProfiles)
|
||||
{
|
||||
_mapperProfiles = mapperProfiles;
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
// mapper profiles have been registered & are created by the container
|
||||
Mapper.Initialize(configuration =>
|
||||
{
|
||||
foreach (var profile in mapperProfiles)
|
||||
foreach (var profile in _mapperProfiles)
|
||||
configuration.AddProfile(profile);
|
||||
});
|
||||
|
||||
@@ -24,5 +31,8 @@ namespace Umbraco.Core.Runtime
|
||||
IOHelper.EnsurePathExists(SystemDirectories.MvcViews + "/Partials");
|
||||
IOHelper.EnsurePathExists(SystemDirectories.MvcViews + "/MacroPartials");
|
||||
}
|
||||
|
||||
public void Terminate()
|
||||
{ }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -492,7 +492,7 @@ namespace Umbraco.Core.Scoping
|
||||
// caching config
|
||||
// true if Umbraco.CoreDebug.LogUncompletedScope appSetting is set to "true"
|
||||
private static bool LogUncompletedScopes => (_logUncompletedScopes
|
||||
?? (_logUncompletedScopes = Current.Config.CoreDebug().LogUncompletedScopes)).Value;
|
||||
?? (_logUncompletedScopes = Current.Configs.CoreDebug().LogUncompletedScopes)).Value;
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ReadLock(params int[] lockIds)
|
||||
|
||||
@@ -88,11 +88,11 @@ namespace Umbraco.Core.Security
|
||||
/// <returns></returns>
|
||||
public static MembershipProvider GetUsersMembershipProvider()
|
||||
{
|
||||
if (Membership.Providers[Current.Config.Umbraco().Providers.DefaultBackOfficeUserProvider] == null)
|
||||
if (Membership.Providers[Current.Configs.Settings().Providers.DefaultBackOfficeUserProvider] == null)
|
||||
{
|
||||
throw new InvalidOperationException("No membership provider found with name " + Current.Config.Umbraco().Providers.DefaultBackOfficeUserProvider);
|
||||
throw new InvalidOperationException("No membership provider found with name " + Current.Configs.Settings().Providers.DefaultBackOfficeUserProvider);
|
||||
}
|
||||
return Membership.Providers[Current.Config.Umbraco().Providers.DefaultBackOfficeUserProvider];
|
||||
return Membership.Providers[Current.Configs.Settings().Providers.DefaultBackOfficeUserProvider];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1114,7 +1114,7 @@ namespace Umbraco.Core
|
||||
/// <remarks>Checks <c>UmbracoSettings.ForceSafeAliases</c> to determine whether it should filter the text.</remarks>
|
||||
public static string ToSafeAliasWithForcingCheck(this string alias)
|
||||
{
|
||||
return Current.Config.Umbraco().Content.ForceSafeAliases ? alias.ToSafeAlias() : alias;
|
||||
return Current.Configs.Settings().Content.ForceSafeAliases ? alias.ToSafeAlias() : alias;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1126,7 +1126,7 @@ namespace Umbraco.Core
|
||||
/// <remarks>Checks <c>UmbracoSettings.ForceSafeAliases</c> to determine whether it should filter the text.</remarks>
|
||||
public static string ToSafeAliasWithForcingCheck(this string alias, string culture)
|
||||
{
|
||||
return Current.Config.Umbraco().Content.ForceSafeAliases ? alias.ToSafeAlias(culture) : alias;
|
||||
return Current.Configs.Settings().Content.ForceSafeAliases ? alias.ToSafeAlias(culture) : alias;
|
||||
}
|
||||
|
||||
// the new methods to get a url segment
|
||||
|
||||
@@ -204,6 +204,8 @@
|
||||
<Compile Include="Composing\WeightedCollectionBuilderBase.cs" />
|
||||
<Compile Include="Configuration\CaseInsensitiveEnumConfigConverter.cs" />
|
||||
<Compile Include="Configuration\CommaDelimitedConfigurationElement.cs" />
|
||||
<Compile Include="ConfigsExtensions.cs" />
|
||||
<Compile Include="Configuration\Configs.cs" />
|
||||
<Compile Include="Configuration\CoreDebug.cs" />
|
||||
<Compile Include="Configuration\Dashboard\AccessElement.cs" />
|
||||
<Compile Include="Configuration\Dashboard\AccessRule.cs" />
|
||||
@@ -257,7 +259,6 @@
|
||||
<Compile Include="Configuration\OptionalCommaDelimitedConfigurationElement.cs" />
|
||||
<Compile Include="Configuration\OptionalInnerTextConfigurationElement.cs" />
|
||||
<Compile Include="Configuration\RawXmlConfigurationElement.cs" />
|
||||
<Compile Include="Configuration\UmbracoConfig.cs" />
|
||||
<Compile Include="Configuration\UmbracoConfigurationSection.cs" />
|
||||
<Compile Include="Configuration\UmbracoSettings\AppCodeFileExtensionsCollection.cs" />
|
||||
<Compile Include="Configuration\UmbracoSettings\AppCodeFileExtensionsElement.cs" />
|
||||
|
||||
@@ -4,6 +4,8 @@ using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Tests.Testing;
|
||||
using Umbraco.Tests.Testing.Objects.Accessors;
|
||||
@@ -48,16 +50,14 @@ namespace Umbraco.Tests.Cache.PublishedCache
|
||||
</root>";
|
||||
}
|
||||
|
||||
public override void SetUp()
|
||||
protected override void Initialize()
|
||||
{
|
||||
base.SetUp();
|
||||
base.Initialize();
|
||||
|
||||
_httpContextFactory = new FakeHttpContextFactory("~/Home");
|
||||
|
||||
var umbracoSettings = SettingsForTests.GenerateMockUmbracoSettings();
|
||||
var globalSettings = SettingsForTests.GenerateMockGlobalSettings();
|
||||
SettingsForTests.ConfigureSettings(umbracoSettings);
|
||||
SettingsForTests.ConfigureSettings(globalSettings);
|
||||
var umbracoSettings = Factory.GetInstance<IUmbracoSettingsSection>();
|
||||
var globalSettings = Factory.GetInstance<IGlobalSettings>();
|
||||
|
||||
_xml = new XmlDocument();
|
||||
_xml.LoadXml(GetXml());
|
||||
|
||||
@@ -18,7 +18,8 @@ namespace Umbraco.Tests.Components
|
||||
public class ComponentTests
|
||||
{
|
||||
private static readonly List<Type> Composed = new List<Type>();
|
||||
private static readonly List<string> Initialized = new List<string>();
|
||||
private static readonly List<Type> Initialized = new List<Type>();
|
||||
private static readonly List<Type> Terminated = new List<Type>();
|
||||
|
||||
private static IFactory MockFactory(Action<Mock<IFactory>> setup = null)
|
||||
{
|
||||
@@ -64,13 +65,36 @@ namespace Umbraco.Tests.Components
|
||||
var composition = new Composition(register, MockTypeLoader(), Mock.Of<IProfilingLogger>(), MockRuntimeState(RuntimeLevel.Unknown));
|
||||
|
||||
var types = TypeArray<Composer1, Composer2, Composer3, Composer4>();
|
||||
var components = new Core.Components.Composers(composition, types, Mock.Of<IProfilingLogger>());
|
||||
var composers = new Composers(composition, types, Mock.Of<IProfilingLogger>());
|
||||
Composed.Clear();
|
||||
// 2 is Core and requires 4
|
||||
// 3 is User - goes away with RuntimeLevel.Unknown
|
||||
// => reorder components accordingly
|
||||
components.Compose();
|
||||
composers.Compose();
|
||||
AssertTypeArray(TypeArray<Composer1, Composer4, Composer2>(), Composed);
|
||||
|
||||
var factory = MockFactory(m =>
|
||||
{
|
||||
m.Setup(x => x.TryGetInstance(It.Is<Type>(t => t == typeof(ISomeResource)))).Returns(() => new SomeResource());
|
||||
m.Setup(x => x.GetInstance(It.IsAny<Type>())).Returns<Type>((type) =>
|
||||
{
|
||||
if (type == typeof(Composer1)) return new Composer1();
|
||||
if (type == typeof(Composer5)) return new Composer5();
|
||||
if (type == typeof(Component5)) return new Component5(new SomeResource());
|
||||
if (type == typeof(IProfilingLogger)) return new ProfilingLogger(Mock.Of<ILogger>(), Mock.Of<IProfiler>());
|
||||
throw new NotSupportedException(type.FullName);
|
||||
});
|
||||
});
|
||||
|
||||
var builder = composition.WithCollectionBuilder<ComponentCollectionBuilder>();
|
||||
builder.RegisterWith(register);
|
||||
var components = builder.CreateCollection(factory);
|
||||
|
||||
Assert.IsEmpty(components);
|
||||
components.Initialize();
|
||||
Assert.IsEmpty(Initialized);
|
||||
components.Terminate();
|
||||
Assert.IsEmpty(Terminated);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -164,6 +188,10 @@ namespace Umbraco.Tests.Components
|
||||
[Test]
|
||||
public void Initialize()
|
||||
{
|
||||
Composed.Clear();
|
||||
Initialized.Clear();
|
||||
Terminated.Clear();
|
||||
|
||||
var register = MockRegister();
|
||||
var factory = MockFactory(m =>
|
||||
{
|
||||
@@ -181,17 +209,22 @@ namespace Umbraco.Tests.Components
|
||||
|
||||
var types = new[] { typeof(Composer1), typeof(Composer5) };
|
||||
var composers = new Composers(composition, types, Mock.Of<IProfilingLogger>());
|
||||
Composed.Clear();
|
||||
Initialized.Clear();
|
||||
|
||||
Assert.IsEmpty(Composed);
|
||||
composers.Compose();
|
||||
AssertTypeArray(TypeArray<Composer1, Composer5>(), Composed);
|
||||
|
||||
var builder = composition.WithCollectionBuilder<ComponentCollectionBuilder>();
|
||||
builder.RegisterWith(register);
|
||||
var components = builder.CreateCollection(factory);
|
||||
Assert.AreEqual(2, Composed.Count);
|
||||
Assert.AreEqual(typeof(Composer1), Composed[0]);
|
||||
Assert.AreEqual(typeof(Composer5), Composed[1]);
|
||||
Assert.AreEqual(1, Initialized.Count);
|
||||
Assert.AreEqual("Umbraco.Tests.Components.ComponentTests+SomeResource", Initialized[0]);
|
||||
|
||||
Assert.IsEmpty(Initialized);
|
||||
components.Initialize();
|
||||
AssertTypeArray(TypeArray<Component5>(), Initialized);
|
||||
|
||||
Assert.IsEmpty(Terminated);
|
||||
components.Terminate();
|
||||
AssertTypeArray(TypeArray<Component5>(), Terminated);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -301,9 +334,6 @@ namespace Umbraco.Tests.Components
|
||||
}
|
||||
}
|
||||
|
||||
public class TestComponentBase : IComponent
|
||||
{ }
|
||||
|
||||
public class Composer1 : TestComposerBase
|
||||
{ }
|
||||
|
||||
@@ -326,11 +356,26 @@ namespace Umbraco.Tests.Components
|
||||
}
|
||||
}
|
||||
|
||||
public class Component5 : IComponent
|
||||
public class TestComponentBase : IComponent
|
||||
{
|
||||
public virtual void Initialize()
|
||||
{
|
||||
Initialized.Add(GetType());
|
||||
}
|
||||
|
||||
public virtual void Terminate()
|
||||
{
|
||||
Terminated.Add(GetType());
|
||||
}
|
||||
}
|
||||
|
||||
public class Component5 : TestComponentBase
|
||||
{
|
||||
private readonly ISomeResource _resource;
|
||||
|
||||
public Component5(ISomeResource resource)
|
||||
{
|
||||
Initialized.Add(resource.GetType().FullName);
|
||||
_resource = resource;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Web.Routing;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.IO;
|
||||
@@ -46,14 +47,13 @@ namespace Umbraco.Tests.Configurations
|
||||
[TestCase("~/some-wacky/nestedPath", "/MyVirtualDir/NestedVDir/", "some-wacky-nestedpath")]
|
||||
public void Umbraco_Mvc_Area(string path, string rootPath, string outcome)
|
||||
{
|
||||
var globalSettingsMock = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container
|
||||
var globalSettingsMock = Mock.Get(Factory.GetInstance<IGlobalSettings>()); //this will modify the IGlobalSettings instance stored in the container
|
||||
globalSettingsMock.Setup(x => x.Path).Returns(IOHelper.ResolveUrl(path));
|
||||
SettingsForTests.ConfigureSettings(globalSettingsMock.Object);
|
||||
|
||||
SystemDirectories.Root = rootPath;
|
||||
Assert.AreEqual(outcome, Current.Config.Global().GetUmbracoMvcArea());
|
||||
Assert.AreEqual(outcome, Current.Configs.Global().GetUmbracoMvcArea());
|
||||
}
|
||||
|
||||
|
||||
[TestCase("/umbraco/editContent.aspx")]
|
||||
[TestCase("/install/default.aspx")]
|
||||
[TestCase("/install/")]
|
||||
@@ -93,10 +93,9 @@ namespace Umbraco.Tests.Configurations
|
||||
public void Is_Reserved_By_Route(string url, bool shouldMatch)
|
||||
{
|
||||
//reset the app config, we only want to test routes not the hard coded paths
|
||||
var globalSettingsMock = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container
|
||||
var globalSettingsMock = Mock.Get(Factory.GetInstance<IGlobalSettings>()); //this will modify the IGlobalSettings instance stored in the container
|
||||
globalSettingsMock.Setup(x => x.ReservedPaths).Returns("");
|
||||
globalSettingsMock.Setup(x => x.ReservedUrls).Returns("");
|
||||
SettingsForTests.ConfigureSettings(globalSettingsMock.Object);
|
||||
|
||||
var routes = new RouteCollection();
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Core.Strings;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Tests.Testing;
|
||||
|
||||
namespace Umbraco.Tests.CoreThings
|
||||
@@ -10,14 +11,11 @@ namespace Umbraco.Tests.CoreThings
|
||||
[TestFixture]
|
||||
public class TryConvertToTests : UmbracoTestBase
|
||||
{
|
||||
public override void SetUp()
|
||||
protected void Compose()
|
||||
{
|
||||
base.SetUp();
|
||||
base.Compose();
|
||||
|
||||
var settings = SettingsForTests.GetDefaultUmbracoSettings();
|
||||
|
||||
// fixme - base should do it!
|
||||
Composition.RegisterUnique<IShortStringHelper>(_ => new DefaultShortStringHelper(settings));
|
||||
Composition.RegisterUnique<IShortStringHelper>(f => new DefaultShortStringHelper(f.GetInstance<IUmbracoSettingsSection>()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -26,10 +26,6 @@ namespace Umbraco.Tests.IO
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
//init the config singleton
|
||||
var config = SettingsForTests.GetDefaultUmbracoSettings();
|
||||
SettingsForTests.ConfigureSettings(config);
|
||||
|
||||
_register = RegisterFactory.Create();
|
||||
|
||||
var composition = new Composition(_register, new TypeLoader(), Mock.Of<IProfilingLogger>(), ComponentTests.MockRuntimeState(RuntimeLevel.Run));
|
||||
@@ -39,10 +35,18 @@ namespace Umbraco.Tests.IO
|
||||
composition.Register(_ => Mock.Of<IContentSection>());
|
||||
composition.RegisterUnique<IMediaPathScheme, OriginalMediaPathScheme>();
|
||||
|
||||
composition.Configs.Add(SettingsForTests.GetDefaultGlobalSettings);
|
||||
composition.Configs.Add(SettingsForTests.GetDefaultUmbracoSettings);
|
||||
|
||||
composition.ComposeFileSystems();
|
||||
|
||||
composition.Configs.Add(SettingsForTests.GetDefaultUmbracoSettings);
|
||||
|
||||
_factory = composition.CreateFactory();
|
||||
|
||||
Current.Reset();
|
||||
Current.Factory = _factory;
|
||||
|
||||
// make sure we start clean
|
||||
// because some tests will create corrupt or weird filesystems
|
||||
FileSystems.Reset();
|
||||
|
||||
@@ -6,6 +6,7 @@ using Umbraco.Core;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Web.Macros;
|
||||
@@ -27,7 +28,9 @@ namespace Umbraco.Tests.Macros
|
||||
new IsolatedRuntimeCache(type => new ObjectCacheRuntimeCacheProvider()));
|
||||
//Current.ApplicationContext = new ApplicationContext(cacheHelper, new ProfilingLogger(Mock.Of<ILogger>(), Mock.Of<IProfiler>()));
|
||||
|
||||
Current.Config.SetUmbracoConfig(SettingsForTests.GetDefaultUmbracoSettings());
|
||||
Current.Reset();
|
||||
Current.UnlockConfigs();
|
||||
Current.Configs.Add(SettingsForTests.GetDefaultUmbracoSettings);
|
||||
}
|
||||
|
||||
[TestCase("123", "IntProp", typeof(int))]
|
||||
|
||||
@@ -90,7 +90,6 @@ namespace Umbraco.Tests.Misc
|
||||
var settings = SettingsForTests.GenerateMockUmbracoSettings();
|
||||
var requestMock = Mock.Get(settings.RequestHandler);
|
||||
requestMock.Setup(x => x.AddTrailingSlash).Returns(trailingSlash);
|
||||
SettingsForTests.ConfigureSettings(settings);
|
||||
|
||||
UriUtility.SetAppDomainAppVirtualPath("/");
|
||||
|
||||
|
||||
@@ -7,18 +7,14 @@ using System.Threading;
|
||||
using Moq;
|
||||
using Umbraco.Core;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Composing.Composers;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Entities;
|
||||
using Umbraco.Core.Serialization;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Tests.TestHelpers.Entities;
|
||||
using Umbraco.Tests.TestHelpers.Stubs;
|
||||
using Umbraco.Tests.Testing;
|
||||
@@ -29,14 +25,6 @@ namespace Umbraco.Tests.Models
|
||||
[TestFixture]
|
||||
public class ContentTests : UmbracoTestBase
|
||||
{
|
||||
public override void SetUp()
|
||||
{
|
||||
base.SetUp();
|
||||
|
||||
var config = SettingsForTests.GetDefaultUmbracoSettings();
|
||||
SettingsForTests.ConfigureSettings(config);
|
||||
}
|
||||
|
||||
protected override void Compose()
|
||||
{
|
||||
base.Compose();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Entities;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
@@ -13,8 +14,9 @@ namespace Umbraco.Tests.Models
|
||||
[SetUp]
|
||||
public void Init()
|
||||
{
|
||||
var config = SettingsForTests.GetDefaultUmbracoSettings();
|
||||
SettingsForTests.ConfigureSettings(config);
|
||||
Current.Reset();
|
||||
Current.UnlockConfigs();
|
||||
Current.Configs.Add(SettingsForTests.GetDefaultUmbracoSettings);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Entities;
|
||||
using Umbraco.Core.Serialization;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Tests.TestHelpers.Entities;
|
||||
|
||||
namespace Umbraco.Tests.Models
|
||||
@@ -12,6 +13,15 @@ namespace Umbraco.Tests.Models
|
||||
[TestFixture]
|
||||
public class MemberTests
|
||||
{
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
Current.Reset();
|
||||
Current.UnlockConfigs();
|
||||
Current.Configs.Add(SettingsForTests.GetDefaultGlobalSettings);
|
||||
Current.Configs.Add(SettingsForTests.GetDefaultUmbracoSettings);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Deep_Clone()
|
||||
{
|
||||
|
||||
@@ -2,14 +2,24 @@
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using Umbraco.Core.Serialization;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
|
||||
namespace Umbraco.Tests.Models
|
||||
{
|
||||
[TestFixture]
|
||||
public class UserTests
|
||||
{
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
Current.Reset();
|
||||
Current.UnlockConfigs();
|
||||
Current.Configs.Add(SettingsForTests.GetDefaultGlobalSettings);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Deep_Clone()
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@ using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
@@ -26,6 +27,11 @@ namespace Umbraco.Tests.Models
|
||||
// need to be able to retrieve them all...
|
||||
|
||||
Current.Reset();
|
||||
|
||||
var configs = new Configs();
|
||||
configs.Add(SettingsForTests.GetDefaultGlobalSettings);
|
||||
configs.Add(SettingsForTests.GetDefaultUmbracoSettings);
|
||||
|
||||
var factory = Mock.Of<IFactory>();
|
||||
Current.Factory = factory;
|
||||
|
||||
@@ -53,12 +59,12 @@ namespace Umbraco.Tests.Models
|
||||
.Setup(x => x.GetInstance(It.IsAny<Type>()))
|
||||
.Returns<Type>(x =>
|
||||
{
|
||||
if (x == typeof(Configs)) return configs;
|
||||
if (x == typeof(PropertyEditorCollection)) return propertyEditors;
|
||||
if (x == typeof(ServiceContext)) return serviceContext;
|
||||
if (x == typeof(ILocalizedTextService)) return serviceContext.LocalizationService;
|
||||
throw new Exception("oops");
|
||||
throw new NotSupportedException(x.FullName);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -429,7 +435,7 @@ namespace Umbraco.Tests.Models
|
||||
Assert.IsTrue(content.IsCultureAvailable(langUk));
|
||||
Assert.IsFalse(content.IsCulturePublished(langUk));
|
||||
Assert.IsNull(content.GetPublishName(langUk));
|
||||
Assert.IsNull(content.GetPublishDate(langUk)); // not published
|
||||
Assert.IsNull(content.GetPublishDate(langUk)); // not published
|
||||
|
||||
Assert.IsFalse(content.IsCultureAvailable(langEs));
|
||||
Assert.IsFalse(content.IsCultureEdited(langEs)); // not avail, so... not edited
|
||||
@@ -437,7 +443,7 @@ namespace Umbraco.Tests.Models
|
||||
|
||||
// not published!
|
||||
Assert.IsNull(content.GetPublishName(langEs));
|
||||
Assert.IsNull(content.GetPublishDate(langEs));
|
||||
Assert.IsNull(content.GetPublishDate(langEs));
|
||||
|
||||
// cannot test IsCultureEdited here - as that requires the content service and repository
|
||||
// see: ContentServiceTests.Can_SaveRead_Variations
|
||||
|
||||
@@ -35,8 +35,11 @@ namespace Umbraco.Tests.PublishedContent
|
||||
// this test implements a full standalone NuCache (based upon a test IDataSource, does not
|
||||
// use any local db files, does not rely on any database) - and tests variations
|
||||
|
||||
SettingsForTests.ConfigureSettings(SettingsForTests.GenerateMockUmbracoSettings());
|
||||
var globalSettings = Current.Config.Global();
|
||||
Current.Reset();
|
||||
Current.UnlockConfigs();
|
||||
Current.Configs.Add(SettingsForTests.GenerateMockUmbracoSettings);
|
||||
Current.Configs.Add<IGlobalSettings>(() => new GlobalSettings());
|
||||
var globalSettings = Current.Configs.Global();
|
||||
|
||||
// create a content node kit
|
||||
var kit = new ContentNodeKit
|
||||
|
||||
@@ -104,7 +104,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
Assert.AreEqual("<div>This is some content</div>", propVal2.ToString());
|
||||
|
||||
var propVal3 = publishedMedia.Value("Content");
|
||||
Assert.IsInstanceOf<IHtmlString>(propVal3);
|
||||
Assert.IsInstanceOf<IHtmlString>(propVal3);
|
||||
Assert.AreEqual("<div>This is some content</div>", propVal3.ToString());
|
||||
}
|
||||
|
||||
@@ -461,10 +461,6 @@ namespace Umbraco.Tests.PublishedContent
|
||||
[Test]
|
||||
public void Convert_From_Standard_Xml()
|
||||
{
|
||||
var config = SettingsForTests.GenerateMockUmbracoSettings();
|
||||
|
||||
SettingsForTests.ConfigureSettings(config);
|
||||
|
||||
var nodeId = 2112;
|
||||
|
||||
var xml = XElement.Parse(@"<Image id=""2112"" version=""5b3e46ab-3e37-4cfa-ab70-014234b5bd39"" parentID=""2222"" level=""3"" writerID=""0"" nodeType=""1032"" template=""0"" sortOrder=""1"" createDate=""2010-05-19T17:32:46"" updateDate=""2010-05-19T17:32:46"" nodeName=""Sam's Umbraco Image"" urlName=""acnestressscrub"" writerName=""Administrator"" nodeTypeAlias=""Image"" path=""-1,1111,2222,2112"" isDoc="""">
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Web.Routing;
|
||||
using Umbraco.Core.Models;
|
||||
@@ -27,10 +29,8 @@ namespace Umbraco.Tests.Routing
|
||||
[TestCase("/home/Sub1.aspx/blah")]
|
||||
public void Match_Document_By_Url_With_Template(string urlAsString)
|
||||
{
|
||||
|
||||
var globalSettings = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container
|
||||
var globalSettings = Mock.Get(Factory.GetInstance<IGlobalSettings>()); //this will modify the IGlobalSettings instance stored in the container
|
||||
globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false);
|
||||
SettingsForTests.ConfigureSettings(globalSettings.Object);
|
||||
|
||||
var template1 = CreateTemplate("test");
|
||||
var template2 = CreateTemplate("blah");
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Globalization;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Models;
|
||||
@@ -28,16 +29,15 @@ namespace Umbraco.Tests.Routing
|
||||
[TestCase("/test-page", 1172)]
|
||||
public void Match_Document_By_Url_Hide_Top_Level(string urlString, int expectedId)
|
||||
{
|
||||
var globalSettingsMock = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container
|
||||
var globalSettingsMock = Mock.Get(Factory.GetInstance<IGlobalSettings>()); //this will modify the IGlobalSettings instance stored in the container
|
||||
globalSettingsMock.Setup(x => x.HideTopLevelNodeFromPath).Returns(true);
|
||||
SettingsForTests.ConfigureSettings(globalSettingsMock.Object);
|
||||
|
||||
var umbracoContext = GetUmbracoContext(urlString, globalSettings:globalSettingsMock.Object);
|
||||
var publishedRouter = CreatePublishedRouter();
|
||||
var frequest = publishedRouter.CreateRequest(umbracoContext);
|
||||
var lookup = new ContentFinderByUrl(Logger);
|
||||
|
||||
Assert.IsTrue(Current.Config.Global().HideTopLevelNodeFromPath);
|
||||
Assert.IsTrue(Current.Configs.Global().HideTopLevelNodeFromPath);
|
||||
|
||||
// fixme debugging - going further down, the routes cache is NOT empty?!
|
||||
if (urlString == "/home/sub1")
|
||||
@@ -64,16 +64,15 @@ namespace Umbraco.Tests.Routing
|
||||
[TestCase("/home/Sub1.aspx", 1173)]
|
||||
public void Match_Document_By_Url(string urlString, int expectedId)
|
||||
{
|
||||
var globalSettingsMock = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container
|
||||
var globalSettingsMock = Mock.Get(Factory.GetInstance<IGlobalSettings>()); //this will modify the IGlobalSettings instance stored in the container
|
||||
globalSettingsMock.Setup(x => x.HideTopLevelNodeFromPath).Returns(false);
|
||||
SettingsForTests.ConfigureSettings(globalSettingsMock.Object);
|
||||
|
||||
var umbracoContext = GetUmbracoContext(urlString, globalSettings:globalSettingsMock.Object);
|
||||
var publishedRouter = CreatePublishedRouter();
|
||||
var frequest = publishedRouter.CreateRequest(umbracoContext);
|
||||
var lookup = new ContentFinderByUrl(Logger);
|
||||
|
||||
Assert.IsFalse(Current.Config.Global().HideTopLevelNodeFromPath);
|
||||
Assert.IsFalse(Current.Configs.Global().HideTopLevelNodeFromPath);
|
||||
|
||||
var result = lookup.TryFindContent(frequest);
|
||||
|
||||
@@ -90,9 +89,8 @@ namespace Umbraco.Tests.Routing
|
||||
[TestCase("/home/sub1/custom-sub-4-with-æøå", 1180)]
|
||||
public void Match_Document_By_Url_With_Special_Characters(string urlString, int expectedId)
|
||||
{
|
||||
var globalSettingsMock = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container
|
||||
var globalSettingsMock = Mock.Get(Factory.GetInstance<IGlobalSettings>()); //this will modify the IGlobalSettings instance stored in the container
|
||||
globalSettingsMock.Setup(x => x.HideTopLevelNodeFromPath).Returns(false);
|
||||
SettingsForTests.ConfigureSettings(globalSettingsMock.Object);
|
||||
|
||||
var umbracoContext = GetUmbracoContext(urlString, globalSettings:globalSettingsMock.Object);
|
||||
var publishedRouter = CreatePublishedRouter();
|
||||
@@ -118,9 +116,8 @@ namespace Umbraco.Tests.Routing
|
||||
[TestCase("/home/sub1/custom-sub-4-with-æøå", 1180)]
|
||||
public void Match_Document_By_Url_With_Special_Characters_Using_Hostname(string urlString, int expectedId)
|
||||
{
|
||||
var globalSettingsMock = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container
|
||||
var globalSettingsMock = Mock.Get(Factory.GetInstance<IGlobalSettings>()); //this will modify the IGlobalSettings instance stored in the container
|
||||
globalSettingsMock.Setup(x => x.HideTopLevelNodeFromPath).Returns(false);
|
||||
SettingsForTests.ConfigureSettings(globalSettingsMock.Object);
|
||||
|
||||
var umbracoContext = GetUmbracoContext(urlString, globalSettings:globalSettingsMock.Object);
|
||||
var publishedRouter = CreatePublishedRouter();
|
||||
@@ -148,9 +145,8 @@ namespace Umbraco.Tests.Routing
|
||||
[TestCase("/æøå/home/sub1/custom-sub-4-with-æøå", 1180)]
|
||||
public void Match_Document_By_Url_With_Special_Characters_In_Hostname(string urlString, int expectedId)
|
||||
{
|
||||
var globalSettingsMock = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container
|
||||
var globalSettingsMock = Mock.Get(Factory.GetInstance<IGlobalSettings>()); //this will modify the IGlobalSettings instance stored in the container
|
||||
globalSettingsMock.Setup(x => x.HideTopLevelNodeFromPath).Returns(false);
|
||||
SettingsForTests.ConfigureSettings(globalSettingsMock.Object);
|
||||
|
||||
var umbracoContext = GetUmbracoContext(urlString, globalSettings:globalSettingsMock.Object);
|
||||
var publishedRouter = CreatePublishedRouter();
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Web.Routing;
|
||||
@@ -124,10 +126,9 @@ namespace Umbraco.Tests.Routing
|
||||
{
|
||||
SetDomains3();
|
||||
|
||||
var globalSettingsMock = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container
|
||||
var globalSettingsMock = Mock.Get(Factory.GetInstance<IGlobalSettings>()); //this will modify the IGlobalSettings instance stored in the container
|
||||
globalSettingsMock.Setup(x => x.HideTopLevelNodeFromPath).Returns(true);
|
||||
SettingsForTests.ConfigureSettings(globalSettingsMock.Object);
|
||||
|
||||
|
||||
var umbracoContext = GetUmbracoContext(url, globalSettings:globalSettingsMock.Object);
|
||||
var publishedRouter = CreatePublishedRouter(Factory);
|
||||
var frequest = publishedRouter.CreateRequest(umbracoContext);
|
||||
@@ -167,9 +168,8 @@ namespace Umbraco.Tests.Routing
|
||||
// defaults depend on test environment
|
||||
expectedCulture = expectedCulture ?? System.Threading.Thread.CurrentThread.CurrentUICulture.Name;
|
||||
|
||||
var globalSettingsMock = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container
|
||||
var globalSettingsMock = Mock.Get(Factory.GetInstance<IGlobalSettings>()); //this will modify the IGlobalSettings instance stored in the container
|
||||
globalSettingsMock.Setup(x => x.HideTopLevelNodeFromPath).Returns(true);
|
||||
SettingsForTests.ConfigureSettings(globalSettingsMock.Object);
|
||||
|
||||
var umbracoContext = GetUmbracoContext(url, globalSettings:globalSettingsMock.Object);
|
||||
var publishedRouter = CreatePublishedRouter(Factory);
|
||||
|
||||
@@ -5,6 +5,7 @@ using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Web.Routing;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
|
||||
namespace Umbraco.Tests.Routing
|
||||
{
|
||||
@@ -265,9 +266,8 @@ namespace Umbraco.Tests.Routing
|
||||
{
|
||||
SetDomains1();
|
||||
|
||||
var globalSettings = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container
|
||||
var globalSettings = Mock.Get(Factory.GetInstance<IGlobalSettings>()); //this will modify the IGlobalSettings instance stored in the container
|
||||
globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false);
|
||||
SettingsForTests.ConfigureSettings(globalSettings.Object);
|
||||
|
||||
var umbracoContext = GetUmbracoContext(inputUrl, globalSettings:globalSettings.Object);
|
||||
var publishedRouter = CreatePublishedRouter(Factory);
|
||||
@@ -315,9 +315,8 @@ namespace Umbraco.Tests.Routing
|
||||
// defaults depend on test environment
|
||||
expectedCulture = expectedCulture ?? System.Threading.Thread.CurrentThread.CurrentUICulture.Name;
|
||||
|
||||
var globalSettings = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container
|
||||
var globalSettings = Mock.Get(Factory.GetInstance<IGlobalSettings>()); //this will modify the IGlobalSettings instance stored in the container
|
||||
globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false);
|
||||
SettingsForTests.ConfigureSettings(globalSettings.Object);
|
||||
|
||||
var umbracoContext = GetUmbracoContext(inputUrl, globalSettings:globalSettings.Object);
|
||||
var publishedRouter = CreatePublishedRouter(Factory);
|
||||
@@ -371,9 +370,8 @@ namespace Umbraco.Tests.Routing
|
||||
{
|
||||
SetDomains3();
|
||||
|
||||
var globalSettings = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container
|
||||
var globalSettings = Mock.Get(Factory.GetInstance<IGlobalSettings>()); //this will modify the IGlobalSettings instance stored in the container
|
||||
globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false);
|
||||
SettingsForTests.ConfigureSettings(globalSettings.Object);
|
||||
var umbracoContext = GetUmbracoContext(inputUrl, globalSettings:globalSettings.Object);
|
||||
var publishedRouter = CreatePublishedRouter(Factory);
|
||||
var frequest = publishedRouter.CreateRequest(umbracoContext);
|
||||
|
||||
@@ -3,10 +3,11 @@ using System.Globalization;
|
||||
using System.Linq;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Tests.TestHelpers.Entities;
|
||||
using Umbraco.Web.Routing;
|
||||
|
||||
@@ -15,17 +16,6 @@ namespace Umbraco.Tests.Routing
|
||||
[TestFixture]
|
||||
public class GetContentUrlsTests : UrlRoutingTestBase
|
||||
{
|
||||
private IUmbracoSettingsSection _umbracoSettings;
|
||||
|
||||
public override void SetUp()
|
||||
{
|
||||
base.SetUp();
|
||||
|
||||
//generate new mock settings and assign so we can configure in individual tests
|
||||
_umbracoSettings = SettingsForTests.GenerateMockUmbracoSettings();
|
||||
SettingsForTests.ConfigureSettings(_umbracoSettings);
|
||||
}
|
||||
|
||||
private ILocalizedTextService GetTextService()
|
||||
{
|
||||
var textService = Mock.Of<ILocalizedTextService>(
|
||||
@@ -80,8 +70,10 @@ namespace Umbraco.Tests.Routing
|
||||
content.Path = "-1,1046";
|
||||
content.Published = true;
|
||||
|
||||
var umbracoSettings = Current.Configs.Settings();
|
||||
|
||||
var umbContext = GetUmbracoContext("http://localhost:8000",
|
||||
urlProviders: new []{ new DefaultUrlProvider(_umbracoSettings.RequestHandler, Logger, TestObjects.GetGlobalSettings(), new SiteDomainHelper()) });
|
||||
urlProviders: new []{ new DefaultUrlProvider(umbracoSettings.RequestHandler, Logger, TestObjects.GetGlobalSettings(), new SiteDomainHelper()) });
|
||||
var publishedRouter = CreatePublishedRouter(Factory,
|
||||
contentFinders:new ContentFinderCollection(new[]{new ContentFinderByUrl(Logger) }));
|
||||
var urls = content.GetContentUrls(publishedRouter,
|
||||
@@ -110,8 +102,10 @@ namespace Umbraco.Tests.Routing
|
||||
child.Path = "-1,1046,1173";
|
||||
child.Published = true;
|
||||
|
||||
var umbracoSettings = Current.Configs.Settings();
|
||||
|
||||
var umbContext = GetUmbracoContext("http://localhost:8000",
|
||||
urlProviders: new[] { new DefaultUrlProvider(_umbracoSettings.RequestHandler, Logger, TestObjects.GetGlobalSettings(), new SiteDomainHelper()) });
|
||||
urlProviders: new[] { new DefaultUrlProvider(umbracoSettings.RequestHandler, Logger, TestObjects.GetGlobalSettings(), new SiteDomainHelper()) });
|
||||
var publishedRouter = CreatePublishedRouter(Factory,
|
||||
contentFinders: new ContentFinderCollection(new[] { new ContentFinderByUrl(Logger) }));
|
||||
var urls = child.GetContentUrls(publishedRouter,
|
||||
|
||||
@@ -6,7 +6,7 @@ using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
@@ -28,15 +28,10 @@ namespace Umbraco.Tests.Routing
|
||||
Composition.Register<ISiteDomainHelper, SiteDomainHelper>();
|
||||
}
|
||||
|
||||
private IUmbracoSettingsSection _umbracoSettings;
|
||||
|
||||
public override void SetUp()
|
||||
protected override void ComposeSettings()
|
||||
{
|
||||
base.SetUp();
|
||||
|
||||
//generate new mock settings and assign so we can configure in individual tests
|
||||
_umbracoSettings = SettingsForTests.GenerateMockUmbracoSettings();
|
||||
SettingsForTests.ConfigureSettings(_umbracoSettings);
|
||||
Composition.Configs.Add(SettingsForTests.GenerateMockUmbracoSettings);
|
||||
Composition.Configs.Add(SettingsForTests.GenerateMockGlobalSettings);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -46,17 +41,18 @@ namespace Umbraco.Tests.Routing
|
||||
[Test]
|
||||
public void Ensure_Cache_Is_Correct()
|
||||
{
|
||||
var globalSettings = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container
|
||||
var globalSettings = Mock.Get(Factory.GetInstance<IGlobalSettings>()); //this will modify the IGlobalSettings instance stored in the container
|
||||
globalSettings.Setup(x => x.UseDirectoryUrls).Returns(true);
|
||||
globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false);
|
||||
SettingsForTests.ConfigureSettings(globalSettings.Object);
|
||||
|
||||
var umbracoSettings = Current.Configs.Settings();
|
||||
|
||||
var umbracoContext = GetUmbracoContext("/test", 1111, urlProviders: new[]
|
||||
{
|
||||
new DefaultUrlProvider(_umbracoSettings.RequestHandler, Logger, globalSettings.Object, new SiteDomainHelper())
|
||||
new DefaultUrlProvider(umbracoSettings.RequestHandler, Logger, globalSettings.Object, new SiteDomainHelper())
|
||||
}, globalSettings: globalSettings.Object);
|
||||
|
||||
var requestHandlerMock = Mock.Get(_umbracoSettings.RequestHandler);
|
||||
var requestHandlerMock = Mock.Get(umbracoSettings.RequestHandler);
|
||||
requestHandlerMock.Setup(x => x.AddTrailingSlash).Returns(false);// (cached routes have none)
|
||||
|
||||
var samples = new Dictionary<int, string> {
|
||||
@@ -109,17 +105,18 @@ namespace Umbraco.Tests.Routing
|
||||
[TestCase(1172, "/test-page/")]
|
||||
public void Get_Url_Not_Hiding_Top_Level(int nodeId, string niceUrlMatch)
|
||||
{
|
||||
var globalSettings = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container
|
||||
var globalSettings = Mock.Get(Factory.GetInstance<IGlobalSettings>()); //this will modify the IGlobalSettings instance stored in the container
|
||||
globalSettings.Setup(x => x.UseDirectoryUrls).Returns(true);
|
||||
globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false);
|
||||
SettingsForTests.ConfigureSettings(globalSettings.Object);
|
||||
|
||||
var umbracoSettings = Current.Configs.Settings();
|
||||
|
||||
var umbracoContext = GetUmbracoContext("/test", 1111, urlProviders: new[]
|
||||
{
|
||||
new DefaultUrlProvider(_umbracoSettings.RequestHandler, Logger, globalSettings.Object, new SiteDomainHelper())
|
||||
new DefaultUrlProvider(umbracoSettings.RequestHandler, Logger, globalSettings.Object, new SiteDomainHelper())
|
||||
}, globalSettings: globalSettings.Object);
|
||||
|
||||
var requestMock = Mock.Get(_umbracoSettings.RequestHandler);
|
||||
var requestMock = Mock.Get(umbracoSettings.RequestHandler);
|
||||
requestMock.Setup(x => x.UseDomainPrefixes).Returns(false);
|
||||
|
||||
var result = umbracoContext.UrlProvider.GetUrl(nodeId);
|
||||
@@ -139,17 +136,18 @@ namespace Umbraco.Tests.Routing
|
||||
[TestCase(1172, "/test-page/")] // not hidden because not first root
|
||||
public void Get_Url_Hiding_Top_Level(int nodeId, string niceUrlMatch)
|
||||
{
|
||||
var globalSettings = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container
|
||||
var globalSettings = Mock.Get(Factory.GetInstance<IGlobalSettings>()); //this will modify the IGlobalSettings instance stored in the container
|
||||
globalSettings.Setup(x => x.UseDirectoryUrls).Returns(true);
|
||||
globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(true);
|
||||
SettingsForTests.ConfigureSettings(globalSettings.Object);
|
||||
|
||||
var umbracoSettings = Current.Configs.Settings();
|
||||
|
||||
var umbracoContext = GetUmbracoContext("/test", 1111, urlProviders: new[]
|
||||
{
|
||||
new DefaultUrlProvider(_umbracoSettings.RequestHandler, Logger, globalSettings.Object, new SiteDomainHelper())
|
||||
new DefaultUrlProvider(umbracoSettings.RequestHandler, Logger, globalSettings.Object, new SiteDomainHelper())
|
||||
}, globalSettings: globalSettings.Object);
|
||||
|
||||
var requestMock = Mock.Get(_umbracoSettings.RequestHandler);
|
||||
var requestMock = Mock.Get(umbracoSettings.RequestHandler);
|
||||
requestMock.Setup(x => x.UseDomainPrefixes).Returns(false);
|
||||
|
||||
var result = umbracoContext.UrlProvider.GetUrl(nodeId);
|
||||
@@ -161,12 +159,13 @@ namespace Umbraco.Tests.Routing
|
||||
{
|
||||
const string currentUri = "http://example.us/test";
|
||||
|
||||
var globalSettings = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container
|
||||
var globalSettings = Mock.Get(Factory.GetInstance<IGlobalSettings>()); //this will modify the IGlobalSettings instance stored in the container
|
||||
globalSettings.Setup(x => x.UseDirectoryUrls).Returns(true);
|
||||
globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false);
|
||||
SettingsForTests.ConfigureSettings(globalSettings.Object);
|
||||
|
||||
var requestMock = Mock.Get(_umbracoSettings.RequestHandler);
|
||||
var umbracoSettings = Current.Configs.Settings();
|
||||
|
||||
var requestMock = Mock.Get(umbracoSettings.RequestHandler);
|
||||
requestMock.Setup(x => x.UseDomainPrefixes).Returns(false);
|
||||
|
||||
var contentType = new PublishedContentType(666, "alias", PublishedItemType.Content, Enumerable.Empty<string>(), Enumerable.Empty<PublishedPropertyType>(), ContentVariation.Culture);
|
||||
@@ -188,9 +187,9 @@ namespace Umbraco.Tests.Routing
|
||||
snapshotService.Setup(x => x.CreatePublishedSnapshot(It.IsAny<string>()))
|
||||
.Returns(snapshot);
|
||||
|
||||
var umbracoContext = GetUmbracoContext(currentUri, umbracoSettings: _umbracoSettings,
|
||||
var umbracoContext = GetUmbracoContext(currentUri, umbracoSettings: umbracoSettings,
|
||||
urlProviders: new[] {
|
||||
new DefaultUrlProvider(_umbracoSettings.RequestHandler, Logger, globalSettings.Object, new SiteDomainHelper())
|
||||
new DefaultUrlProvider(umbracoSettings.RequestHandler, Logger, globalSettings.Object, new SiteDomainHelper())
|
||||
},
|
||||
globalSettings: globalSettings.Object,
|
||||
snapshotService: snapshotService.Object);
|
||||
@@ -209,12 +208,13 @@ namespace Umbraco.Tests.Routing
|
||||
{
|
||||
const string currentUri = "http://example.fr/test";
|
||||
|
||||
var globalSettings = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container
|
||||
var globalSettings = Mock.Get(Factory.GetInstance<IGlobalSettings>()); //this will modify the IGlobalSettings instance stored in the container
|
||||
globalSettings.Setup(x => x.UseDirectoryUrls).Returns(true);
|
||||
globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false);
|
||||
SettingsForTests.ConfigureSettings(globalSettings.Object);
|
||||
|
||||
var requestMock = Mock.Get(_umbracoSettings.RequestHandler);
|
||||
var umbracoSettings = Current.Configs.Settings();
|
||||
|
||||
var requestMock = Mock.Get(umbracoSettings.RequestHandler);
|
||||
requestMock.Setup(x => x.UseDomainPrefixes).Returns(false);
|
||||
|
||||
var contentType = new PublishedContentType(666, "alias", PublishedItemType.Content, Enumerable.Empty<string>(), Enumerable.Empty<PublishedPropertyType>(), ContentVariation.Culture);
|
||||
@@ -245,9 +245,9 @@ namespace Umbraco.Tests.Routing
|
||||
snapshotService.Setup(x => x.CreatePublishedSnapshot(It.IsAny<string>()))
|
||||
.Returns(snapshot);
|
||||
|
||||
var umbracoContext = GetUmbracoContext(currentUri, umbracoSettings: _umbracoSettings,
|
||||
var umbracoContext = GetUmbracoContext(currentUri, umbracoSettings: umbracoSettings,
|
||||
urlProviders: new[] {
|
||||
new DefaultUrlProvider(_umbracoSettings.RequestHandler, Logger, globalSettings.Object, new SiteDomainHelper())
|
||||
new DefaultUrlProvider(umbracoSettings.RequestHandler, Logger, globalSettings.Object, new SiteDomainHelper())
|
||||
},
|
||||
globalSettings: globalSettings.Object,
|
||||
snapshotService: snapshotService.Object);
|
||||
@@ -266,12 +266,13 @@ namespace Umbraco.Tests.Routing
|
||||
{
|
||||
const string currentUri = "http://example.us/test";
|
||||
|
||||
var globalSettings = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container
|
||||
var globalSettings = Mock.Get(Factory.GetInstance<IGlobalSettings>()); //this will modify the IGlobalSettings instance stored in the container
|
||||
globalSettings.Setup(x => x.UseDirectoryUrls).Returns(true);
|
||||
globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false);
|
||||
SettingsForTests.ConfigureSettings(globalSettings.Object);
|
||||
|
||||
var requestMock = Mock.Get(_umbracoSettings.RequestHandler);
|
||||
var umbracoSettings = Current.Configs.Settings();
|
||||
|
||||
var requestMock = Mock.Get(umbracoSettings.RequestHandler);
|
||||
requestMock.Setup(x => x.UseDomainPrefixes).Returns(false);
|
||||
|
||||
var contentType = new PublishedContentType(666, "alias", PublishedItemType.Content, Enumerable.Empty<string>(), Enumerable.Empty<PublishedPropertyType>(), ContentVariation.Culture);
|
||||
@@ -302,9 +303,9 @@ namespace Umbraco.Tests.Routing
|
||||
snapshotService.Setup(x => x.CreatePublishedSnapshot(It.IsAny<string>()))
|
||||
.Returns(snapshot);
|
||||
|
||||
var umbracoContext = GetUmbracoContext(currentUri, umbracoSettings: _umbracoSettings,
|
||||
var umbracoContext = GetUmbracoContext(currentUri, umbracoSettings: umbracoSettings,
|
||||
urlProviders: new[] {
|
||||
new DefaultUrlProvider(_umbracoSettings.RequestHandler, Logger, globalSettings.Object, new SiteDomainHelper())
|
||||
new DefaultUrlProvider(umbracoSettings.RequestHandler, Logger, globalSettings.Object, new SiteDomainHelper())
|
||||
},
|
||||
globalSettings: globalSettings.Object,
|
||||
snapshotService: snapshotService.Object);
|
||||
@@ -319,17 +320,18 @@ namespace Umbraco.Tests.Routing
|
||||
[Test]
|
||||
public void Get_Url_Relative_Or_Absolute()
|
||||
{
|
||||
var globalSettings = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container
|
||||
var globalSettings = Mock.Get(Factory.GetInstance<IGlobalSettings>()); //this will modify the IGlobalSettings instance stored in the container
|
||||
globalSettings.Setup(x => x.UseDirectoryUrls).Returns(true);
|
||||
globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false);
|
||||
SettingsForTests.ConfigureSettings(globalSettings.Object);
|
||||
|
||||
var requestMock = Mock.Get(_umbracoSettings.RequestHandler);
|
||||
var umbracoSettings = Current.Configs.Settings();
|
||||
|
||||
var requestMock = Mock.Get(umbracoSettings.RequestHandler);
|
||||
requestMock.Setup(x => x.UseDomainPrefixes).Returns(false);
|
||||
|
||||
var umbracoContext = GetUmbracoContext("http://example.com/test", 1111, umbracoSettings: _umbracoSettings, urlProviders: new[]
|
||||
var umbracoContext = GetUmbracoContext("http://example.com/test", 1111, umbracoSettings: umbracoSettings, urlProviders: new[]
|
||||
{
|
||||
new DefaultUrlProvider(_umbracoSettings.RequestHandler, Logger, globalSettings.Object, new SiteDomainHelper())
|
||||
new DefaultUrlProvider(umbracoSettings.RequestHandler, Logger, globalSettings.Object, new SiteDomainHelper())
|
||||
}, globalSettings: globalSettings.Object);
|
||||
|
||||
Assert.AreEqual("/home/sub1/custom-sub-1/", umbracoContext.UrlProvider.GetUrl(1177));
|
||||
@@ -345,18 +347,19 @@ namespace Umbraco.Tests.Routing
|
||||
[Test]
|
||||
public void Get_Url_Unpublished()
|
||||
{
|
||||
var globalSettings = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container
|
||||
var globalSettings = Mock.Get(Factory.GetInstance<IGlobalSettings>()); //this will modify the IGlobalSettings instance stored in the container
|
||||
globalSettings.Setup(x => x.UseDirectoryUrls).Returns(true);
|
||||
globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false);
|
||||
SettingsForTests.ConfigureSettings(globalSettings.Object);
|
||||
|
||||
var umbracoSettings = Current.Configs.Settings();
|
||||
|
||||
var umbracoContext = GetUmbracoContext("http://example.com/test", 1111, urlProviders: new[]
|
||||
{
|
||||
new DefaultUrlProvider(_umbracoSettings.RequestHandler, Logger, globalSettings.Object, new SiteDomainHelper())
|
||||
new DefaultUrlProvider(umbracoSettings.RequestHandler, Logger, globalSettings.Object, new SiteDomainHelper())
|
||||
}, globalSettings: globalSettings.Object);
|
||||
|
||||
//mock the Umbraco settings that we need
|
||||
var requestMock = Mock.Get(_umbracoSettings.RequestHandler);
|
||||
var requestMock = Mock.Get(umbracoSettings.RequestHandler);
|
||||
requestMock.Setup(x => x.UseDomainPrefixes).Returns(false);
|
||||
|
||||
Assert.AreEqual("#", umbracoContext.UrlProvider.GetUrl(999999));
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Tests.Testing;
|
||||
@@ -193,9 +195,8 @@ DetermineRouteById(id):
|
||||
[TestCase(2006, false, "/x/b/e")]
|
||||
public void GetRouteByIdNoHide(int id, bool hide, string expected)
|
||||
{
|
||||
var globalSettings = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container
|
||||
var globalSettings = Mock.Get(Factory.GetInstance<IGlobalSettings>()); //this will modify the IGlobalSettings instance stored in the container
|
||||
globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(hide);
|
||||
SettingsForTests.ConfigureSettings(globalSettings.Object);
|
||||
|
||||
var umbracoContext = GetUmbracoContext("/test", 0, globalSettings: globalSettings.Object);
|
||||
var cache = umbracoContext.ContentCache as PublishedContentCache;
|
||||
@@ -218,9 +219,8 @@ DetermineRouteById(id):
|
||||
[TestCase(2006, true, "/b/e")] // risky!
|
||||
public void GetRouteByIdHide(int id, bool hide, string expected)
|
||||
{
|
||||
var globalSettings = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container
|
||||
var globalSettings = Mock.Get(Factory.GetInstance<IGlobalSettings>()); //this will modify the IGlobalSettings instance stored in the container
|
||||
globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(hide);
|
||||
SettingsForTests.ConfigureSettings(globalSettings.Object);
|
||||
|
||||
var umbracoContext = GetUmbracoContext("/test", 0, globalSettings: globalSettings.Object);
|
||||
var cache = umbracoContext.ContentCache as PublishedContentCache;
|
||||
@@ -233,14 +233,13 @@ DetermineRouteById(id):
|
||||
[Test]
|
||||
public void GetRouteByIdCache()
|
||||
{
|
||||
var globalSettings = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container
|
||||
var globalSettings = Mock.Get(Factory.GetInstance<IGlobalSettings>()); //this will modify the IGlobalSettings instance stored in the container
|
||||
globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false);
|
||||
SettingsForTests.ConfigureSettings(globalSettings.Object);
|
||||
|
||||
var umbracoContext = GetUmbracoContext("/test", 0, globalSettings:globalSettings.Object);
|
||||
var cache = umbracoContext.ContentCache as PublishedContentCache;
|
||||
if (cache == null) throw new Exception("Unsupported IPublishedContentCache, only the Xml one is supported.");
|
||||
|
||||
|
||||
var route = cache.GetRouteById(false, 1000);
|
||||
Assert.AreEqual("/a", route);
|
||||
|
||||
@@ -265,9 +264,8 @@ DetermineRouteById(id):
|
||||
[TestCase("/x", false, 2000)]
|
||||
public void GetByRouteNoHide(string route, bool hide, int expected)
|
||||
{
|
||||
var globalSettings = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container
|
||||
var globalSettings = Mock.Get(Factory.GetInstance<IGlobalSettings>()); //this will modify the IGlobalSettings instance stored in the container
|
||||
globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(hide);
|
||||
SettingsForTests.ConfigureSettings(globalSettings.Object);
|
||||
|
||||
var umbracoContext = GetUmbracoContext("/test", 0, globalSettings:globalSettings.Object);
|
||||
var cache = umbracoContext.ContentCache as PublishedContentCache;
|
||||
@@ -297,9 +295,8 @@ DetermineRouteById(id):
|
||||
[TestCase("/b/c", true, 1002)] // (hence the 2005 collision)
|
||||
public void GetByRouteHide(string route, bool hide, int expected)
|
||||
{
|
||||
var globalSettings = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container
|
||||
var globalSettings = Mock.Get(Factory.GetInstance<IGlobalSettings>()); //this will modify the IGlobalSettings instance stored in the container
|
||||
globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(hide);
|
||||
SettingsForTests.ConfigureSettings(globalSettings.Object);
|
||||
|
||||
var umbracoContext = GetUmbracoContext("/test", 0, globalSettings:globalSettings.Object);
|
||||
var cache = umbracoContext.ContentCache as PublishedContentCache;
|
||||
@@ -321,14 +318,13 @@ DetermineRouteById(id):
|
||||
[Test]
|
||||
public void GetByRouteCache()
|
||||
{
|
||||
var globalSettings = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container
|
||||
var globalSettings = Mock.Get(Factory.GetInstance<IGlobalSettings>()); //this will modify the IGlobalSettings instance stored in the container
|
||||
globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false);
|
||||
SettingsForTests.ConfigureSettings(globalSettings.Object);
|
||||
|
||||
var umbracoContext = GetUmbracoContext("/test", 0, globalSettings:globalSettings.Object);
|
||||
var cache = umbracoContext.ContentCache as PublishedContentCache;
|
||||
if (cache == null) throw new Exception("Unsupported IPublishedContentCache, only the Xml one is supported.");
|
||||
|
||||
|
||||
var content = cache.GetByRoute(false, "/a/b/c");
|
||||
Assert.IsNotNull(content);
|
||||
Assert.AreEqual(1002, content.Id);
|
||||
|
||||
@@ -5,6 +5,7 @@ using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
@@ -178,10 +179,9 @@ namespace Umbraco.Tests.Routing
|
||||
var request = Mock.Get(settings.RequestHandler);
|
||||
request.Setup(x => x.UseDomainPrefixes).Returns(false);
|
||||
|
||||
var globalSettings = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container
|
||||
var globalSettings = Mock.Get(Factory.GetInstance<IGlobalSettings>()); //this will modify the IGlobalSettings instance stored in the container
|
||||
globalSettings.Setup(x => x.UseDirectoryUrls).Returns(true);
|
||||
globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false); // ignored w/domains
|
||||
SettingsForTests.ConfigureSettings(globalSettings.Object);
|
||||
|
||||
var umbracoContext = GetUmbracoContext("/test", 1111, umbracoSettings: settings, urlProviders: new[]
|
||||
{
|
||||
@@ -214,10 +214,9 @@ namespace Umbraco.Tests.Routing
|
||||
var request = Mock.Get(settings.RequestHandler);
|
||||
request.Setup(x => x.UseDomainPrefixes).Returns(false);
|
||||
|
||||
var globalSettings = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container
|
||||
var globalSettings = Mock.Get(Factory.GetInstance<IGlobalSettings>()); //this will modify the IGlobalSettings instance stored in the container
|
||||
globalSettings.Setup(x => x.UseDirectoryUrls).Returns(true);
|
||||
globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false); // ignored w/domains
|
||||
SettingsForTests.ConfigureSettings(globalSettings.Object);
|
||||
|
||||
var umbracoContext = GetUmbracoContext("/test", 1111, umbracoSettings: settings, urlProviders: new[]
|
||||
{
|
||||
@@ -242,10 +241,9 @@ namespace Umbraco.Tests.Routing
|
||||
var request = Mock.Get(settings.RequestHandler);
|
||||
request.Setup(x => x.UseDomainPrefixes).Returns(false);
|
||||
|
||||
var globalSettings = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container
|
||||
var globalSettings = Mock.Get(Factory.GetInstance<IGlobalSettings>()); //this will modify the IGlobalSettings instance stored in the container
|
||||
globalSettings.Setup(x => x.UseDirectoryUrls).Returns(true);
|
||||
globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false); // ignored w/domains
|
||||
SettingsForTests.ConfigureSettings(globalSettings.Object);
|
||||
|
||||
var umbracoContext = GetUmbracoContext("/test", 1111, umbracoSettings: settings, urlProviders: new[]
|
||||
{
|
||||
@@ -276,10 +274,9 @@ namespace Umbraco.Tests.Routing
|
||||
var request = Mock.Get(settings.RequestHandler);
|
||||
request.Setup(x => x.UseDomainPrefixes).Returns(false);
|
||||
|
||||
var globalSettings = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container
|
||||
var globalSettings = Mock.Get(Factory.GetInstance<IGlobalSettings>()); //this will modify the IGlobalSettings instance stored in the container
|
||||
globalSettings.Setup(x => x.UseDirectoryUrls).Returns(true);
|
||||
globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false); // ignored w/domains
|
||||
SettingsForTests.ConfigureSettings(globalSettings.Object);
|
||||
|
||||
var umbracoContext = GetUmbracoContext("/test", 1111, umbracoSettings: settings, urlProviders: new[]
|
||||
{
|
||||
@@ -300,10 +297,9 @@ namespace Umbraco.Tests.Routing
|
||||
var request = Mock.Get(settings.RequestHandler);
|
||||
request.Setup(x => x.UseDomainPrefixes).Returns(false);
|
||||
|
||||
var globalSettings = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container
|
||||
var globalSettings = Mock.Get(Factory.GetInstance<IGlobalSettings>()); //this will modify the IGlobalSettings instance stored in the container
|
||||
globalSettings.Setup(x => x.UseDirectoryUrls).Returns(true);
|
||||
globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false); // ignored w/domains
|
||||
SettingsForTests.ConfigureSettings(globalSettings.Object);
|
||||
|
||||
var umbracoContext = GetUmbracoContext("/test", 1111, umbracoSettings: settings, urlProviders: new[]
|
||||
{
|
||||
@@ -367,10 +363,9 @@ namespace Umbraco.Tests.Routing
|
||||
var requestMock = Mock.Get(settings.RequestHandler);
|
||||
requestMock.Setup(x => x.UseDomainPrefixes).Returns(false);
|
||||
|
||||
var globalSettings = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container
|
||||
var globalSettings = Mock.Get(Factory.GetInstance<IGlobalSettings>()); //this will modify the IGlobalSettings instance stored in the container
|
||||
globalSettings.Setup(x => x.UseDirectoryUrls).Returns(true);
|
||||
globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false); // ignored w/domains
|
||||
SettingsForTests.ConfigureSettings(globalSettings.Object);
|
||||
|
||||
var umbracoContext = GetUmbracoContext("http://domain1.com/test", 1111, umbracoSettings: settings, urlProviders: new[]
|
||||
{
|
||||
@@ -399,10 +394,9 @@ namespace Umbraco.Tests.Routing
|
||||
{
|
||||
var settings = SettingsForTests.GenerateMockUmbracoSettings();
|
||||
|
||||
var globalSettings = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container
|
||||
var globalSettings = Mock.Get(Factory.GetInstance<IGlobalSettings>()); //this will modify the IGlobalSettings instance stored in the container
|
||||
globalSettings.Setup(x => x.UseDirectoryUrls).Returns(true);
|
||||
globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false); // ignored w/domains
|
||||
SettingsForTests.ConfigureSettings(globalSettings.Object);
|
||||
|
||||
var umbracoContext = GetUmbracoContext("http://domain1.com/en/test", 1111, umbracoSettings: settings, urlProviders: new[]
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@ using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Web.PublishedCache.XmlPublishedCache;
|
||||
@@ -29,10 +30,9 @@ namespace Umbraco.Tests.Routing
|
||||
[Test]
|
||||
public void DoNotPolluteCache()
|
||||
{
|
||||
var globalSettings = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container
|
||||
var globalSettings = Mock.Get(Factory.GetInstance<IGlobalSettings>()); //this will modify the IGlobalSettings instance stored in the container
|
||||
globalSettings.Setup(x => x.UseDirectoryUrls).Returns(true);
|
||||
globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false);
|
||||
SettingsForTests.ConfigureSettings(globalSettings.Object);
|
||||
|
||||
var settings = SettingsForTests.GenerateMockUmbracoSettings();
|
||||
var request = Mock.Get(settings.RequestHandler);
|
||||
|
||||
@@ -8,6 +8,7 @@ using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Components;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Events;
|
||||
using Umbraco.Core.Exceptions;
|
||||
using Umbraco.Core.Logging;
|
||||
@@ -27,12 +28,7 @@ namespace Umbraco.Tests.Runtimes
|
||||
public void SetUp()
|
||||
{
|
||||
TestComponent.Reset();
|
||||
|
||||
// cannot boot runtime without some configuration
|
||||
var umbracoSettings = SettingsForTests.GenerateMockUmbracoSettings();
|
||||
var globalSettings = SettingsForTests.GenerateMockGlobalSettings();
|
||||
SettingsForTests.ConfigureSettings(umbracoSettings);
|
||||
SettingsForTests.ConfigureSettings(globalSettings);
|
||||
Current.Reset();
|
||||
}
|
||||
|
||||
public void TearDown()
|
||||
@@ -106,6 +102,14 @@ namespace Umbraco.Tests.Runtimes
|
||||
return mock.Object;
|
||||
}
|
||||
|
||||
protected override Configs GetConfigs()
|
||||
{
|
||||
var configs = new Configs();
|
||||
configs.Add(SettingsForTests.GetDefaultGlobalSettings);
|
||||
configs.Add(SettingsForTests.GetDefaultUmbracoSettings);
|
||||
return configs;
|
||||
}
|
||||
|
||||
// fixme so how the f* should we do it now?
|
||||
/*
|
||||
// pretend we have the proper migration
|
||||
@@ -191,8 +195,7 @@ namespace Umbraco.Tests.Runtimes
|
||||
{
|
||||
// test flags
|
||||
public static bool Ctored;
|
||||
public static bool Initialized1;
|
||||
public static bool Initialized2;
|
||||
public static bool Initialized;
|
||||
public static bool Terminated;
|
||||
public static IProfilingLogger ProfilingLogger;
|
||||
|
||||
@@ -200,7 +203,7 @@ namespace Umbraco.Tests.Runtimes
|
||||
|
||||
public static void Reset()
|
||||
{
|
||||
Ctored = Initialized1 = Initialized2 = Terminated = false;
|
||||
Ctored = Initialized = Terminated = false;
|
||||
ProfilingLogger = null;
|
||||
}
|
||||
|
||||
@@ -210,10 +213,19 @@ namespace Umbraco.Tests.Runtimes
|
||||
ProfilingLogger = proflog;
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
Initialized = true;
|
||||
}
|
||||
|
||||
public void Terminate()
|
||||
{
|
||||
Terminated = true;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Disposed = true;
|
||||
Terminated = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,6 +107,10 @@ namespace Umbraco.Tests.Runtimes
|
||||
.Clear()
|
||||
.Append<DistributedCacheBinderComponent>();
|
||||
|
||||
// configure
|
||||
composition.Configs.Add(SettingsForTests.GetDefaultGlobalSettings);
|
||||
composition.Configs.Add(SettingsForTests.GetDefaultUmbracoSettings);
|
||||
|
||||
// create and register the factory
|
||||
Current.Factory = factory = composition.CreateFactory();
|
||||
|
||||
@@ -150,11 +154,6 @@ namespace Umbraco.Tests.Runtimes
|
||||
// done installing
|
||||
runtimeState.Level = RuntimeLevel.Run;
|
||||
|
||||
var globalSettings = SettingsForTests.GetDefaultGlobalSettings();
|
||||
SettingsForTests.ConfigureSettings(globalSettings);
|
||||
var umbracoSettings = SettingsForTests.GetDefaultUmbracoSettings();
|
||||
SettingsForTests.ConfigureSettings(umbracoSettings);
|
||||
|
||||
// instantiate to register events
|
||||
// should be done by Initialize?
|
||||
// should we invoke Initialize?
|
||||
@@ -260,9 +259,9 @@ namespace Umbraco.Tests.Runtimes
|
||||
// get the components
|
||||
// all of them?
|
||||
var composerTypes = typeLoader.GetTypes<IComposer>();
|
||||
// filtered?
|
||||
//var componentTypes = typeLoader.GetTypes<IUmbracoComponent>()
|
||||
// .Where(x => !x.FullName.StartsWith("Umbraco.Web"));
|
||||
// filtered
|
||||
composerTypes = composerTypes
|
||||
.Where(x => !x.FullName.StartsWith("Umbraco.Tests"));
|
||||
// single?
|
||||
//var componentTypes = new[] { typeof(CoreRuntimeComponent) };
|
||||
var composers = new Composers(composition, composerTypes, profilingLogger);
|
||||
|
||||
@@ -3,7 +3,6 @@ using System.Linq;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Components;
|
||||
using Umbraco.Core.Events;
|
||||
using Umbraco.Core.Models;
|
||||
@@ -13,7 +12,6 @@ using Umbraco.Core.Scoping;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Tests.TestHelpers.Entities;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Persistence.Mappers;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Tests.Components;
|
||||
@@ -42,6 +40,9 @@ namespace Umbraco.Tests.Scoping
|
||||
composition.RegisterUnique(factory => new FileSystems(factory, factory.TryGetInstance<ILogger>()));
|
||||
composition.WithCollectionBuilder<MapperCollectionBuilder>();
|
||||
|
||||
composition.Configs.Add(SettingsForTests.GetDefaultGlobalSettings);
|
||||
composition.Configs.Add(SettingsForTests.GetDefaultUmbracoSettings);
|
||||
|
||||
Current.Reset();
|
||||
Current.Factory = composition.CreateFactory();
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Core.Events;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models;
|
||||
@@ -39,6 +40,12 @@ namespace Umbraco.Tests.Scoping
|
||||
.Add(() => Composition.TypeLoader.GetCacheRefreshers());
|
||||
}
|
||||
|
||||
protected override void ComposeSettings()
|
||||
{
|
||||
Composition.Configs.Add(SettingsForTests.GenerateMockUmbracoSettings);
|
||||
Composition.Configs.Add(SettingsForTests.GenerateMockGlobalSettings);
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void Teardown()
|
||||
{
|
||||
@@ -79,10 +86,8 @@ namespace Umbraco.Tests.Scoping
|
||||
Assert.AreSame(XmlStore, ((PublishedContentCache) umbracoContext.ContentCache).XmlStore);
|
||||
|
||||
// settings
|
||||
var settings = SettingsForTests.GenerateMockUmbracoSettings();
|
||||
var contentMock = Mock.Get(settings.Content);
|
||||
var contentMock = Mock.Get(Factory.GetInstance<IUmbracoSettingsSection>().Content);
|
||||
contentMock.Setup(x => x.XmlCacheEnabled).Returns(false);
|
||||
SettingsForTests.ConfigureSettings(settings);
|
||||
|
||||
// create document type, document
|
||||
var contentType = new ContentType(-1) { Alias = "CustomDocument", Name = "Custom Document" };
|
||||
@@ -200,9 +205,8 @@ namespace Umbraco.Tests.Scoping
|
||||
|
||||
// settings
|
||||
var settings = SettingsForTests.GenerateMockUmbracoSettings();
|
||||
var contentMock = Mock.Get(settings.Content);
|
||||
var contentMock = Mock.Get(Factory.GetInstance<IUmbracoSettingsSection>().Content);
|
||||
contentMock.Setup(x => x.XmlCacheEnabled).Returns(false);
|
||||
SettingsForTests.ConfigureSettings(settings);
|
||||
|
||||
// create document type
|
||||
var contentType = new ContentType(-1) { Alias = "CustomDocument", Name = "Custom Document" };
|
||||
|
||||
@@ -9,15 +9,6 @@ namespace Umbraco.Tests.Strings
|
||||
[TestFixture]
|
||||
public class CmsHelperCasingTests : UmbracoTestBase
|
||||
{
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
//set default config
|
||||
var config = SettingsForTests.GetDefaultUmbracoSettings();
|
||||
SettingsForTests.ConfigureSettings(config);
|
||||
|
||||
}
|
||||
|
||||
[TestCase("thisIsTheEnd", "This Is The End")]
|
||||
[TestCase("th", "Th")]
|
||||
[TestCase("t", "t")]
|
||||
|
||||
@@ -123,7 +123,6 @@ namespace Umbraco.Tests.Strings
|
||||
var contentMock = Mock.Get(settings.RequestHandler);
|
||||
contentMock.Setup(x => x.CharCollection).Returns(Enumerable.Empty<IChar>());
|
||||
contentMock.Setup(x => x.ConvertUrlsToAscii).Returns(false);
|
||||
SettingsForTests.ConfigureSettings(settings);
|
||||
|
||||
const string input1 = "ÆØÅ and æøå and 中文测试 and אודות האתר and größer БбДдЖж page";
|
||||
const string input2 = "ÆØÅ and æøå and größer БбДдЖж page";
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO;
|
||||
using System.Configuration;
|
||||
using Moq;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Core.IO;
|
||||
@@ -12,22 +10,6 @@ namespace Umbraco.Tests.TestHelpers
|
||||
{
|
||||
public class SettingsForTests
|
||||
{
|
||||
public static void ConfigureSettings(IGlobalSettings settings)
|
||||
{
|
||||
Current.Config.SetGlobalConfig(settings);
|
||||
}
|
||||
|
||||
// umbracoSettings
|
||||
|
||||
/// <summary>
|
||||
/// Sets the umbraco settings singleton to the object specified
|
||||
/// </summary>
|
||||
/// <param name="settings"></param>
|
||||
public static void ConfigureSettings(IUmbracoSettingsSection settings)
|
||||
{
|
||||
Current.Config.SetUmbracoConfig(settings);
|
||||
}
|
||||
|
||||
public static IGlobalSettings GenerateMockGlobalSettings()
|
||||
{
|
||||
var config = Mock.Of<IGlobalSettings>(
|
||||
@@ -132,8 +114,6 @@ namespace Umbraco.Tests.TestHelpers
|
||||
private static void ResetSettings()
|
||||
{
|
||||
_defaultGlobalSettings = null;
|
||||
ConfigureSettings(GetDefaultUmbracoSettings());
|
||||
ConfigureSettings(GetDefaultGlobalSettings());
|
||||
}
|
||||
|
||||
private static IUmbracoSettingsSection _defaultUmbracoSettings;
|
||||
|
||||
@@ -131,9 +131,8 @@ namespace Umbraco.Tests.TestHelpers
|
||||
}
|
||||
|
||||
// ensure the configuration matches the current version for tests
|
||||
var globalSettingsMock = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container
|
||||
var globalSettingsMock = Mock.Get(Factory.GetInstance<IGlobalSettings>()); //this will modify the IGlobalSettings instance stored in the container
|
||||
globalSettingsMock.Setup(x => x.ConfigurationStatus).Returns(UmbracoVersion.Current.ToString(3));
|
||||
SettingsForTests.ConfigureSettings(globalSettingsMock.Object);
|
||||
|
||||
using (ProfilingLogger.TraceDuration<TestWithDatabaseBase>("Initialize database."))
|
||||
{
|
||||
|
||||
@@ -287,25 +287,25 @@ namespace Umbraco.Tests.Testing
|
||||
// create the schema
|
||||
}
|
||||
|
||||
protected virtual void ComposeSettings()
|
||||
{
|
||||
Composition.Configs.Add(SettingsForTests.GetDefaultUmbracoSettings);
|
||||
Composition.Configs.Add(SettingsForTests.GetDefaultGlobalSettings);
|
||||
}
|
||||
|
||||
protected virtual void ComposeApplication(bool withApplication)
|
||||
{
|
||||
if (withApplication == false) return;
|
||||
ComposeSettings();
|
||||
|
||||
var umbracoSettings = SettingsForTests.GetDefaultUmbracoSettings();
|
||||
var globalSettings = SettingsForTests.GetDefaultGlobalSettings();
|
||||
//apply these globally
|
||||
SettingsForTests.ConfigureSettings(umbracoSettings);
|
||||
SettingsForTests.ConfigureSettings(globalSettings);
|
||||
if (withApplication == false) return;
|
||||
|
||||
// default Datalayer/Repositories/SQL/Database/etc...
|
||||
Composition.ComposeRepositories();
|
||||
|
||||
// register basic stuff that might need to be there for some container resolvers to work
|
||||
Composition.RegisterUnique(factory => umbracoSettings);
|
||||
Composition.RegisterUnique(factory => globalSettings);
|
||||
Composition.RegisterUnique(factory => umbracoSettings.Content);
|
||||
Composition.RegisterUnique(factory => umbracoSettings.Templates);
|
||||
Composition.RegisterUnique(factory => umbracoSettings.WebRouting);
|
||||
Composition.RegisterUnique(factory => factory.GetInstance<IUmbracoSettingsSection>().Content);
|
||||
Composition.RegisterUnique(factory => factory.GetInstance<IUmbracoSettingsSection>().Templates);
|
||||
Composition.RegisterUnique(factory => factory.GetInstance<IUmbracoSettingsSection>().WebRouting);
|
||||
|
||||
Composition.RegisterUnique<IExamineManager>(factory => ExamineManager.Instance);
|
||||
|
||||
|
||||
@@ -37,17 +37,19 @@ namespace Umbraco.Tests.Web
|
||||
var serviceContext = ServiceContext.CreatePartial(entityService: entityService.Object);
|
||||
|
||||
// fixme - bad in a unit test - but Udi has a static ctor that wants it?!
|
||||
var container = new Mock<IFactory>();
|
||||
container.Setup(x => x.GetInstance(typeof(TypeLoader))).Returns(
|
||||
var factory = new Mock<IFactory>();
|
||||
factory.Setup(x => x.GetInstance(typeof(TypeLoader))).Returns(
|
||||
new TypeLoader(NullCacheProvider.Instance, LocalTempStorage.Default, new ProfilingLogger(Mock.Of<ILogger>(), Mock.Of<IProfiler>())));
|
||||
container.Setup(x => x.GetInstance(typeof (ServiceContext))).Returns(serviceContext);
|
||||
Current.Factory = container.Object;
|
||||
factory.Setup(x => x.GetInstance(typeof (ServiceContext))).Returns(serviceContext);
|
||||
|
||||
var settings = SettingsForTests.GetDefaultUmbracoSettings();
|
||||
factory.Setup(x => x.GetInstance(typeof(IUmbracoSettingsSection))).Returns(settings);
|
||||
|
||||
Current.Factory = factory.Object;
|
||||
|
||||
Umbraco.Web.Composing.Current.UmbracoContextAccessor = new TestUmbracoContextAccessor();
|
||||
|
||||
Udi.ResetUdiTypes();
|
||||
|
||||
Current.Config.SetUmbracoConfig(SettingsForTests.GetDefaultUmbracoSettings());
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
|
||||
+7
-21
@@ -5152,14 +5152,12 @@
|
||||
"balanced-match": {
|
||||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"brace-expansion": {
|
||||
"version": "1.1.11",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"balanced-match": "^1.0.0",
|
||||
"concat-map": "0.0.1"
|
||||
@@ -5174,20 +5172,17 @@
|
||||
"code-point-at": {
|
||||
"version": "1.1.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"concat-map": {
|
||||
"version": "0.0.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"console-control-strings": {
|
||||
"version": "1.1.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"core-util-is": {
|
||||
"version": "1.0.2",
|
||||
@@ -5304,8 +5299,7 @@
|
||||
"inherits": {
|
||||
"version": "2.0.3",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"ini": {
|
||||
"version": "1.3.5",
|
||||
@@ -5317,7 +5311,6 @@
|
||||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"number-is-nan": "^1.0.0"
|
||||
}
|
||||
@@ -5332,7 +5325,6 @@
|
||||
"version": "3.0.4",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"brace-expansion": "^1.1.7"
|
||||
}
|
||||
@@ -5340,14 +5332,12 @@
|
||||
"minimist": {
|
||||
"version": "0.0.8",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"minipass": {
|
||||
"version": "2.2.4",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"safe-buffer": "^5.1.1",
|
||||
"yallist": "^3.0.0"
|
||||
@@ -5366,7 +5356,6 @@
|
||||
"version": "0.5.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"minimist": "0.0.8"
|
||||
}
|
||||
@@ -5447,8 +5436,7 @@
|
||||
"number-is-nan": {
|
||||
"version": "1.0.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"object-assign": {
|
||||
"version": "4.1.1",
|
||||
@@ -5460,7 +5448,6 @@
|
||||
"version": "1.4.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"wrappy": "1"
|
||||
}
|
||||
@@ -5582,7 +5569,6 @@
|
||||
"version": "1.0.2",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"code-point-at": "^1.0.0",
|
||||
"is-fullwidth-code-point": "^1.0.0",
|
||||
|
||||
+4
@@ -18,6 +18,7 @@
|
||||
|
||||
<umb-toggle
|
||||
checked="vm.checked"
|
||||
disabled="vm.disabled"
|
||||
on-click="vm.toggle()"
|
||||
show-labels="true"
|
||||
label-on="Start"
|
||||
@@ -38,6 +39,7 @@
|
||||
|
||||
var vm = this;
|
||||
vm.checked = false;
|
||||
vm.disabled = false;
|
||||
|
||||
vm.toggle = toggle;
|
||||
|
||||
@@ -52,6 +54,7 @@
|
||||
</pre>
|
||||
|
||||
@param {boolean} checked Set to <code>true</code> or <code>false</code> to toggle the switch.
|
||||
@param {boolean} disabled Set to <code>true</code> or <code>false</code> to disable the switch.
|
||||
@param {callback} onClick The function which should be called when the toggle is clicked.
|
||||
@param {string=} showLabels Set to <code>true</code> or <code>false</code> to show a "On" or "Off" label next to the switch.
|
||||
@param {string=} labelOn Set a custom label for when the switched is turned on. It will default to "On".
|
||||
@@ -115,6 +118,7 @@
|
||||
templateUrl: 'views/components/buttons/umb-toggle.html',
|
||||
scope: {
|
||||
checked: "=",
|
||||
disabled: "=",
|
||||
onClick: "&",
|
||||
labelOn: "@?",
|
||||
labelOff: "@?",
|
||||
|
||||
@@ -28,7 +28,8 @@
|
||||
|
||||
.umb-toggle__toggle {
|
||||
cursor: pointer;
|
||||
display: inline-block;
|
||||
align-items: center;
|
||||
display: flex;
|
||||
width: 48px;
|
||||
height: 24px;
|
||||
background: @gray-8;
|
||||
@@ -41,6 +42,11 @@
|
||||
background-color: @green;
|
||||
}
|
||||
|
||||
.umb-toggle--disabled .umb-toggle__toggle {
|
||||
cursor: not-allowed;
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.umb-toggle--checked .umb-toggle__handler {
|
||||
transform: translate3d(24px, 0, 0) rotate(0);
|
||||
}
|
||||
@@ -63,7 +69,7 @@
|
||||
|
||||
.umb-toggle__icon {
|
||||
position: absolute;
|
||||
top: 3px;
|
||||
line-height: 1em;
|
||||
text-decoration: none;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
@@ -4,10 +4,6 @@
|
||||
padding: 7px 0;
|
||||
}
|
||||
|
||||
.umb-permission--disabled {
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.umb-permission:last-of-type {
|
||||
border-bottom: none;
|
||||
}
|
||||
@@ -25,6 +21,12 @@
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.umb-permission--disabled .umb-permission__toggle,
|
||||
.umb-permission--disabled .umb-permission__content {
|
||||
cursor: not-allowed;
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.umb-permission__description {
|
||||
font-size: 13px;
|
||||
color: @gray-4;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<button ng-click="click()" type="button" class="umb-toggle" ng-class="{'umb-toggle--checked': checked}">
|
||||
<button ng-click="click()" type="button" class="umb-toggle" ng-disabled="disabled" ng-class="{'umb-toggle--checked': checked, 'umb-toggle--disabled': disabled}">
|
||||
|
||||
<span ng-if="!labelPosition && showLabels === 'true' || labelPosition === 'left' && showLabels === 'true'">
|
||||
<span ng-if="!checked" class="umb-toggle__label umb-toggle__label--left">{{ displayLabelOff }}</span>
|
||||
|
||||
@@ -39,7 +39,8 @@
|
||||
<div class="umb-permission" ng-click="vm.toggleDefault()" ng-class="{'umb-permission--disabled': vm.initIsDefault}">
|
||||
<umb-toggle
|
||||
class="umb-permission__toggle"
|
||||
checked="vm.language.isDefault">
|
||||
checked="vm.language.isDefault"
|
||||
disabled="vm.initIsDefault">
|
||||
</umb-toggle>
|
||||
<div class="umb-permission__content" >
|
||||
<div>{{vm.labels.defaultLanguage}}</div>
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
hide-icon="true"
|
||||
hide-description="true"
|
||||
hide-alias="true"
|
||||
navigation="content.apps">
|
||||
navigation="content.apps"
|
||||
on-select-navigation-item="appChanged(app)">
|
||||
</umb-editor-header>
|
||||
|
||||
<umb-editor-container>
|
||||
|
||||
@@ -95,8 +95,11 @@ function mediaEditController($scope, $routeParams, $q, appState, mediaResource,
|
||||
|
||||
function init() {
|
||||
|
||||
// set first app to active
|
||||
$scope.content.apps[0].active = true;
|
||||
if (!$scope.app) {
|
||||
// set first app to active
|
||||
$scope.content.apps[0].active = true;
|
||||
$scope.app = $scope.content.apps[0];
|
||||
}
|
||||
|
||||
// setup infinite mode
|
||||
if(infiniteMode) {
|
||||
@@ -207,6 +210,10 @@ function mediaEditController($scope, $routeParams, $q, appState, mediaResource,
|
||||
}
|
||||
};
|
||||
|
||||
$scope.appChanged = function (app) {
|
||||
$scope.app = app;
|
||||
}
|
||||
|
||||
evts.push(eventsService.on("editors.mediaType.saved", function(name, args) {
|
||||
// if this media item uses the updated media type we need to reload the media item
|
||||
if(args && args.mediaType && args.mediaType.key === $scope.content.contentType.key) {
|
||||
|
||||
@@ -107,7 +107,7 @@
|
||||
<PackageReference Include="MySql.Data" Version="6.10.7" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
|
||||
<PackageReference Include="Umbraco.ModelsBuilder.Ui">
|
||||
<Version>8.0.0-alpha.26</Version>
|
||||
<Version>8.0.0-alpha.29</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Umbraco.SqlServerCE" Version="4.0.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -118,7 +118,7 @@
|
||||
on-login="hideLoginScreen()">
|
||||
</umb-login>
|
||||
|
||||
@Html.BareMinimumServerVariablesScript(Url, Url.Action("ExternalLogin", "BackOffice", new { area = ViewBag.UmbracoPath }), Model.Features, Current.Config.Global())
|
||||
@Html.BareMinimumServerVariablesScript(Url, Url.Action("ExternalLogin", "BackOffice", new { area = ViewBag.UmbracoPath }), Model.Features, Current.Configs.Global())
|
||||
|
||||
<script>
|
||||
|
||||
|
||||
@@ -303,11 +303,11 @@
|
||||
<system.codedom>
|
||||
<compilers>
|
||||
<compiler language="c#;cs;csharp" extension=".cs"
|
||||
type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
|
||||
type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
|
||||
warningLevel="4"
|
||||
compilerOptions="/langversion:7 /nowarn:1659;1699;1701" />
|
||||
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb"
|
||||
type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
|
||||
type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
|
||||
warningLevel="4"
|
||||
compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+"/>
|
||||
</compilers>
|
||||
|
||||
@@ -4,9 +4,19 @@ namespace Umbraco.Web.Cache
|
||||
{
|
||||
public class DistributedCacheBinderComponent : IComponent
|
||||
{
|
||||
private readonly IDistributedCacheBinder _binder;
|
||||
|
||||
public DistributedCacheBinderComponent(IDistributedCacheBinder distributedCacheBinder)
|
||||
{
|
||||
distributedCacheBinder.BindEvents();
|
||||
_binder = distributedCacheBinder;
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
_binder.BindEvents();
|
||||
}
|
||||
|
||||
public void Terminate()
|
||||
{ }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,17 +12,14 @@ namespace Umbraco.Web.Components
|
||||
private readonly IAuditService _auditService;
|
||||
private readonly IUserService _userService;
|
||||
|
||||
private IUser GetPerformingUser(int userId)
|
||||
{
|
||||
var found = userId >= 0 ? _userService.GetUserById(userId) : null;
|
||||
return found ?? new User {Id = 0, Name = "SYSTEM", Email = ""};
|
||||
}
|
||||
|
||||
public BackOfficeUserAuditEventsComponent(IAuditService auditService, IUserService userService)
|
||||
{
|
||||
_auditService = auditService;
|
||||
_userService = userService;
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
//BackOfficeUserManager.AccountLocked += ;
|
||||
//BackOfficeUserManager.AccountUnlocked += ;
|
||||
BackOfficeUserManager.ForgotPasswordRequested += OnForgotPasswordRequest;
|
||||
@@ -34,7 +31,15 @@ namespace Umbraco.Web.Components
|
||||
BackOfficeUserManager.PasswordChanged += OnPasswordChanged;
|
||||
BackOfficeUserManager.PasswordReset += OnPasswordReset;
|
||||
//BackOfficeUserManager.ResetAccessFailedCount += ;
|
||||
}
|
||||
|
||||
public void Terminate()
|
||||
{ }
|
||||
|
||||
private IUser GetPerformingUser(int userId)
|
||||
{
|
||||
var found = userId >= 0 ? _userService.GetUserById(userId) : null;
|
||||
return found ?? new User { Id = 0, Name = "SYSTEM", Email = "" };
|
||||
}
|
||||
|
||||
private static string FormatEmail(IMembershipUser user)
|
||||
@@ -42,7 +47,6 @@ namespace Umbraco.Web.Components
|
||||
return user == null ? string.Empty : user.Email.IsNullOrWhiteSpace() ? "" : $"<{user.Email}>";
|
||||
}
|
||||
|
||||
|
||||
private void OnLoginSuccess(object sender, EventArgs args)
|
||||
{
|
||||
if (args is IdentityAuditEventArgs identityArgs)
|
||||
|
||||
@@ -121,7 +121,10 @@ namespace Umbraco.Web.Components
|
||||
new BackgroundTaskRunnerOptions { AutoStart = true }, logger);
|
||||
_processTaskRunner = new BackgroundTaskRunner<IBackgroundTask>("ServerInstProcess",
|
||||
new BackgroundTaskRunnerOptions { AutoStart = true }, logger);
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
//We will start the whole process when a successful request is made
|
||||
UmbracoModule.RouteAttempt += RegisterBackgroundTasksOnce;
|
||||
|
||||
@@ -129,6 +132,9 @@ namespace Umbraco.Web.Components
|
||||
_messenger.Startup();
|
||||
}
|
||||
|
||||
public void Terminate()
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Handle when a request is made
|
||||
/// </summary>
|
||||
|
||||
@@ -18,27 +18,39 @@ namespace Umbraco.Web.Components
|
||||
{
|
||||
public sealed class NotificationsComponent : IComponent
|
||||
{
|
||||
public NotificationsComponent(INotificationService notificationService, Notifier notifier, ActionCollection actions)
|
||||
private readonly Notifier _notifier;
|
||||
private readonly ActionCollection _actions;
|
||||
|
||||
public NotificationsComponent(Notifier notifier, ActionCollection actions)
|
||||
{
|
||||
_notifier = notifier;
|
||||
_actions = actions;
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
//Send notifications for the send to publish action
|
||||
ContentService.SentToPublish += (sender, args) => notifier.Notify(actions.GetAction<ActionToPublish>(), args.Entity);
|
||||
ContentService.SentToPublish += (sender, args) => _notifier.Notify(_actions.GetAction<ActionToPublish>(), args.Entity);
|
||||
|
||||
//Send notifications for the published action
|
||||
ContentService.Published += (sender, args) => notifier.Notify(actions.GetAction<ActionPublish>(), args.PublishedEntities.ToArray());
|
||||
ContentService.Published += (sender, args) => _notifier.Notify(_actions.GetAction<ActionPublish>(), args.PublishedEntities.ToArray());
|
||||
|
||||
//Send notifications for the saved action
|
||||
ContentService.Sorted += (sender, args) => ContentServiceSorted(notifier, sender, args, actions);
|
||||
ContentService.Sorted += (sender, args) => ContentServiceSorted(_notifier, sender, args, _actions);
|
||||
|
||||
//Send notifications for the update and created actions
|
||||
ContentService.Saved += (sender, args) => ContentServiceSaved(notifier, sender, args, actions);
|
||||
ContentService.Saved += (sender, args) => ContentServiceSaved(_notifier, sender, args, _actions);
|
||||
|
||||
//Send notifications for the delete action
|
||||
ContentService.Deleted += (sender, args) => notifier.Notify(actions.GetAction<ActionDelete>(), args.DeletedEntities.ToArray());
|
||||
ContentService.Deleted += (sender, args) => _notifier.Notify(_actions.GetAction<ActionDelete>(), args.DeletedEntities.ToArray());
|
||||
|
||||
//Send notifications for the unpublish action
|
||||
ContentService.Unpublished += (sender, args) => notifier.Notify(actions.GetAction<ActionUnpublish>(), args.PublishedEntities.ToArray());
|
||||
ContentService.Unpublished += (sender, args) => _notifier.Notify(_actions.GetAction<ActionUnpublish>(), args.PublishedEntities.ToArray());
|
||||
}
|
||||
|
||||
public void Terminate()
|
||||
{ }
|
||||
|
||||
private void ContentServiceSorted(Notifier notifier, IContentService sender, Core.Events.SaveEventArgs<IContent> args, ActionCollection actions)
|
||||
{
|
||||
var parentId = args.SavedEntities.Select(x => x.ParentId).Distinct().ToList();
|
||||
|
||||
@@ -8,11 +8,14 @@ namespace Umbraco.Web.Components
|
||||
{
|
||||
public sealed class PublicAccessComponent : IComponent
|
||||
{
|
||||
public PublicAccessComponent()
|
||||
public void Initialize()
|
||||
{
|
||||
MemberGroupService.Saved += MemberGroupService_Saved;
|
||||
}
|
||||
|
||||
public void Terminate()
|
||||
{ }
|
||||
|
||||
static void MemberGroupService_Saved(IMemberGroupService sender, Core.Events.SaveEventArgs<Core.Models.IMemberGroup> e)
|
||||
{
|
||||
foreach (var grp in e.SavedEntities)
|
||||
|
||||
@@ -201,7 +201,7 @@ namespace Umbraco.Web.Composing
|
||||
|
||||
public static TypeLoader TypeLoader => CoreCurrent.TypeLoader;
|
||||
|
||||
public static UmbracoConfig Config => CoreCurrent.Config;
|
||||
public static Configs Configs => CoreCurrent.Configs;
|
||||
|
||||
public static UrlSegmentProviderCollection UrlSegmentProviders => CoreCurrent.UrlSegmentProviders;
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ using Umbraco.Web.Mvc;
|
||||
using Umbraco.Web.PublishedCache;
|
||||
using Umbraco.Web.Routing;
|
||||
using Umbraco.Web.ContentApps;
|
||||
using Umbraco.Web.Tour;
|
||||
|
||||
// the namespace here is intentional - although defined in Umbraco.Web assembly,
|
||||
// this class should be visible when using Umbraco.Core.Components, alongside
|
||||
@@ -70,6 +71,12 @@ namespace Umbraco.Core.Components
|
||||
public static HealthCheckCollectionBuilder HealthChecks(this Composition composition)
|
||||
=> composition.WithCollectionBuilder<HealthCheckCollectionBuilder>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the TourFilters collection builder.
|
||||
/// </summary>
|
||||
public static TourFilterCollectionBuilder TourFilters(this Composition composition)
|
||||
=> composition.WithCollectionBuilder<TourFilterCollectionBuilder>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the url providers collection builder.
|
||||
/// </summary>
|
||||
|
||||
@@ -300,7 +300,7 @@ namespace Umbraco.Web.Editors
|
||||
{
|
||||
// If this feature is switched off in configuration the UI will be amended to not make the request to reset password available.
|
||||
// So this is just a server-side secondary check.
|
||||
if (Current.Config.Umbraco().Security.AllowPasswordReset == false)
|
||||
if (Current.Configs.Settings().Security.AllowPasswordReset == false)
|
||||
{
|
||||
throw new HttpResponseException(HttpStatusCode.BadRequest);
|
||||
}
|
||||
|
||||
@@ -233,7 +233,7 @@ namespace Umbraco.Web.Editors
|
||||
[HttpGet]
|
||||
public JsonNetResult GetGridConfig()
|
||||
{
|
||||
var gridConfig = Current.Config.Grids();
|
||||
var gridConfig = Current.Configs.Grids();
|
||||
return new JsonNetResult { Data = gridConfig.EditorsConfig.Editors, Formatting = Formatting.Indented };
|
||||
}
|
||||
|
||||
|
||||
@@ -314,25 +314,25 @@ namespace Umbraco.Web.Editors
|
||||
{"appPluginsPath", IOHelper.ResolveUrl(SystemDirectories.AppPlugins).TrimEnd('/')},
|
||||
{
|
||||
"imageFileTypes",
|
||||
string.Join(",", Current.Config.Umbraco().Content.ImageFileTypes)
|
||||
string.Join(",", Current.Configs.Settings().Content.ImageFileTypes)
|
||||
},
|
||||
{
|
||||
"disallowedUploadFiles",
|
||||
string.Join(",", Current.Config.Umbraco().Content.DisallowedUploadFiles)
|
||||
string.Join(",", Current.Configs.Settings().Content.DisallowedUploadFiles)
|
||||
},
|
||||
{
|
||||
"allowedUploadFiles",
|
||||
string.Join(",", Current.Config.Umbraco().Content.AllowedUploadFiles)
|
||||
string.Join(",", Current.Configs.Settings().Content.AllowedUploadFiles)
|
||||
},
|
||||
{
|
||||
"maxFileSize",
|
||||
GetMaxRequestLength()
|
||||
},
|
||||
{"keepUserLoggedIn", Current.Config.Umbraco().Security.KeepUserLoggedIn},
|
||||
{"usernameIsEmail", Current.Config.Umbraco().Security.UsernameIsEmail},
|
||||
{"keepUserLoggedIn", Current.Configs.Settings().Security.KeepUserLoggedIn},
|
||||
{"usernameIsEmail", Current.Configs.Settings().Security.UsernameIsEmail},
|
||||
{"cssPath", IOHelper.ResolveUrl(SystemDirectories.Css).TrimEnd('/')},
|
||||
{"allowPasswordReset", Current.Config.Umbraco().Security.AllowPasswordReset},
|
||||
{"loginBackgroundImage", Current.Config.Umbraco().Content.LoginBackgroundImage},
|
||||
{"allowPasswordReset", Current.Configs.Settings().Security.AllowPasswordReset},
|
||||
{"loginBackgroundImage", Current.Configs.Settings().Content.LoginBackgroundImage},
|
||||
{"showUserInvite", EmailSender.CanSendRequiredEmail},
|
||||
{"canSendRequiredEmail", EmailSender.CanSendRequiredEmail},
|
||||
}
|
||||
|
||||
@@ -344,7 +344,7 @@ namespace Umbraco.Web.Editors
|
||||
public IDictionary<string, IEnumerable<DataTypeBasic>> GetGroupedPropertyEditors()
|
||||
{
|
||||
var datatypes = new List<DataTypeBasic>();
|
||||
var showDeprecatedPropertyEditors = Current.Config.Umbraco().Content.ShowDeprecatedPropertyEditors;
|
||||
var showDeprecatedPropertyEditors = Current.Configs.Settings().Content.ShowDeprecatedPropertyEditors;
|
||||
|
||||
var propertyEditors = Current.PropertyEditors
|
||||
.Where(x=>x.IsDeprecated == false || showDeprecatedPropertyEditors);
|
||||
|
||||
@@ -703,13 +703,13 @@ namespace Umbraco.Web.Editors
|
||||
var safeFileName = fileName.ToSafeFileName();
|
||||
var ext = safeFileName.Substring(safeFileName.LastIndexOf('.') + 1).ToLower();
|
||||
|
||||
if (Current.Config.Umbraco().Content.IsFileAllowedForUpload(ext))
|
||||
if (Current.Configs.Settings().Content.IsFileAllowedForUpload(ext))
|
||||
{
|
||||
var mediaType = Constants.Conventions.MediaTypes.File;
|
||||
|
||||
if (result.FormData["contentTypeAlias"] == Constants.Conventions.MediaTypes.AutoSelect)
|
||||
{
|
||||
if (Current.Config.Umbraco().Content.ImageFileTypes.Contains(ext))
|
||||
if (Current.Configs.Settings().Content.ImageFileTypes.Contains(ext))
|
||||
{
|
||||
mediaType = Constants.Conventions.MediaTypes.Image;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Umbraco.Web.Editors
|
||||
[HttpGet]
|
||||
public IHttpActionResult GetEnableState()
|
||||
{
|
||||
var enabled = Current.Config.Umbraco().WebRouting.DisableRedirectUrlTracking == false;
|
||||
var enabled = Current.Configs.Settings().WebRouting.DisableRedirectUrlTracking == false;
|
||||
var userIsAdmin = Umbraco.UmbracoContext.Security.CurrentUser.IsAdmin();
|
||||
return Ok(new { enabled, userIsAdmin });
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.IO;
|
||||
@@ -26,7 +27,7 @@ namespace Umbraco.Web.Editors
|
||||
{
|
||||
var result = new List<BackOfficeTourFile>();
|
||||
|
||||
if (Current.Config.Umbraco().BackOffice.Tours.EnableTours == false)
|
||||
if (Current.Configs.Settings().BackOffice.Tours.EnableTours == false)
|
||||
return result;
|
||||
|
||||
//get all filters that will be applied to all tour aliases
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Web.Http.Filters;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Models;
|
||||
@@ -59,9 +60,9 @@ namespace Umbraco.Web.Editors
|
||||
var cookie = new CookieHeaderValue("UMB_UPDCHK", "1")
|
||||
{
|
||||
Path = "/",
|
||||
Expires = DateTimeOffset.Now.AddDays(Current.Config.Global().VersionCheckPeriod),
|
||||
Expires = DateTimeOffset.Now.AddDays(Current.Configs.Global().VersionCheckPeriod),
|
||||
HttpOnly = true,
|
||||
Secure = Current.Config.Global().UseHttps
|
||||
Secure = Current.Configs.Global().UseHttps
|
||||
};
|
||||
context.Response.Headers.AddCookies(new[] { cookie });
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace Umbraco.Web.Editors
|
||||
var safeFileName = fileName.ToSafeFileName();
|
||||
var ext = safeFileName.Substring(safeFileName.LastIndexOf('.') + 1).ToLower();
|
||||
|
||||
if (Current.Config.Umbraco().Content.DisallowedUploadFiles.Contains(ext) == false)
|
||||
if (Current.Configs.Settings().Content.DisallowedUploadFiles.Contains(ext) == false)
|
||||
{
|
||||
//generate a path of known data, we don't want this path to be guessable
|
||||
user.Avatar = "UserAvatars/" + (user.Id + safeFileName).ToSHA1() + "." + ext;
|
||||
@@ -195,7 +195,7 @@ namespace Umbraco.Web.Editors
|
||||
// so to do that here, we'll need to check if this current user is an admin and if not we should exclude all user who are
|
||||
// also admins
|
||||
|
||||
var hideDisabledUsers = Current.Config.Umbraco().Security.HideDisabledUsersInBackoffice;
|
||||
var hideDisabledUsers = Current.Configs.Settings().Security.HideDisabledUsersInBackoffice;
|
||||
var excludeUserGroups = new string[0];
|
||||
var isAdmin = Security.CurrentUser.IsAdmin();
|
||||
if (isAdmin == false)
|
||||
@@ -253,7 +253,7 @@ namespace Umbraco.Web.Editors
|
||||
throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
|
||||
}
|
||||
|
||||
if (Current.Config.Umbraco().Security.UsernameIsEmail)
|
||||
if (Current.Configs.Settings().Security.UsernameIsEmail)
|
||||
{
|
||||
//ensure they are the same if we're using it
|
||||
userSave.Username = userSave.Email;
|
||||
@@ -345,7 +345,7 @@ namespace Umbraco.Web.Editors
|
||||
}
|
||||
|
||||
IUser user;
|
||||
if (Current.Config.Umbraco().Security.UsernameIsEmail)
|
||||
if (Current.Configs.Settings().Security.UsernameIsEmail)
|
||||
{
|
||||
//ensure it's the same
|
||||
userSave.Username = userSave.Email;
|
||||
@@ -419,7 +419,7 @@ namespace Umbraco.Web.Editors
|
||||
if (user != null && (extraCheck == null || extraCheck(user)))
|
||||
{
|
||||
ModelState.AddModelError(
|
||||
Current.Config.Umbraco().Security.UsernameIsEmail ? "Email" : "Username",
|
||||
Current.Configs.Settings().Security.UsernameIsEmail ? "Email" : "Username",
|
||||
"A user with the username already exists");
|
||||
throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
|
||||
}
|
||||
@@ -539,7 +539,7 @@ namespace Umbraco.Web.Editors
|
||||
|
||||
// if the found user has his email for username, we want to keep this synced when changing the email.
|
||||
// we have already cross-checked above that the email isn't colliding with anything, so we can safely assign it here.
|
||||
if (Current.Config.Umbraco().Security.UsernameIsEmail && found.Username == found.Email && userSave.Username != userSave.Email)
|
||||
if (Current.Configs.Settings().Security.UsernameIsEmail && found.Username == found.Email && userSave.Username != userSave.Email)
|
||||
{
|
||||
userSave.Username = userSave.Email;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using System.Web.Http;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Configuration;
|
||||
@@ -28,7 +29,7 @@ namespace Umbraco.Web.HealthCheck
|
||||
_checks = checks ?? throw new ArgumentNullException(nameof(checks));
|
||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
|
||||
var healthCheckConfig = Current.Config.HealthChecks();
|
||||
var healthCheckConfig = Current.Configs.HealthChecks();
|
||||
_disabledCheckIds = healthCheckConfig.DisabledChecks
|
||||
.Select(x => x.Id)
|
||||
.ToList();
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace Umbraco.Web.HealthCheck.NotificationMethods
|
||||
|
||||
private MailMessage CreateMailMessage(string subject, string message)
|
||||
{
|
||||
var to = Current.Config.Umbraco().Content.NotificationEmailAddress;
|
||||
var to = Current.Configs.Settings().Content.NotificationEmailAddress;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(subject))
|
||||
subject = "Umbraco Health Check Status";
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Configuration.HealthChecks;
|
||||
@@ -20,7 +21,7 @@ namespace Umbraco.Web.HealthCheck.NotificationMethods
|
||||
return;
|
||||
}
|
||||
|
||||
var healthCheckConfig = Current.Config.HealthChecks();
|
||||
var healthCheckConfig = Current.Configs.HealthChecks();
|
||||
var notificationMethods = healthCheckConfig.NotificationSettings.NotificationMethods;
|
||||
var notificationMethod = notificationMethods[attribute.Alias];
|
||||
if (notificationMethod == null)
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace Umbraco.Web
|
||||
if (UmbracoContext.Current.InPreviewMode)
|
||||
{
|
||||
var htmlBadge =
|
||||
String.Format(Current.Config.Umbraco().Content.PreviewBadge,
|
||||
String.Format(Current.Configs.Settings().Content.PreviewBadge,
|
||||
IOHelper.ResolveUrl(SystemDirectories.Umbraco),
|
||||
UmbracoContext.Current.HttpContext.Server.UrlEncode(UmbracoContext.Current.HttpContext.Request.Path));
|
||||
return new MvcHtmlString(htmlBadge);
|
||||
|
||||
@@ -145,7 +145,7 @@ namespace Umbraco.Web.Install.InstallSteps
|
||||
|
||||
// In this one case when it's a brand new install and nothing has been configured, make sure the
|
||||
// back office cookie is cleared so there's no old cookies lying around causing problems
|
||||
_http.ExpireCookie(Current.Config.Umbraco().Security.AuthCookieName);
|
||||
_http.ExpireCookie(Current.Configs.Settings().Security.AuthCookieName);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Web;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Components;
|
||||
using Umbraco.Core.Logging;
|
||||
|
||||
@@ -9,30 +8,38 @@ namespace Umbraco.Web.Logging
|
||||
internal sealed class WebProfilerComponent : IComponent
|
||||
{
|
||||
private readonly WebProfiler _profiler;
|
||||
private readonly bool _profile;
|
||||
|
||||
public WebProfilerComponent(IProfiler profiler, ILogger logger, IRuntimeState runtime)
|
||||
public WebProfilerComponent(IProfiler profiler, ILogger logger)
|
||||
{
|
||||
_profile = true;
|
||||
|
||||
// although registered in WebRuntime.Compose, ensure that we have not
|
||||
// been replaced by another component, and we are still "the" profiler
|
||||
_profiler = profiler as WebProfiler;
|
||||
if (_profiler == null)
|
||||
{
|
||||
// if VoidProfiler was registered, let it be known
|
||||
var vp = profiler as VoidProfiler;
|
||||
if (vp != null)
|
||||
logger.Info<WebProfilerComponent>("Profiler is VoidProfiler, not profiling (must run debug mode to profile).");
|
||||
return;
|
||||
}
|
||||
if (_profiler != null) return;
|
||||
|
||||
// if VoidProfiler was registered, let it be known
|
||||
if (profiler is VoidProfiler)
|
||||
logger.Info<WebProfilerComponent>("Profiler is VoidProfiler, not profiling (must run debug mode to profile).");
|
||||
_profile = false;
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
if (!_profile) return;
|
||||
|
||||
// bind to ApplicationInit - ie execute the application initialization for *each* application
|
||||
// it would be a mistake to try and bind to the current application events
|
||||
UmbracoApplicationBase.ApplicationInit += InitializeApplication;
|
||||
}
|
||||
|
||||
public void Terminate()
|
||||
{ }
|
||||
|
||||
private void InitializeApplication(object sender, EventArgs args)
|
||||
{
|
||||
var app = sender as HttpApplication;
|
||||
if (app == null) return;
|
||||
if (!(sender is HttpApplication app)) return;
|
||||
|
||||
// for *each* application (this will run more than once)
|
||||
app.BeginRequest += (s, a) => _profiler.UmbracoApplicationBeginRequest(s, a);
|
||||
|
||||
@@ -312,7 +312,7 @@ namespace Umbraco.Web.Macros
|
||||
Alias = macro.Alias,
|
||||
MacroSource = macro.MacroSource,
|
||||
Exception = e,
|
||||
Behaviour = Current.Config.Umbraco().Content.MacroErrorBehaviour
|
||||
Behaviour = Current.Configs.Settings().Content.MacroErrorBehaviour
|
||||
};
|
||||
|
||||
OnError(macroErrorEventArgs);
|
||||
@@ -604,7 +604,7 @@ namespace Umbraco.Web.Macros
|
||||
querystring += $"&umb_{ide.Key}={HttpContext.Current.Server.UrlEncode((ide.Value ?? String.Empty).ToString())}";
|
||||
|
||||
// create a new 'HttpWebRequest' object to the mentioned URL.
|
||||
var useSsl = Current.Config.Global().UseHttps;
|
||||
var useSsl = Current.Configs.Global().UseHttps;
|
||||
var protocol = useSsl ? "https" : "http";
|
||||
var currentRequest = HttpContext.Current.Request;
|
||||
var serverVars = currentRequest.ServerVariables;
|
||||
@@ -619,7 +619,7 @@ namespace Umbraco.Web.Macros
|
||||
// propagate the user's context
|
||||
// TODO: this is the worst thing ever.
|
||||
// also will not work if people decide to put their own custom auth system in place.
|
||||
var inCookie = currentRequest.Cookies[Current.Config.Umbraco().Security.AuthCookieName];
|
||||
var inCookie = currentRequest.Cookies[Current.Configs.Settings().Security.AuthCookieName];
|
||||
if (inCookie == null) throw new NullReferenceException("No auth cookie found");
|
||||
var cookie = new Cookie(inCookie.Name, inCookie.Value, inCookie.Path, serverVars["SERVER_NAME"]);
|
||||
myHttpWebRequest.CookieContainer = new CookieContainer();
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace Umbraco.Web.Models.ContentEditing
|
||||
{
|
||||
return IconIsClass
|
||||
? string.Empty
|
||||
: string.Format("{0}images/umbraco/{1}", Current.Config.Global().Path.EnsureEndsWith("/"), Icon);
|
||||
: string.Format("{0}images/umbraco/{1}", Current.Configs.Global().Path.EnsureEndsWith("/"), Icon);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Umbraco.Web.Models.ContentEditing
|
||||
if (UserGroups.Any() == false)
|
||||
yield return new ValidationResult("A user must be assigned to at least one group", new[] { "UserGroups" });
|
||||
|
||||
if (Current.Config.Umbraco().Security.UsernameIsEmail == false && Username.IsNullOrWhiteSpace())
|
||||
if (Current.Configs.Settings().Security.UsernameIsEmail == false && Username.IsNullOrWhiteSpace())
|
||||
yield return new ValidationResult("A username cannot be empty", new[] { "Username" });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
public DataTypeMapperProfile(PropertyEditorCollection propertyEditors, ILogger logger)
|
||||
{
|
||||
// create, capture, cache
|
||||
var availablePropertyEditorsResolver = new AvailablePropertyEditorsResolver(Current.Config.Umbraco().Content);
|
||||
var availablePropertyEditorsResolver = new AvailablePropertyEditorsResolver(Current.Configs.Settings().Content);
|
||||
var configurationDisplayResolver = new DataTypeConfigurationFieldDisplayResolver(logger);
|
||||
var databaseTypeResolver = new DatabaseTypeResolver();
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
.ForMember(dest => dest.Tabs, opt => opt.ResolveUsing(tabsAndPropertiesResolver))
|
||||
.ForMember(dest => dest.AdditionalData, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.ContentType, opt => opt.ResolveUsing(mediaTypeBasicResolver))
|
||||
.ForMember(dest => dest.MediaLink, opt => opt.ResolveUsing(content => string.Join(",", content.GetUrls(Current.Config.Umbraco().Content, logger))))
|
||||
.ForMember(dest => dest.MediaLink, opt => opt.ResolveUsing(content => string.Join(",", content.GetUrls(Current.Configs.Settings().Content, logger))))
|
||||
.ForMember(dest => dest.ContentApps, opt => opt.ResolveUsing(mediaAppResolver))
|
||||
.ForMember(dest => dest.VariesByCulture, opt => opt.MapFrom(src => src.ContentType.VariesByCulture()));
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ namespace Umbraco.Web.Models.Trees
|
||||
return IOHelper.ResolveUrl("~" + Icon.TrimStart('~'));
|
||||
|
||||
//legacy icon path
|
||||
return string.Format("{0}images/umbraco/{1}", Current.Config.Global().Path.EnsureEndsWith("/"), Icon);
|
||||
return string.Format("{0}images/umbraco/{1}", Current.Configs.Global().Path.EnsureEndsWith("/"), Icon);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user