diff --git a/src/Umbraco.Abstractions/Composing/Current.cs b/src/Umbraco.Abstractions/Composing/Current.cs
index 63da21fe88..f99a32a585 100644
--- a/src/Umbraco.Abstractions/Composing/Current.cs
+++ b/src/Umbraco.Abstractions/Composing/Current.cs
@@ -5,6 +5,6 @@ namespace Umbraco.Composing
public static class Current
{
- public static ILogger Logger { get; set; }
+ public static ILogger Logger { get; set; } = new NullLogger();
}
}
diff --git a/src/Umbraco.Abstractions/Logging/Viewer/NullLogger.cs b/src/Umbraco.Abstractions/Logging/Viewer/NullLogger.cs
new file mode 100644
index 0000000000..d1faccd8ce
--- /dev/null
+++ b/src/Umbraco.Abstractions/Logging/Viewer/NullLogger.cs
@@ -0,0 +1,110 @@
+using System;
+using Umbraco.Core.Logging;
+
+namespace Umbraco.Core.Logging
+{
+ public class NullLogger : ILogger
+ {
+ public bool IsEnabled(Type reporting, LogLevel level) => false;
+
+ public void Fatal(Type reporting, Exception exception, string message)
+ {
+
+ }
+
+ public void Fatal(Type reporting, Exception exception)
+ {
+
+ }
+
+ public void Fatal(Type reporting, string message)
+ {
+
+ }
+
+ public void Fatal(Type reporting, Exception exception, string messageTemplate, params object[] propertyValues)
+ {
+
+ }
+
+ public void Fatal(Type reporting, string messageTemplate, params object[] propertyValues)
+ {
+
+ }
+
+ public void Error(Type reporting, Exception exception, string message)
+ {
+
+ }
+
+ public void Error(Type reporting, Exception exception)
+ {
+
+ }
+
+ public void Error(Type reporting, string message)
+ {
+
+ }
+
+ public void Error(Type reporting, Exception exception, string messageTemplate, params object[] propertyValues)
+ {
+
+ }
+
+ public void Error(Type reporting, string messageTemplate, params object[] propertyValues)
+ {
+
+ }
+
+ public void Warn(Type reporting, string message)
+ {
+
+ }
+
+ public void Warn(Type reporting, string messageTemplate, params object[] propertyValues)
+ {
+
+ }
+
+ public void Warn(Type reporting, Exception exception, string message)
+ {
+
+ }
+
+ public void Warn(Type reporting, Exception exception, string messageTemplate, params object[] propertyValues)
+ {
+
+ }
+
+ public void Info(Type reporting, string message)
+ {
+
+ }
+
+ public void Info(Type reporting, string messageTemplate, params object[] propertyValues)
+ {
+
+ }
+
+ public void Debug(Type reporting, string message)
+ {
+
+ }
+
+ public void Debug(Type reporting, string messageTemplate, params object[] propertyValues)
+ {
+
+ }
+
+ public void Verbose(Type reporting, string message)
+ {
+
+ }
+
+ public void Verbose(Type reporting, string messageTemplate, params object[] propertyValues)
+ {
+
+ }
+ }
+}
diff --git a/src/Umbraco.Core/PublishedContentExtensions.cs b/src/Umbraco.Abstractions/PublishedContentExtensions.cs
similarity index 83%
rename from src/Umbraco.Core/PublishedContentExtensions.cs
rename to src/Umbraco.Abstractions/PublishedContentExtensions.cs
index 921883b822..5242fdfd67 100644
--- a/src/Umbraco.Core/PublishedContentExtensions.cs
+++ b/src/Umbraco.Abstractions/PublishedContentExtensions.cs
@@ -8,8 +8,6 @@ namespace Umbraco.Core
{
public static class PublishedContentExtensions
{
- private static IVariationContextAccessor VariationContextAccessor => Current.VariationContextAccessor;
-
///
/// Determines whether the content has a culture.
///
@@ -28,13 +26,14 @@ namespace Umbraco.Core
/// Filters a sequence of to return invariant items, and items that are published for the specified culture.
///
/// The content items.
+ ///
/// The specific culture to filter for. If null is used the current culture is used. (Default is null).
- internal static IEnumerable WhereIsInvariantOrHasCulture(this IEnumerable contents, string culture = null)
+ internal static IEnumerable WhereIsInvariantOrHasCulture(this IEnumerable contents, IVariationContextAccessor variationContextAccessor, string culture = null)
where T : class, IPublishedContent
{
if (contents == null) throw new ArgumentNullException(nameof(contents));
- culture = culture ?? Current.VariationContextAccessor.VariationContext?.Culture ?? "";
+ culture = culture ?? variationContextAccessor.VariationContext?.Culture ?? "";
// either does not vary by culture, or has the specified culture
return contents.Where(x => !x.ContentType.VariesByCulture() || HasCulture(x, culture));
@@ -44,8 +43,9 @@ namespace Umbraco.Core
/// Gets the name of the content item.
///
/// The content item.
+ ///
/// The specific culture to get the name for. If null is used the current culture is used (Default is null).
- public static string Name(this IPublishedContent content, string culture = null)
+ public static string Name(this IPublishedContent content, IVariationContextAccessor variationContextAccessor, string culture = null)
{
// invariant has invariant value (whatever the requested culture)
if (!content.ContentType.VariesByCulture())
@@ -53,7 +53,7 @@ namespace Umbraco.Core
// handle context culture for variant
if (culture == null)
- culture = VariationContextAccessor?.VariationContext?.Culture ?? "";
+ culture = variationContextAccessor?.VariationContext?.Culture ?? "";
// get
return culture != "" && content.Cultures.TryGetValue(culture, out var infos) ? infos.Name : null;
@@ -64,8 +64,9 @@ namespace Umbraco.Core
/// Gets the url segment of the content item.
///
/// The content item.
+ ///
/// The specific culture to get the url segment for. If null is used the current culture is used (Default is null).
- public static string UrlSegment(this IPublishedContent content, string culture = null)
+ public static string UrlSegment(this IPublishedContent content, IVariationContextAccessor variationContextAccessor, string culture = null)
{
// invariant has invariant value (whatever the requested culture)
if (!content.ContentType.VariesByCulture())
@@ -73,7 +74,7 @@ namespace Umbraco.Core
// handle context culture for variant
if (culture == null)
- culture = VariationContextAccessor?.VariationContext?.Culture ?? "";
+ culture = variationContextAccessor?.VariationContext?.Culture ?? "";
// get
return culture != "" && content.Cultures.TryGetValue(culture, out var infos) ? infos.UrlSegment : null;
@@ -83,8 +84,9 @@ namespace Umbraco.Core
/// Gets the culture date of the content item.
///
/// The content item.
+ ///
/// The specific culture to get the name for. If null is used the current culture is used (Default is null).
- public static DateTime CultureDate(this IPublishedContent content, string culture = null)
+ public static DateTime CultureDate(this IPublishedContent content, IVariationContextAccessor variationContextAccessor, string culture = null)
{
// invariant has invariant value (whatever the requested culture)
if (!content.ContentType.VariesByCulture())
@@ -92,7 +94,7 @@ namespace Umbraco.Core
// handle context culture for variant
if (culture == null)
- culture = VariationContextAccessor?.VariationContext?.Culture ?? "";
+ culture = variationContextAccessor?.VariationContext?.Culture ?? "";
// get
return culture != "" && content.Cultures.TryGetValue(culture, out var infos) ? infos.Date : DateTime.MinValue;
@@ -103,14 +105,15 @@ namespace Umbraco.Core
/// Gets the children of the content item.
///
/// The content item.
+ ///
///
- /// The specific culture to get the url children for. Default is null which will use the current culture in
+ /// The specific culture to get the url children for. Default is null which will use the current culture in
///
///
/// Gets children that are available for the specified culture.
/// Children are sorted by their sortOrder.
///
- /// For culture,
+ /// For culture,
/// if null is used the current culture is used.
/// If an empty string is used only invariant children are returned.
/// If "*" is used all children are returned.
@@ -121,11 +124,11 @@ namespace Umbraco.Core
/// However, if an empty string is specified only invariant children are returned.
///
///
- public static IEnumerable Children(this IPublishedContent content, string culture = null)
+ public static IEnumerable Children(this IPublishedContent content, IVariationContextAccessor variationContextAccessor, string culture = null)
{
// handle context culture for variant
if (culture == null)
- culture = VariationContextAccessor?.VariationContext?.Culture ?? "";
+ culture = variationContextAccessor?.VariationContext?.Culture ?? "";
var children = content.ChildrenForAllCultures;
return culture == "*"
diff --git a/src/Umbraco.Core/ServiceContextExtensions.cs b/src/Umbraco.Abstractions/ServiceContextExtensions.cs
similarity index 100%
rename from src/Umbraco.Core/ServiceContextExtensions.cs
rename to src/Umbraco.Abstractions/ServiceContextExtensions.cs
diff --git a/src/Umbraco.Abstractions/TypeExtensions.cs b/src/Umbraco.Abstractions/TypeExtensions.cs
index c656aa6373..15f3e56924 100644
--- a/src/Umbraco.Abstractions/TypeExtensions.cs
+++ b/src/Umbraco.Abstractions/TypeExtensions.cs
@@ -5,6 +5,7 @@ using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using Umbraco.Core.Composing;
+using Umbraco.Core.Strings;
namespace Umbraco.Core
{
@@ -427,5 +428,54 @@ namespace Umbraco.Core
return type.GetCustomAttributes(typeof (T), inherited).OfType();
}
+ ///
+ /// Tries to return a value based on a property name for an object but ignores case sensitivity
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Currently this will only work for ProperCase and camelCase properties, see the TODO below to enable complete case insensitivity
+ ///
+ internal static Attempt GetMemberIgnoreCase(this Type type, IShortStringHelper shortStringHelper, object target, string memberName)
+ {
+ Func> getMember =
+ memberAlias =>
+ {
+ try
+ {
+ return Attempt.Succeed(
+ type.InvokeMember(memberAlias,
+ System.Reflection.BindingFlags.GetProperty |
+ System.Reflection.BindingFlags.Instance |
+ System.Reflection.BindingFlags.Public,
+ null,
+ target,
+ null));
+ }
+ catch (MissingMethodException ex)
+ {
+ return Attempt.Fail(ex);
+ }
+ };
+
+ //try with the current casing
+ var attempt = getMember(memberName);
+ if (attempt.Success == false)
+ {
+ //if we cannot get with the current alias, try changing it's case
+ attempt = memberName[0].IsUpperCase()
+ ? getMember(memberName.ToCleanString(shortStringHelper, CleanStringType.Ascii | CleanStringType.ConvertCase | CleanStringType.CamelCase))
+ : getMember(memberName.ToCleanString(shortStringHelper, CleanStringType.Ascii | CleanStringType.ConvertCase | CleanStringType.PascalCase));
+
+ // TODO: If this still fails then we should get a list of properties from the object and then compare - doing the above without listing
+ // all properties will surely be faster than using reflection to get ALL properties first and then query against them.
+ }
+
+ return attempt;
+ }
+
}
}
diff --git a/src/Umbraco.Core/TypeLoaderExtensions.cs b/src/Umbraco.Abstractions/TypeLoaderExtensions.cs
similarity index 91%
rename from src/Umbraco.Core/TypeLoaderExtensions.cs
rename to src/Umbraco.Abstractions/TypeLoaderExtensions.cs
index 974bd3e805..9c086ab8b9 100644
--- a/src/Umbraco.Core/TypeLoaderExtensions.cs
+++ b/src/Umbraco.Abstractions/TypeLoaderExtensions.cs
@@ -3,12 +3,11 @@ using System.Collections.Generic;
using Umbraco.Core.Cache;
using Umbraco.Core.Composing;
using Umbraco.Core.PackageActions;
-using Umbraco.Core.Persistence.Mappers;
using Umbraco.Core.PropertyEditors;
namespace Umbraco.Core
{
- internal static class TypeLoaderExtensions
+ public static class TypeLoaderExtensions
{
///
/// Gets all classes implementing .
diff --git a/src/Umbraco.Core/UriExtensions.cs b/src/Umbraco.Abstractions/UriExtensions.cs
similarity index 99%
rename from src/Umbraco.Core/UriExtensions.cs
rename to src/Umbraco.Abstractions/UriExtensions.cs
index 0813c321bc..cf84d7914d 100644
--- a/src/Umbraco.Core/UriExtensions.cs
+++ b/src/Umbraco.Abstractions/UriExtensions.cs
@@ -1,7 +1,7 @@
using System;
using System.IO;
using System.Linq;
-using Umbraco.Core.Composing;
+using Umbraco.Composing;
using Umbraco.Core.Configuration;
using Umbraco.Core.IO;
@@ -240,7 +240,7 @@ namespace Umbraco.Core
/// Default uri.AbsolutePath does not support relative uris.
public static string GetSafeAbsolutePathDecoded(this Uri uri)
{
- return System.Web.HttpUtility.UrlDecode(uri.GetSafeAbsolutePath());
+ return System.Net.WebUtility.UrlDecode(uri.GetSafeAbsolutePath());
}
///
diff --git a/src/Umbraco.Core/Composing/Current.cs b/src/Umbraco.Core/Composing/Current.cs
index a50bb89558..8b594db424 100644
--- a/src/Umbraco.Core/Composing/Current.cs
+++ b/src/Umbraco.Core/Composing/Current.cs
@@ -1,22 +1,12 @@
using System;
-using Umbraco.Core.Cache;
using Umbraco.Core.Configuration;
-using Umbraco.Core.Dictionary;
-using Umbraco.Core.Hosting;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
-using Umbraco.Core.Mapping;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Core.PackageActions;
-using Umbraco.Core.Packaging;
-using Umbraco.Core.Persistence;
-using Umbraco.Core.PropertyEditors;
-using Umbraco.Core.Scoping;
-using Umbraco.Core.Security;
using Umbraco.Core.Services;
using Umbraco.Core.Strings;
using Umbraco.Core.Sync;
-using Umbraco.Net;
namespace Umbraco.Core.Composing
{
@@ -39,11 +29,7 @@ namespace Umbraco.Core.Composing
// registered we setup a default one. We should really refactor our tests so that it does
// not happen.
- private static IShortStringHelper _shortStringHelper;
private static ILogger _logger;
- private static IProfiler _profiler;
- private static IProfilingLogger _profilingLogger;
- private static IPublishedValueFallback _publishedValueFallback;
private static Configs _configs;
///
@@ -79,11 +65,7 @@ namespace Umbraco.Core.Composing
_factory = null;
_configs = null;
- _shortStringHelper = null;
_logger = null;
- _profiler = null;
- _profilingLogger = null;
- _publishedValueFallback = null;
Resetted?.Invoke(null, EventArgs.Empty);
}
@@ -107,31 +89,14 @@ namespace Umbraco.Core.Composing
#region Getters
- public static UmbracoMapper Mapper
- => _factory.GetInstance();
- public static IShortStringHelper ShortStringHelper
- => _shortStringHelper ?? (_shortStringHelper = _factory?.TryGetInstance()
- ?? new DefaultShortStringHelper(new DefaultShortStringHelperConfig().WithDefault(Configs.Settings())));
+ public static IShortStringHelper ShortStringHelper => Factory.GetInstance();
+
public static ILogger Logger
=> _logger ?? (_logger = _factory?.TryGetInstance()
?? new DebugDiagnosticsLogger(new MessageTemplates()));
- public static IProfiler Profiler
- => _profiler ?? (_profiler = _factory?.TryGetInstance()
- ?? new LogProfiler(Logger));
-
- public static IProfilingLogger ProfilingLogger
- => _profilingLogger ?? (_profilingLogger = _factory?.TryGetInstance())
- ?? new ProfilingLogger(Logger, Profiler);
-
- public static IRuntimeState RuntimeState
- => Factory.GetInstance();
-
- public static TypeLoader TypeLoader
- => Factory.GetInstance();
-
public static Configs Configs
{
get
@@ -142,81 +107,21 @@ namespace Umbraco.Core.Composing
}
}
- public static IFileSystems FileSystems
- => Factory.GetInstance();
-
- public static IMediaFileSystem MediaFileSystem
- => Factory.GetInstance();
-
- public static UrlSegmentProviderCollection UrlSegmentProviders
- => Factory.GetInstance();
-
- public static CacheRefresherCollection CacheRefreshers
- => Factory.GetInstance();
-
- public static DataEditorCollection DataEditors
- => Factory.GetInstance();
-
- public static DataValueReferenceFactoryCollection DataValueReferenceFactories
- => Factory.GetInstance();
-
- public static PropertyEditorCollection PropertyEditors
- => Factory.GetInstance();
-
- public static ParameterEditorCollection ParameterEditors
- => Factory.GetInstance();
-
- internal static ManifestValueValidatorCollection ManifestValidators
- => Factory.GetInstance();
-
internal static PackageActionCollection PackageActions
=> Factory.GetInstance();
- internal static IPackageActionRunner PackageActionRunner
- => Factory.GetInstance();
-
- internal static PropertyValueConverterCollection PropertyValueConverters
- => Factory.GetInstance();
-
internal static IPublishedModelFactory PublishedModelFactory
=> Factory.GetInstance();
public static IServerMessenger ServerMessenger
=> Factory.GetInstance();
- public static IServerRegistrar ServerRegistrar
- => Factory.GetInstance();
-
- public static ICultureDictionaryFactory CultureDictionaryFactory
- => Factory.GetInstance();
-
- public static AppCaches AppCaches
- => Factory.GetInstance();
-
public static ServiceContext Services
=> Factory.GetInstance();
- public static IScopeProvider ScopeProvider
- => Factory.GetInstance();
+ public static IIOHelper IOHelper
+ => Factory.GetInstance();
- public static ISqlContext SqlContext
- => Factory.GetInstance();
-
- public static IPublishedContentTypeFactory PublishedContentTypeFactory
- => Factory.GetInstance();
-
- public static IPublishedValueFallback PublishedValueFallback
- => _publishedValueFallback ?? Factory.GetInstance() ?? new NoopPublishedValueFallback();
-
- public static IVariationContextAccessor VariationContextAccessor
- => Factory.GetInstance();
-
- public static IIOHelper IOHelper => Factory.GetInstance();
-
-
- public static IHostingEnvironment HostingEnvironment => Factory.GetInstance();
- public static IBackOfficeInfo BackOfficeInfo => Factory.GetInstance();
- public static ISessionIdResolver SessionIdResolver => Factory.GetInstance();
#endregion
}
diff --git a/src/Umbraco.Core/TypeExtensions.cs b/src/Umbraco.Core/TypeExtensions.cs
deleted file mode 100644
index c383faf2af..0000000000
--- a/src/Umbraco.Core/TypeExtensions.cs
+++ /dev/null
@@ -1,64 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using Umbraco.Core.Composing;
-using Umbraco.Core.Strings;
-
-namespace Umbraco.Core
-{
- public static class TypeExtensions
- {
- ///
- /// Tries to return a value based on a property name for an object but ignores case sensitivity
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- /// Currently this will only work for ProperCase and camelCase properties, see the TODO below to enable complete case insensitivity
- ///
- internal static Attempt GetMemberIgnoreCase(this Type type, IShortStringHelper shortStringHelper, object target, string memberName)
- {
- Func> getMember =
- memberAlias =>
- {
- try
- {
- return Attempt.Succeed(
- type.InvokeMember(memberAlias,
- System.Reflection.BindingFlags.GetProperty |
- System.Reflection.BindingFlags.Instance |
- System.Reflection.BindingFlags.Public,
- null,
- target,
- null));
- }
- catch (MissingMethodException ex)
- {
- return Attempt.Fail(ex);
- }
- };
-
- //try with the current casing
- var attempt = getMember(memberName);
- if (attempt.Success == false)
- {
- //if we cannot get with the current alias, try changing it's case
- attempt = memberName[0].IsUpperCase()
- ? getMember(memberName.ToCleanString(shortStringHelper, CleanStringType.Ascii | CleanStringType.ConvertCase | CleanStringType.CamelCase))
- : getMember(memberName.ToCleanString(shortStringHelper, CleanStringType.Ascii | CleanStringType.ConvertCase | CleanStringType.PascalCase));
-
- // TODO: If this still fails then we should get a list of properties from the object and then compare - doing the above without listing
- // all properties will surely be faster than using reflection to get ALL properties first and then query against them.
- }
-
- return attempt;
- }
-
- }
-}
diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj
index 7ff3544f7a..e21fe72278 100755
--- a/src/Umbraco.Core/Umbraco.Core.csproj
+++ b/src/Umbraco.Core/Umbraco.Core.csproj
@@ -136,7 +136,6 @@
-
@@ -144,7 +143,6 @@
-
@@ -154,9 +152,6 @@
-
-
-
Properties\SolutionInfo.cs
diff --git a/src/Umbraco.Tests/Cache/DistributedCache/DistributedCacheTests.cs b/src/Umbraco.Tests/Cache/DistributedCache/DistributedCacheTests.cs
index ea7819b14d..225bc54eb9 100644
--- a/src/Umbraco.Tests/Cache/DistributedCache/DistributedCacheTests.cs
+++ b/src/Umbraco.Tests/Cache/DistributedCache/DistributedCacheTests.cs
@@ -21,22 +21,21 @@ namespace Umbraco.Tests.Cache.DistributedCache
{
private Umbraco.Web.Cache.DistributedCache _distributedCache;
+ private IServerRegistrar ServerRegistrar { get; set; }
+ private TestServerMessenger ServerMessenger { get; set; }
+
[SetUp]
public void Setup()
{
- var register = TestHelper.GetRegister();
+ ServerRegistrar = new TestServerRegistrar();
+ ServerMessenger = new TestServerMessenger();
- var composition = new Composition(register, TestHelper.GetMockedTypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
+ var cacheRefresherCollection = new CacheRefresherCollection(new []
+ {
+ new TestCacheRefresher()
+ });
- composition.RegisterUnique(_ => new TestServerRegistrar());
- composition.RegisterUnique(_ => new TestServerMessenger());
-
- composition.WithCollectionBuilder()
- .Add();
-
- Current.Factory = composition.CreateFactory();
-
- _distributedCache = new Umbraco.Web.Cache.DistributedCache();
+ _distributedCache = new Umbraco.Web.Cache.DistributedCache(ServerMessenger, cacheRefresherCollection);
}
[TearDown]
@@ -52,7 +51,7 @@ namespace Umbraco.Tests.Cache.DistributedCache
{
_distributedCache.Refresh(Guid.Parse("E0F452CB-DCB2-4E84-B5A5-4F01744C5C73"), i);
}
- Assert.AreEqual(10, ((TestServerMessenger)Current.ServerMessenger).IntIdsRefreshed.Count);
+ Assert.AreEqual(10, ServerMessenger.IntIdsRefreshed.Count);
}
[Test]
@@ -65,7 +64,7 @@ namespace Umbraco.Tests.Cache.DistributedCache
x => x.Id,
new TestObjectWithId{Id = i});
}
- Assert.AreEqual(10, ((TestServerMessenger)Current.ServerMessenger).IntIdsRefreshed.Count);
+ Assert.AreEqual(10, ServerMessenger.IntIdsRefreshed.Count);
}
[Test]
@@ -75,7 +74,7 @@ namespace Umbraco.Tests.Cache.DistributedCache
{
_distributedCache.Refresh(Guid.Parse("E0F452CB-DCB2-4E84-B5A5-4F01744C5C73"), Guid.NewGuid());
}
- Assert.AreEqual(11, ((TestServerMessenger)Current.ServerMessenger).GuidIdsRefreshed.Count);
+ Assert.AreEqual(11, ServerMessenger.GuidIdsRefreshed.Count);
}
[Test]
@@ -85,7 +84,7 @@ namespace Umbraco.Tests.Cache.DistributedCache
{
_distributedCache.Remove(Guid.Parse("E0F452CB-DCB2-4E84-B5A5-4F01744C5C73"), i);
}
- Assert.AreEqual(12, ((TestServerMessenger)Current.ServerMessenger).IntIdsRemoved.Count);
+ Assert.AreEqual(12, ServerMessenger.IntIdsRemoved.Count);
}
[Test]
@@ -95,7 +94,7 @@ namespace Umbraco.Tests.Cache.DistributedCache
{
_distributedCache.RefreshAll(Guid.Parse("E0F452CB-DCB2-4E84-B5A5-4F01744C5C73"));
}
- Assert.AreEqual(13, ((TestServerMessenger)Current.ServerMessenger).CountOfFullRefreshes);
+ Assert.AreEqual(13, ServerMessenger.CountOfFullRefreshes);
}
#region internal test classes
diff --git a/src/Umbraco.Tests/Cache/DistributedCacheBinderTests.cs b/src/Umbraco.Tests/Cache/DistributedCacheBinderTests.cs
index 862f6da038..880bee4904 100644
--- a/src/Umbraco.Tests/Cache/DistributedCacheBinderTests.cs
+++ b/src/Umbraco.Tests/Cache/DistributedCacheBinderTests.cs
@@ -4,7 +4,6 @@ using System.Threading;
using Moq;
using NUnit.Framework;
using Umbraco.Core.Composing;
-using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.Events;
using Umbraco.Core.Models;
using Umbraco.Core.Models.Membership;
@@ -15,6 +14,7 @@ using Umbraco.Web;
using Umbraco.Web.Cache;
using Umbraco.Web.PublishedCache;
using Umbraco.Web.Routing;
+using Current = Umbraco.Web.Composing.Current;
namespace Umbraco.Tests.Cache
{
diff --git a/src/Umbraco.Tests/Cache/ObjectAppCacheTests.cs b/src/Umbraco.Tests/Cache/ObjectAppCacheTests.cs
index 0fb8e574a8..772e92cabe 100644
--- a/src/Umbraco.Tests/Cache/ObjectAppCacheTests.cs
+++ b/src/Umbraco.Tests/Cache/ObjectAppCacheTests.cs
@@ -1,9 +1,7 @@
using System.Collections.Generic;
using System.Linq;
-using System.Text;
using Moq;
using NUnit.Framework;
-using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Core.Composing;
using Umbraco.Core.Logging;
diff --git a/src/Umbraco.Tests/Cache/PublishedCache/PublishedContentCacheTests.cs b/src/Umbraco.Tests/Cache/PublishedCache/PublishedContentCacheTests.cs
index 5297f7afd6..00fc5b09b8 100644
--- a/src/Umbraco.Tests/Cache/PublishedCache/PublishedContentCacheTests.cs
+++ b/src/Umbraco.Tests/Cache/PublishedCache/PublishedContentCacheTests.cs
@@ -4,7 +4,7 @@ using Moq;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Cache;
-using Umbraco.Core.Composing;
+using Umbraco.Web.Composing;
using Umbraco.Core.Configuration;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.Services;
@@ -68,9 +68,9 @@ namespace Umbraco.Tests.Cache.PublishedCache
var appCache = new DictionaryAppCache();
var domainCache = new DomainCache(ServiceContext.DomainService, DefaultCultureAccessor);
var publishedShapshot = new PublishedSnapshot(
- new PublishedContentCache(xmlStore, domainCache, appCache, globalSettings, ContentTypesCache, null, null),
- new PublishedMediaCache(xmlStore, ServiceContext.MediaService, ServiceContext.UserService, appCache, ContentTypesCache, Factory.GetInstance(), umbracoContextAccessor),
- new PublishedMemberCache(null, appCache, Current.Services.MemberService, ContentTypesCache, Current.Services.UserService),
+ new PublishedContentCache(xmlStore, domainCache, appCache, globalSettings, ContentTypesCache, null, VariationContextAccessor, null),
+ new PublishedMediaCache(xmlStore, ServiceContext.MediaService, ServiceContext.UserService, appCache, ContentTypesCache, Factory.GetInstance(), umbracoContextAccessor, VariationContextAccessor),
+ new PublishedMemberCache(null, appCache, Current.Services.MemberService, ContentTypesCache, Current.Services.UserService, VariationContextAccessor),
domainCache);
var publishedSnapshotService = new Mock();
publishedSnapshotService.Setup(x => x.CreatePublishedSnapshot(It.IsAny())).Returns(publishedShapshot);
diff --git a/src/Umbraco.Tests/Cache/PublishedCache/PublishedMediaCacheTests.cs b/src/Umbraco.Tests/Cache/PublishedCache/PublishedMediaCacheTests.cs
index 8b9507dab8..36ac57728e 100644
--- a/src/Umbraco.Tests/Cache/PublishedCache/PublishedMediaCacheTests.cs
+++ b/src/Umbraco.Tests/Cache/PublishedCache/PublishedMediaCacheTests.cs
@@ -6,7 +6,6 @@ using Examine;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Cache;
-using Umbraco.Core.Composing;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Core.Strings;
using Umbraco.Tests.TestHelpers;
@@ -79,7 +78,7 @@ namespace Umbraco.Tests.Cache.PublishedCache
var mChild2 = MakeNewMedia("Child2", mType, user, mRoot2.Id);
var ctx = GetUmbracoContext("/test");
- var cache = new PublishedMediaCache(new XmlStore((XmlDocument) null, null, null, null, HostingEnvironment), ServiceContext.MediaService, ServiceContext.UserService, new DictionaryAppCache(), ContentTypesCache, Factory.GetInstance(), Factory.GetInstance());
+ var cache = new PublishedMediaCache(new XmlStore((XmlDocument) null, null, null, null, HostingEnvironment), ServiceContext.MediaService, ServiceContext.UserService, new DictionaryAppCache(), ContentTypesCache, Factory.GetInstance(), Factory.GetInstance(), VariationContextAccessor);
var roots = cache.GetAtRoot();
Assert.AreEqual(2, roots.Count());
Assert.IsTrue(roots.Select(x => x.Id).ContainsAll(new[] {mRoot1.Id, mRoot2.Id}));
@@ -97,7 +96,7 @@ namespace Umbraco.Tests.Cache.PublishedCache
//var publishedMedia = PublishedMediaTests.GetNode(mRoot.Id, GetUmbracoContext("/test", 1234));
var umbracoContext = GetUmbracoContext("/test");
- var cache = new PublishedMediaCache(new XmlStore((XmlDocument)null, null, null, null, HostingEnvironment), Current.Services.MediaService, Current.Services.UserService, new DictionaryAppCache(), ContentTypesCache, Factory.GetInstance(), Factory.GetInstance());
+ var cache = new PublishedMediaCache(new XmlStore((XmlDocument)null, null, null, null, HostingEnvironment), Current.Services.MediaService, Current.Services.UserService, new DictionaryAppCache(), ContentTypesCache, Factory.GetInstance(), Factory.GetInstance(), VariationContextAccessor);
var publishedMedia = cache.GetById(mRoot.Id);
Assert.IsNotNull(publishedMedia);
@@ -208,7 +207,7 @@ namespace Umbraco.Tests.Cache.PublishedCache
var result = new SearchResult("1234", 1, () => fields.ToDictionary(x => x.Key, x => new List { x.Value }));
- var store = new PublishedMediaCache(new XmlStore((XmlDocument)null, null, null, null, HostingEnvironment), ServiceContext.MediaService, ServiceContext.UserService, new DictionaryAppCache(), ContentTypesCache, Factory.GetInstance(), Factory.GetInstance());
+ var store = new PublishedMediaCache(new XmlStore((XmlDocument)null, null, null, null, HostingEnvironment), ServiceContext.MediaService, ServiceContext.UserService, new DictionaryAppCache(), ContentTypesCache, Factory.GetInstance(), Factory.GetInstance(), VariationContextAccessor);
var doc = store.CreateFromCacheValues(store.ConvertFromSearchResult(result));
DoAssert(doc, 1234, key, null, 0, "/media/test.jpg", "Image", 23, "Shannon", "Shannon", 0, 0, "-1,1234", DateTime.Parse("2012-07-17T10:34:09"), DateTime.Parse("2012-07-16T10:34:09"), 2);
@@ -224,7 +223,7 @@ namespace Umbraco.Tests.Cache.PublishedCache
var xmlDoc = GetMediaXml();
((XmlElement)xmlDoc.DocumentElement.FirstChild).SetAttribute("key", key.ToString());
var navigator = xmlDoc.SelectSingleNode("/root/Image").CreateNavigator();
- var cache = new PublishedMediaCache(new XmlStore((XmlDocument)null, null, null, null, HostingEnvironment), ServiceContext.MediaService, ServiceContext.UserService, new DictionaryAppCache(), ContentTypesCache, Factory.GetInstance(), Factory.GetInstance());
+ var cache = new PublishedMediaCache(new XmlStore((XmlDocument)null, null, null, null, HostingEnvironment), ServiceContext.MediaService, ServiceContext.UserService, new DictionaryAppCache(), ContentTypesCache, Factory.GetInstance(), Factory.GetInstance(),VariationContextAccessor);
var doc = cache.CreateFromCacheValues(cache.ConvertFromXPathNavigator(navigator, true));
DoAssert(doc, 2000, key, null, 2, "image1", "Image", 23, "Shannon", "Shannon", 33, 33, "-1,2000", DateTime.Parse("2012-06-12T14:13:17"), DateTime.Parse("2012-07-20T18:50:43"), 1);
@@ -319,6 +318,7 @@ namespace Umbraco.Tests.Cache.PublishedCache
// callback to get a property
(dd, a) => dd.Properties.FirstOrDefault(x => x.Alias.InvariantEquals(a)),
null, // cache provider
+ VariationContextAccessor,
ContentTypesCache,
// no xpath
null,
@@ -329,6 +329,7 @@ namespace Umbraco.Tests.Cache.PublishedCache
// callback to get a property
(dd, a) => dd.Properties.FirstOrDefault(x => x.Alias.InvariantEquals(a)),
null, // cache provider
+ VariationContextAccessor,
ContentTypesCache,
// no xpath
null,
diff --git a/src/Umbraco.Tests/Composing/CollectionBuildersTests.cs b/src/Umbraco.Tests/Composing/CollectionBuildersTests.cs
index 9f18d7a061..575bd869ba 100644
--- a/src/Umbraco.Tests/Composing/CollectionBuildersTests.cs
+++ b/src/Umbraco.Tests/Composing/CollectionBuildersTests.cs
@@ -3,13 +3,13 @@ using System.Collections.Generic;
using System.Linq;
using Moq;
using NUnit.Framework;
-using Umbraco.Core.Composing;
using Umbraco.Core;
using Umbraco.Core.Cache;
-using Umbraco.Core.Configuration;
+using Umbraco.Core.Composing;
using Umbraco.Core.Logging;
using Umbraco.Tests.Components;
using Umbraco.Tests.TestHelpers;
+using Current = Umbraco.Web.Composing.Current;
namespace Umbraco.Tests.Composing
{
diff --git a/src/Umbraco.Tests/Configurations/GlobalSettingsTests.cs b/src/Umbraco.Tests/Configurations/GlobalSettingsTests.cs
index 2b7deb23f8..37e2636bf4 100644
--- a/src/Umbraco.Tests/Configurations/GlobalSettingsTests.cs
+++ b/src/Umbraco.Tests/Configurations/GlobalSettingsTests.cs
@@ -1,7 +1,5 @@
using Moq;
using NUnit.Framework;
-using NUnit.Framework.Internal;
-using Umbraco.Core.Composing;
using Umbraco.Core.Configuration;
using Umbraco.Tests.TestHelpers;
diff --git a/src/Umbraco.Tests/CoreThings/TryConvertToTests.cs b/src/Umbraco.Tests/CoreThings/TryConvertToTests.cs
index 120a7f40c9..5723b51bab 100644
--- a/src/Umbraco.Tests/CoreThings/TryConvertToTests.cs
+++ b/src/Umbraco.Tests/CoreThings/TryConvertToTests.cs
@@ -1,7 +1,6 @@
using System;
using NUnit.Framework;
using Umbraco.Core;
-using Umbraco.Core.Composing;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.Strings;
using Umbraco.Tests.Testing;
diff --git a/src/Umbraco.Tests/CoreThings/UdiTests.cs b/src/Umbraco.Tests/CoreThings/UdiTests.cs
index df5d5363e5..2ab39f3664 100644
--- a/src/Umbraco.Tests/CoreThings/UdiTests.cs
+++ b/src/Umbraco.Tests/CoreThings/UdiTests.cs
@@ -1,20 +1,12 @@
using System;
using System.Collections.Generic;
-using System.IO;
using System.Linq;
using System.Reflection;
-using Moq;
using Newtonsoft.Json;
using NUnit.Framework;
using Umbraco.Core;
-using Umbraco.Core.Cache;
-using Umbraco.Core.Composing;
-using Umbraco.Core.Configuration;
using Umbraco.Core.Deploy;
-using Umbraco.Core.IO;
-using Umbraco.Core.Logging;
using Umbraco.Core.Serialization;
-using Umbraco.Tests.TestHelpers;
namespace Umbraco.Tests.CoreThings
{
@@ -24,7 +16,7 @@ namespace Umbraco.Tests.CoreThings
[SetUp]
public void SetUp()
{
- UdiParser.ResetUdiTypes();
+ UdiParser.ResetUdiTypes();
}
[Test]
@@ -284,20 +276,20 @@ namespace Umbraco.Tests.CoreThings
Assert.IsNull(udi);
UdiParser.ResetUdiTypes();
-
+
// unless we want to know
Assert.IsFalse(UdiParser.TryParse("umb://whatever/1234", true, out udi));
Assert.AreEqual(Constants.UdiEntityType.Unknown, udi.EntityType);
Assert.AreEqual("Umbraco.Core.UnknownTypeUdi", udi.GetType().FullName);
UdiParser.ResetUdiTypes();
-
+
// not known
Assert.IsFalse(UdiParser.TryParse("umb://foo/A87F65C8D6B94E868F6949BA92C93045", true, out udi));
Assert.AreEqual(Constants.UdiEntityType.Unknown, udi.EntityType);
Assert.AreEqual("Umbraco.Core.UnknownTypeUdi", udi.GetType().FullName);
- // scanned
+ // scanned
UdiParserServiceConnectors.RegisterServiceConnector(); // this is the equivalent of scanning but we'll just manually register this one
Assert.IsTrue(UdiParser.TryParse("umb://foo/A87F65C8D6B94E868F6949BA92C93045", out udi));
Assert.IsInstanceOf(udi);
diff --git a/src/Umbraco.Tests/IO/FileSystemsTests.cs b/src/Umbraco.Tests/IO/FileSystemsTests.cs
index 9358923f72..48ac93c2cf 100644
--- a/src/Umbraco.Tests/IO/FileSystemsTests.cs
+++ b/src/Umbraco.Tests/IO/FileSystemsTests.cs
@@ -14,7 +14,6 @@ using Umbraco.Core.Services;
using Umbraco.Tests.Components;
using Umbraco.Tests.TestHelpers;
using Umbraco.Core.Composing.CompositionExtensions;
-using Umbraco.Core.Strings;
using FileSystems = Umbraco.Core.IO.FileSystems;
namespace Umbraco.Tests.IO
diff --git a/src/Umbraco.Tests/IO/IoHelperTests.cs b/src/Umbraco.Tests/IO/IoHelperTests.cs
index 9458f384ce..6e876c4705 100644
--- a/src/Umbraco.Tests/IO/IoHelperTests.cs
+++ b/src/Umbraco.Tests/IO/IoHelperTests.cs
@@ -1,9 +1,6 @@
using System;
using NUnit.Framework;
using Umbraco.Core.IO;
-using Umbraco.Core;
-using Umbraco.Core.Composing;
-using Umbraco.Core.Configuration;
using Umbraco.Core.Strings;
using Umbraco.Tests.TestHelpers;
diff --git a/src/Umbraco.Tests/Integration/ContentEventsTests.cs b/src/Umbraco.Tests/Integration/ContentEventsTests.cs
index 7f103e13e4..575215c41f 100644
--- a/src/Umbraco.Tests/Integration/ContentEventsTests.cs
+++ b/src/Umbraco.Tests/Integration/ContentEventsTests.cs
@@ -5,7 +5,7 @@ using Moq;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Cache;
-using Umbraco.Core.Composing;
+using Umbraco.Web.Composing;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
using Umbraco.Core.Persistence.Repositories.Implement;
@@ -33,7 +33,7 @@ namespace Umbraco.Tests.Integration
{
base.SetUp();
- _h1 = new DistributedCacheBinder(new DistributedCache(), Mock.Of(), Mock.Of());
+ _h1 = new DistributedCacheBinder(new DistributedCache(Current.ServerMessenger, Current.CacheRefreshers), Mock.Of(), Mock.Of());
_h1.BindEvents(true);
_events = new List();
diff --git a/src/Umbraco.Tests/Issues/U9560.cs b/src/Umbraco.Tests/Issues/U9560.cs
index e3f1ee087d..c70b8710ef 100644
--- a/src/Umbraco.Tests/Issues/U9560.cs
+++ b/src/Umbraco.Tests/Issues/U9560.cs
@@ -4,7 +4,6 @@ using Umbraco.Core.Models;
using Umbraco.Core.Persistence;
using Umbraco.Tests.Testing;
using Umbraco.Core;
-using Umbraco.Core.Composing;
using Umbraco.Tests.TestHelpers;
namespace Umbraco.Tests.Issues
diff --git a/src/Umbraco.Tests/LegacyXmlPublishedCache/DictionaryPublishedContent.cs b/src/Umbraco.Tests/LegacyXmlPublishedCache/DictionaryPublishedContent.cs
index db8dc38d6d..31fbb8d6b9 100644
--- a/src/Umbraco.Tests/LegacyXmlPublishedCache/DictionaryPublishedContent.cs
+++ b/src/Umbraco.Tests/LegacyXmlPublishedCache/DictionaryPublishedContent.cs
@@ -37,9 +37,10 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
Func> getChildren,
Func getProperty,
IAppCache appCache,
+ IVariationContextAccessor variationContextAccessor,
PublishedContentTypeCache contentTypeCache,
XPathNavigator nav,
- bool fromExamine)
+ bool fromExamine):base(variationContextAccessor)
{
if (valueDictionary == null) throw new ArgumentNullException(nameof(valueDictionary));
if (getParent == null) throw new ArgumentNullException(nameof(getParent));
diff --git a/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedContentCache.cs b/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedContentCache.cs
index 8ce6b10983..e9a193f35f 100644
--- a/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedContentCache.cs
+++ b/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedContentCache.cs
@@ -9,6 +9,7 @@ using Umbraco.Core.Cache;
using Umbraco.Core.Configuration;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Core.Xml;
+using Umbraco.Tests.TestHelpers;
using Umbraco.Web.PublishedCache;
using Umbraco.Web.Routing;
@@ -19,6 +20,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
private readonly IAppCache _appCache;
private readonly IGlobalSettings _globalSettings;
private readonly RoutesCache _routesCache;
+ private readonly IVariationContextAccessor _variationContextAccessor;
private readonly IDomainCache _domainCache;
private readonly PublishedContentTypeCache _contentTypeCache;
@@ -34,12 +36,14 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
IGlobalSettings globalSettings,
PublishedContentTypeCache contentTypeCache, // a PublishedContentType cache
RoutesCache routesCache, // a RoutesCache
+ IVariationContextAccessor variationContextAccessor,
string previewToken) // a preview token string (or null if not previewing)
: base(previewToken.IsNullOrWhiteSpace() == false)
{
_appCache = appCache;
_globalSettings = globalSettings;
_routesCache = routesCache; // may be null for unit-testing
+ _variationContextAccessor = variationContextAccessor;
_contentTypeCache = contentTypeCache;
_domainCache = domainCache;
@@ -264,7 +268,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
while (hasDomains == false && n != null) // n is null at root
{
// get the url
- var urlName = n.UrlSegment();
+ var urlName = n.UrlSegment(TestHelper.VariationContextAccessor);
pathParts.Add(urlName);
// move to parent node
@@ -313,13 +317,13 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
private IPublishedContent ConvertToDocument(XmlNode xmlNode, bool isPreviewing)
{
- return xmlNode == null ? null : XmlPublishedContent.Get(xmlNode, isPreviewing, _appCache, _contentTypeCache);
+ return xmlNode == null ? null : XmlPublishedContent.Get(xmlNode, isPreviewing, _appCache, _contentTypeCache, _variationContextAccessor);
}
private IEnumerable ConvertToDocuments(XmlNodeList xmlNodes, bool isPreviewing)
{
return xmlNodes.Cast()
- .Select(xmlNode => XmlPublishedContent.Get(xmlNode, isPreviewing, _appCache, _contentTypeCache));
+ .Select(xmlNode => XmlPublishedContent.Get(xmlNode, isPreviewing, _appCache, _contentTypeCache, _variationContextAccessor));
}
#endregion
diff --git a/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedMediaCache.cs b/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedMediaCache.cs
index f0785da744..8594b07692 100644
--- a/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedMediaCache.cs
+++ b/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedMediaCache.cs
@@ -42,13 +42,14 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
private readonly PublishedContentTypeCache _contentTypeCache;
private readonly IEntityXmlSerializer _entitySerializer;
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
+ private readonly IVariationContextAccessor _variationContextAccessor;
// must be specified by the ctor
private readonly IAppCache _appCache;
public PublishedMediaCache(XmlStore xmlStore, IMediaService mediaService, IUserService userService,
IAppCache appCache, PublishedContentTypeCache contentTypeCache, IEntityXmlSerializer entitySerializer,
- IUmbracoContextAccessor umbracoContextAccessor)
+ IUmbracoContextAccessor umbracoContextAccessor, IVariationContextAccessor variationContextAccessor)
: base(false)
{
_mediaService = mediaService ?? throw new ArgumentNullException(nameof(mediaService));
@@ -59,6 +60,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
_contentTypeCache = contentTypeCache;
_entitySerializer = entitySerializer;
_umbracoContextAccessor = umbracoContextAccessor;
+ _variationContextAccessor = variationContextAccessor;
}
///
@@ -672,6 +674,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
GetChildrenMedia,
GetProperty,
_appCache,
+ _variationContextAccessor,
_contentTypeCache,
cacheValues.XPath, // though, outside of tests, that should be null
cacheValues.FromExamine
diff --git a/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedMemberCache.cs b/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedMemberCache.cs
index 6990ffe8a2..e763fd8510 100644
--- a/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedMemberCache.cs
+++ b/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedMemberCache.cs
@@ -1,11 +1,9 @@
-using System;
-using System.Text;
+using System.Text;
using System.Xml.XPath;
using Umbraco.Core.Cache;
-using Umbraco.Core.Composing;
+using Umbraco.Web.Composing;
using Umbraco.Core.Models;
using Umbraco.Core.Models.PublishedContent;
-using Umbraco.Core.Security;
using Umbraco.Core.Services;
using Umbraco.Web.PublishedCache;
using Umbraco.Web.Security;
@@ -19,14 +17,16 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
private readonly XmlStore _xmlStore;
private readonly PublishedContentTypeCache _contentTypeCache;
private readonly IUserService _userService;
+ private readonly IVariationContextAccessor _variationContextAccessor;
- public PublishedMemberCache(XmlStore xmlStore, IAppCache requestCache, IMemberService memberService, PublishedContentTypeCache contentTypeCache, IUserService userService)
+ public PublishedMemberCache(XmlStore xmlStore, IAppCache requestCache, IMemberService memberService, PublishedContentTypeCache contentTypeCache, IUserService userService, IVariationContextAccessor variationContextAccessor)
{
_requestCache = requestCache;
_memberService = memberService;
_xmlStore = xmlStore;
_contentTypeCache = contentTypeCache;
_userService = userService;
+ _variationContextAccessor = variationContextAccessor;
}
public IPublishedContent GetByProviderKey(object key)
@@ -39,7 +39,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
var result = _memberService.GetByProviderKey(key);
if (result == null) return null;
var type = _contentTypeCache.Get(PublishedItemType.Member, result.ContentTypeId);
- return new PublishedMember(result, type, _userService).CreateModel(Current.PublishedModelFactory);
+ return new PublishedMember(result, type, _userService, _variationContextAccessor).CreateModel(Current.PublishedModelFactory);
});
}
@@ -53,7 +53,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
var result = _memberService.GetById(memberId);
if (result == null) return null;
var type = _contentTypeCache.Get(PublishedItemType.Member, result.ContentTypeId);
- return new PublishedMember(result, type, _userService).CreateModel(Current.PublishedModelFactory);
+ return new PublishedMember(result, type, _userService, _variationContextAccessor).CreateModel(Current.PublishedModelFactory);
});
}
@@ -67,7 +67,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
var result = _memberService.GetByUsername(username);
if (result == null) return null;
var type = _contentTypeCache.Get(PublishedItemType.Member, result.ContentTypeId);
- return new PublishedMember(result, type, _userService).CreateModel(Current.PublishedModelFactory);
+ return new PublishedMember(result, type, _userService, _variationContextAccessor).CreateModel(Current.PublishedModelFactory);
});
}
@@ -81,14 +81,14 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
var result = _memberService.GetByEmail(email);
if (result == null) return null;
var type = _contentTypeCache.Get(PublishedItemType.Member, result.ContentTypeId);
- return new PublishedMember(result, type, _userService).CreateModel(Current.PublishedModelFactory);
+ return new PublishedMember(result, type, _userService, _variationContextAccessor).CreateModel(Current.PublishedModelFactory);
});
}
public IPublishedContent GetByMember(IMember member)
{
var type = _contentTypeCache.Get(PublishedItemType.Member, member.ContentTypeId);
- return new PublishedMember(member, type, _userService).CreateModel(Current.PublishedModelFactory);
+ return new PublishedMember(member, type, _userService, _variationContextAccessor).CreateModel(Current.PublishedModelFactory);
}
public XPathNavigator CreateNavigator()
diff --git a/src/Umbraco.Tests/LegacyXmlPublishedCache/XmlPublishedContent.cs b/src/Umbraco.Tests/LegacyXmlPublishedCache/XmlPublishedContent.cs
index f2dbeb954d..03f897b0cc 100644
--- a/src/Umbraco.Tests/LegacyXmlPublishedCache/XmlPublishedContent.cs
+++ b/src/Umbraco.Tests/LegacyXmlPublishedCache/XmlPublishedContent.cs
@@ -26,19 +26,22 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
XmlNode xmlNode,
bool isPreviewing,
IAppCache appCache,
- PublishedContentTypeCache contentTypeCache)
+ PublishedContentTypeCache contentTypeCache,
+ IVariationContextAccessor variationContextAccessor): base(variationContextAccessor)
{
_xmlNode = xmlNode;
_isPreviewing = isPreviewing;
_appCache = appCache;
_contentTypeCache = contentTypeCache;
+ _variationContextAccessor = variationContextAccessor;
}
private readonly XmlNode _xmlNode;
private readonly bool _isPreviewing;
private readonly IAppCache _appCache; // at snapshot/request level (see PublishedContentCache)
private readonly PublishedContentTypeCache _contentTypeCache;
+ private readonly IVariationContextAccessor _variationContextAccessor;
private readonly object _initializeLock = new object();
@@ -272,7 +275,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
if (parent == null) return;
if (parent.Attributes?.GetNamedItem("isDoc") != null)
- _parent = Get(parent, _isPreviewing, _appCache, _contentTypeCache);
+ _parent = Get(parent, _isPreviewing, _appCache, _contentTypeCache, _variationContextAccessor);
_parentInitialized = true;
}
@@ -429,7 +432,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
var iterator = nav.Select(expr);
_children = iterator.Cast()
- .Select(n => Get(((IHasXmlNode) n).GetNode(), _isPreviewing, _appCache, _contentTypeCache))
+ .Select(n => Get(((IHasXmlNode) n).GetNode(), _isPreviewing, _appCache, _contentTypeCache, _variationContextAccessor))
.OrderBy(x => x.SortOrder)
.ToList();
@@ -444,12 +447,13 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
/// A cache.
/// A content type cache.
/// A umbraco context accessor
+ ///
/// The IPublishedContent corresponding to the Xml cache node.
/// Maintains a per-request cache of IPublishedContent items in order to make
/// sure that we create only one instance of each for the duration of a request. The
/// returned IPublishedContent is a model, if models are enabled.
public static IPublishedContent Get(XmlNode node, bool isPreviewing, IAppCache appCache,
- PublishedContentTypeCache contentTypeCache)
+ PublishedContentTypeCache contentTypeCache, IVariationContextAccessor variationContextAccessor)
{
// only 1 per request
@@ -457,7 +461,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
var id = attrs?.GetNamedItem("id").Value;
if (id.IsNullOrWhiteSpace()) throw new InvalidOperationException("Node has no ID attribute.");
var key = CacheKeyPrefix + id; // dont bother with preview, wont change during request in Xml cache
- return (IPublishedContent) appCache.Get(key, () => (new XmlPublishedContent(node, isPreviewing, appCache, contentTypeCache)).CreateModel(Current.PublishedModelFactory));
+ return (IPublishedContent) appCache.Get(key, () => (new XmlPublishedContent(node, isPreviewing, appCache, contentTypeCache, variationContextAccessor)).CreateModel(Current.PublishedModelFactory));
}
public static void ClearRequest()
diff --git a/src/Umbraco.Tests/LegacyXmlPublishedCache/XmlPublishedSnapshotService.cs b/src/Umbraco.Tests/LegacyXmlPublishedCache/XmlPublishedSnapshotService.cs
index cbff346c4d..c723c14c80 100644
--- a/src/Umbraco.Tests/LegacyXmlPublishedCache/XmlPublishedSnapshotService.cs
+++ b/src/Umbraco.Tests/LegacyXmlPublishedCache/XmlPublishedSnapshotService.cs
@@ -38,6 +38,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
private readonly IDefaultCultureAccessor _defaultCultureAccessor;
private readonly ISiteDomainHelper _siteDomainHelper;
private readonly IEntityXmlSerializer _entitySerializer;
+ private readonly IVariationContextAccessor _variationContextAccessor;
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
private readonly IHostingEnvironment _hostingEnvironment;
@@ -58,6 +59,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
IShortStringHelper shortStringHelper,
ISiteDomainHelper siteDomainHelper,
IEntityXmlSerializer entitySerializer,
+
MainDom mainDom,
bool testing = false, bool enableRepositoryEvents = true)
: this(serviceContext, publishedContentTypeFactory, scopeProvider, requestCache,
@@ -103,7 +105,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
_mediaService = serviceContext.MediaService;
_userService = serviceContext.UserService;
_defaultCultureAccessor = defaultCultureAccessor;
-
+ _variationContextAccessor = variationContextAccessor;
_requestCache = requestCache;
_umbracoContextAccessor = umbracoContextAccessor;
_globalSettings = globalSettings;
@@ -153,9 +155,9 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
var domainCache = new DomainCache(_domainService, _defaultCultureAccessor);
return new PublishedSnapshot(
- new PublishedContentCache(_xmlStore, domainCache, _requestCache, _globalSettings, _contentTypeCache, _routesCache, previewToken),
- new PublishedMediaCache(_xmlStore, _mediaService, _userService, _requestCache, _contentTypeCache, _entitySerializer, _umbracoContextAccessor),
- new PublishedMemberCache(_xmlStore, _requestCache, _memberService, _contentTypeCache, _userService),
+ new PublishedContentCache(_xmlStore, domainCache, _requestCache, _globalSettings, _contentTypeCache, _routesCache,_variationContextAccessor, previewToken),
+ new PublishedMediaCache(_xmlStore, _mediaService, _userService, _requestCache, _contentTypeCache, _entitySerializer, _umbracoContextAccessor, _variationContextAccessor),
+ new PublishedMemberCache(_xmlStore, _requestCache, _memberService, _contentTypeCache, _userService, _variationContextAccessor),
domainCache);
}
diff --git a/src/Umbraco.Tests/Logging/LogviewerTests.cs b/src/Umbraco.Tests/Logging/LogviewerTests.cs
index cddd01c178..6e0e82827c 100644
--- a/src/Umbraco.Tests/Logging/LogviewerTests.cs
+++ b/src/Umbraco.Tests/Logging/LogviewerTests.cs
@@ -4,8 +4,6 @@ using System;
using System.IO;
using System.Linq;
using Umbraco.Core;
-using Umbraco.Core.Composing;
-using Umbraco.Core.IO;
using Umbraco.Core.Logging.Viewer;
using Umbraco.Tests.TestHelpers;
diff --git a/src/Umbraco.Tests/Macros/MacroTests.cs b/src/Umbraco.Tests/Macros/MacroTests.cs
index cf56f407ce..7f1bb1a8e3 100644
--- a/src/Umbraco.Tests/Macros/MacroTests.cs
+++ b/src/Umbraco.Tests/Macros/MacroTests.cs
@@ -3,7 +3,6 @@ using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Core.Composing;
-using Umbraco.Core.Configuration;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
using Umbraco.Tests.TestHelpers;
diff --git a/src/Umbraco.Tests/Manifest/ManifestParserTests.cs b/src/Umbraco.Tests/Manifest/ManifestParserTests.cs
index f08706a9d0..661c9cff0e 100644
--- a/src/Umbraco.Tests/Manifest/ManifestParserTests.cs
+++ b/src/Umbraco.Tests/Manifest/ManifestParserTests.cs
@@ -6,14 +6,12 @@ using NUnit.Framework;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Umbraco.Core.Cache;
-using Umbraco.Core.Composing;
using Umbraco.Core.Logging;
using Umbraco.Core.Manifest;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.PropertyEditors.Validators;
using Umbraco.Core.Services;
using Umbraco.Core.Dashboards;
-using Umbraco.Core.IO;
using Umbraco.Core.Serialization;
using Umbraco.Core.Strings;
using Umbraco.Tests.TestHelpers;
diff --git a/src/Umbraco.Tests/Models/ContentExtensionsTests.cs b/src/Umbraco.Tests/Models/ContentExtensionsTests.cs
index efd59f88bf..87bd661015 100644
--- a/src/Umbraco.Tests/Models/ContentExtensionsTests.cs
+++ b/src/Umbraco.Tests/Models/ContentExtensionsTests.cs
@@ -10,7 +10,6 @@ using Umbraco.Core.Models;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Services;
using Umbraco.Core.Services.Implement;
-using Umbraco.Tests.TestHelpers;
using Umbraco.Tests.TestHelpers.Entities;
using Umbraco.Tests.Testing;
using Umbraco.Web.PropertyEditors;
diff --git a/src/Umbraco.Tests/Models/ContentXmlTest.cs b/src/Umbraco.Tests/Models/ContentXmlTest.cs
index fe58889d05..70307b9bad 100644
--- a/src/Umbraco.Tests/Models/ContentXmlTest.cs
+++ b/src/Umbraco.Tests/Models/ContentXmlTest.cs
@@ -2,8 +2,6 @@
using System.Xml.Linq;
using NUnit.Framework;
using Umbraco.Core;
-using Umbraco.Core.Composing;
-using Umbraco.Core.Models;
using Umbraco.Core.Services;
using Umbraco.Core.Strings;
using Umbraco.Tests.TestHelpers;
diff --git a/src/Umbraco.Tests/Models/Mapping/ContentWebModelMappingTests.cs b/src/Umbraco.Tests/Models/Mapping/ContentWebModelMappingTests.cs
index 36d467a0be..ad65ef0a47 100644
--- a/src/Umbraco.Tests/Models/Mapping/ContentWebModelMappingTests.cs
+++ b/src/Umbraco.Tests/Models/Mapping/ContentWebModelMappingTests.cs
@@ -6,7 +6,6 @@ using Umbraco.Core;
using Umbraco.Core.Composing.CompositionExtensions;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.Services;
-using Umbraco.Core.Dictionary;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
using Umbraco.Core.PropertyEditors;
diff --git a/src/Umbraco.Tests/PublishedContent/NuCacheChildrenTests.cs b/src/Umbraco.Tests/PublishedContent/NuCacheChildrenTests.cs
index 943125bd21..f9c7b566db 100644
--- a/src/Umbraco.Tests/PublishedContent/NuCacheChildrenTests.cs
+++ b/src/Umbraco.Tests/PublishedContent/NuCacheChildrenTests.cs
@@ -37,6 +37,7 @@ namespace Umbraco.Tests.PublishedContent
public class NuCacheChildrenTests
{
private IPublishedModelFactory PublishedModelFactory { get; } = new NoopPublishedModelFactory();
+ private IVariationContextAccessor VariationContextAccessor { get; } = TestHelper.VariationContextAccessor;
private IPublishedSnapshotService _snapshotService;
private IVariationContextAccessor _variationAccesor;
@@ -402,19 +403,19 @@ namespace Umbraco.Tests.PublishedContent
var documents = snapshot.Content.GetAtRoot().ToArray();
AssertDocuments(documents, "N1", "N2", "N3");
- documents = snapshot.Content.GetById(1).Children().ToArray();
+ documents = snapshot.Content.GetById(1).Children(_variationAccesor).ToArray();
AssertDocuments(documents, "N4", "N5", "N6");
- documents = snapshot.Content.GetById(2).Children().ToArray();
+ documents = snapshot.Content.GetById(2).Children(_variationAccesor).ToArray();
AssertDocuments(documents, "N9", "N8", "N7");
- documents = snapshot.Content.GetById(3).Children().ToArray();
+ documents = snapshot.Content.GetById(3).Children(_variationAccesor).ToArray();
AssertDocuments(documents, "N10");
- documents = snapshot.Content.GetById(4).Children().ToArray();
+ documents = snapshot.Content.GetById(4).Children(_variationAccesor).ToArray();
AssertDocuments(documents, "N11", "N12");
- documents = snapshot.Content.GetById(10).Children().ToArray();
+ documents = snapshot.Content.GetById(10).Children(_variationAccesor).ToArray();
AssertDocuments(documents);
}
@@ -480,7 +481,7 @@ namespace Umbraco.Tests.PublishedContent
var documents = snapshot.Content.GetAtRoot().ToArray();
AssertDocuments(documents, "N1", "N2", "N3", "N10");
- documents = snapshot.Content.GetById(3).Children().ToArray();
+ documents = snapshot.Content.GetById(3).Children(_variationAccesor).ToArray();
AssertDocuments(documents);
Assert.IsNull(snapshot.Content.GetById(10).Parent);
@@ -522,7 +523,7 @@ namespace Umbraco.Tests.PublishedContent
var documents = snapshot.Content.GetAtRoot().ToArray();
AssertDocuments(documents, "N2", "N3");
- documents = snapshot.Content.GetById(10).Children().ToArray();
+ documents = snapshot.Content.GetById(10).Children(_variationAccesor).ToArray();
AssertDocuments(documents, "N1");
Assert.AreEqual(10, snapshot.Content.GetById(1).Parent?.Id);
@@ -599,7 +600,7 @@ namespace Umbraco.Tests.PublishedContent
_snapshotService.Notify(new[] { new ContentCacheRefresher.JsonPayload(kit.Node.ParentContentId, Guid.Empty, TreeChangeTypes.RefreshBranch) }, out _, out _);
// changes that *I* make are immediately visible on the current snapshot
- var documents = snapshot.Content.GetById(kit.Node.ParentContentId).Children().ToArray();
+ var documents = snapshot.Content.GetById(kit.Node.ParentContentId).Children(_variationAccesor).ToArray();
AssertDocuments(documents, "N7", "N9", "N8");
}
@@ -698,10 +699,10 @@ namespace Umbraco.Tests.PublishedContent
}, out _, out _);
// changes that *I* make are immediately visible on the current snapshot
- var documents = snapshot.Content.GetById(1).Children().ToArray();
+ var documents = snapshot.Content.GetById(1).Children(_variationAccesor).ToArray();
AssertDocuments(documents, "N7", "N4", "N5", "N6");
- documents = snapshot.Content.GetById(2).Children().ToArray();
+ documents = snapshot.Content.GetById(2).Children(_variationAccesor).ToArray();
AssertDocuments(documents, "N9", "N8");
Assert.AreEqual(1, snapshot.Content.GetById(7).Parent?.Id);
@@ -723,15 +724,15 @@ namespace Umbraco.Tests.PublishedContent
var documents = snapshot.Content.GetAtRoot().ToArray();
AssertDocuments(documents, "N1-en-US");
- documents = snapshot.Content.GetById(1).Children().ToArray();
+ documents = snapshot.Content.GetById(1).Children(_variationAccesor).ToArray();
AssertDocuments(documents, "N4", "N7-en-US");
//Get the invariant and list children, there's a variation context so it should return invariant AND en-us variants
- documents = snapshot.Content.GetById(4).Children().ToArray();
+ documents = snapshot.Content.GetById(4).Children(_variationAccesor).ToArray();
AssertDocuments(documents, "N10-en-US", "N11");
//Get the variant and list children, there's a variation context so it should return invariant AND en-us variants
- documents = snapshot.Content.GetById(7).Children().ToArray();
+ documents = snapshot.Content.GetById(7).Children(_variationAccesor).ToArray();
AssertDocuments(documents, "N12-en-US", "N13");
//TEST with fr-fr variation context
@@ -741,15 +742,15 @@ namespace Umbraco.Tests.PublishedContent
documents = snapshot.Content.GetAtRoot().ToArray();
AssertDocuments(documents, "N1-fr-FR");
- documents = snapshot.Content.GetById(1).Children().ToArray();
+ documents = snapshot.Content.GetById(1).Children(_variationAccesor).ToArray();
AssertDocuments(documents, "N4", "N7-fr-FR");
//Get the invariant and list children, there's a variation context so it should return invariant AND en-us variants
- documents = snapshot.Content.GetById(4).Children().ToArray();
+ documents = snapshot.Content.GetById(4).Children(_variationAccesor).ToArray();
AssertDocuments(documents, "N10-fr-FR", "N11");
//Get the variant and list children, there's a variation context so it should return invariant AND en-us variants
- documents = snapshot.Content.GetById(7).Children().ToArray();
+ documents = snapshot.Content.GetById(7).Children(_variationAccesor).ToArray();
AssertDocuments(documents, "N12-fr-FR", "N13");
//TEST specific cultures
@@ -757,19 +758,19 @@ namespace Umbraco.Tests.PublishedContent
documents = snapshot.Content.GetAtRoot("fr-FR").ToArray();
AssertDocuments(documents, "N1-fr-FR");
- documents = snapshot.Content.GetById(1).Children("fr-FR").ToArray();
+ documents = snapshot.Content.GetById(1).Children(_variationAccesor, "fr-FR").ToArray();
AssertDocuments(documents, "N4", "N7-fr-FR"); //NOTE: Returns invariant, this is expected
- documents = snapshot.Content.GetById(1).Children("").ToArray();
+ documents = snapshot.Content.GetById(1).Children(_variationAccesor, "").ToArray();
AssertDocuments(documents, "N4"); //Only returns invariant since that is what was requested
- documents = snapshot.Content.GetById(4).Children("fr-FR").ToArray();
+ documents = snapshot.Content.GetById(4).Children(_variationAccesor, "fr-FR").ToArray();
AssertDocuments(documents, "N10-fr-FR", "N11"); //NOTE: Returns invariant, this is expected
- documents = snapshot.Content.GetById(4).Children("").ToArray();
+ documents = snapshot.Content.GetById(4).Children(_variationAccesor, "").ToArray();
AssertDocuments(documents, "N11"); //Only returns invariant since that is what was requested
- documents = snapshot.Content.GetById(7).Children("fr-FR").ToArray();
+ documents = snapshot.Content.GetById(7).Children(_variationAccesor, "fr-FR").ToArray();
AssertDocuments(documents, "N12-fr-FR", "N13"); //NOTE: Returns invariant, this is expected
- documents = snapshot.Content.GetById(7).Children("").ToArray();
+ documents = snapshot.Content.GetById(7).Children(_variationAccesor, "").ToArray();
AssertDocuments(documents, "N13"); //Only returns invariant since that is what was requested
//TEST without variation context
@@ -785,15 +786,15 @@ namespace Umbraco.Tests.PublishedContent
documents = snapshot.Content.GetAtRoot("fr-FR").ToArray();
Assert.AreEqual(1, documents.Length);
- documents = snapshot.Content.GetById(1).Children().ToArray();
+ documents = snapshot.Content.GetById(1).Children(_variationAccesor).ToArray();
AssertDocuments(documents, "N4");
//Get the invariant and list children
- documents = snapshot.Content.GetById(4).Children().ToArray();
+ documents = snapshot.Content.GetById(4).Children(_variationAccesor).ToArray();
AssertDocuments(documents, "N11");
//Get the variant and list children
- documents = snapshot.Content.GetById(7).Children().ToArray();
+ documents = snapshot.Content.GetById(7).Children(_variationAccesor).ToArray();
AssertDocuments(documents, "N13");
}
@@ -810,19 +811,19 @@ namespace Umbraco.Tests.PublishedContent
var documents = snapshot.Content.GetAtRoot().ToArray();
AssertDocuments(documents, "N1-en-US", "N2-en-US", "N3-en-US");
- documents = snapshot.Content.GetById(1).Children().ToArray();
+ documents = snapshot.Content.GetById(1).Children(_variationAccesor).ToArray();
AssertDocuments(documents, "N4-en-US", "N5-en-US", "N6-en-US");
- documents = snapshot.Content.GetById(2).Children().ToArray();
+ documents = snapshot.Content.GetById(2).Children(_variationAccesor).ToArray();
AssertDocuments(documents, "N9-en-US", "N8-en-US", "N7-en-US");
- documents = snapshot.Content.GetById(3).Children().ToArray();
+ documents = snapshot.Content.GetById(3).Children(_variationAccesor).ToArray();
AssertDocuments(documents, "N10-en-US");
- documents = snapshot.Content.GetById(4).Children().ToArray();
+ documents = snapshot.Content.GetById(4).Children(_variationAccesor).ToArray();
AssertDocuments(documents, "N11-en-US", "N12-en-US");
- documents = snapshot.Content.GetById(10).Children().ToArray();
+ documents = snapshot.Content.GetById(10).Children(_variationAccesor).ToArray();
AssertDocuments(documents);
@@ -831,26 +832,26 @@ namespace Umbraco.Tests.PublishedContent
documents = snapshot.Content.GetAtRoot().ToArray();
AssertDocuments(documents, "N1-fr-FR", "N3-fr-FR");
- documents = snapshot.Content.GetById(1).Children().ToArray();
+ documents = snapshot.Content.GetById(1).Children(_variationAccesor).ToArray();
AssertDocuments(documents, "N4-fr-FR", "N6-fr-FR");
- documents = snapshot.Content.GetById(2).Children().ToArray();
+ documents = snapshot.Content.GetById(2).Children(_variationAccesor).ToArray();
AssertDocuments(documents, "N9-fr-FR", "N7-fr-FR");
- documents = snapshot.Content.GetById(3).Children().ToArray();
+ documents = snapshot.Content.GetById(3).Children(_variationAccesor).ToArray();
AssertDocuments(documents, "N10-fr-FR");
- documents = snapshot.Content.GetById(4).Children().ToArray();
+ documents = snapshot.Content.GetById(4).Children(_variationAccesor).ToArray();
AssertDocuments(documents, "N12-fr-FR");
- documents = snapshot.Content.GetById(10).Children().ToArray();
+ documents = snapshot.Content.GetById(10).Children(_variationAccesor).ToArray();
AssertDocuments(documents);
- documents = snapshot.Content.GetById(1).Children("*").ToArray();
+ documents = snapshot.Content.GetById(1).Children(_variationAccesor, "*").ToArray();
AssertDocuments(documents, "N4-fr-FR", null, "N6-fr-FR");
AssertDocuments("en-US", documents, "N4-en-US", "N5-en-US", "N6-en-US");
- documents = snapshot.Content.GetById(1).Children("en-US").ToArray();
+ documents = snapshot.Content.GetById(1).Children(_variationAccesor, "en-US").ToArray();
AssertDocuments(documents, "N4-fr-FR", null, "N6-fr-FR");
AssertDocuments("en-US", documents, "N4-en-US", "N5-en-US", "N6-en-US");
@@ -880,10 +881,10 @@ namespace Umbraco.Tests.PublishedContent
var documents = snapshot.Content.GetAtRoot().ToArray();
AssertDocuments(documents, "N1", "N2", "N3");
- documents = snapshot.Content.GetById(1).Children().ToArray();
+ documents = snapshot.Content.GetById(1).Children(_variationAccesor).ToArray();
AssertDocuments(documents, "N4", "N5", "N6");
- documents = snapshot.Content.GetById(2).Children().ToArray();
+ documents = snapshot.Content.GetById(2).Children(_variationAccesor).ToArray();
AssertDocuments(documents, "N9", "N8", "N7");
// notify
@@ -897,10 +898,10 @@ namespace Umbraco.Tests.PublishedContent
documents = snapshot.Content.GetAtRoot().ToArray();
AssertDocuments(documents, "N1", "N2");
- documents = snapshot.Content.GetById(1).Children().ToArray();
+ documents = snapshot.Content.GetById(1).Children(_variationAccesor).ToArray();
AssertDocuments(documents, "N4", "N6");
- documents = snapshot.Content.GetById(2).Children().ToArray();
+ documents = snapshot.Content.GetById(2).Children(_variationAccesor).ToArray();
AssertDocuments(documents, "N8", "N7");
// notify
@@ -914,7 +915,7 @@ namespace Umbraco.Tests.PublishedContent
documents = snapshot.Content.GetAtRoot().ToArray();
AssertDocuments(documents, "N2");
- documents = snapshot.Content.GetById(2).Children().ToArray();
+ documents = snapshot.Content.GetById(2).Children(_variationAccesor).ToArray();
AssertDocuments(documents);
}
@@ -929,10 +930,10 @@ namespace Umbraco.Tests.PublishedContent
var documents = snapshot.Content.GetAtRoot().ToArray();
AssertDocuments(documents, "N1", "N2", "N3");
- documents = snapshot.Content.GetById(1).Children().ToArray();
+ documents = snapshot.Content.GetById(1).Children(_variationAccesor).ToArray();
AssertDocuments(documents, "N4", "N5", "N6");
- documents = snapshot.Content.GetById(2).Children().ToArray();
+ documents = snapshot.Content.GetById(2).Children(_variationAccesor).ToArray();
AssertDocuments(documents, "N9", "N8", "N7");
// notify
@@ -945,10 +946,10 @@ namespace Umbraco.Tests.PublishedContent
documents = snapshot.Content.GetAtRoot().ToArray();
AssertDocuments(documents, "N1", "N2", "N3");
- documents = snapshot.Content.GetById(1).Children().ToArray();
+ documents = snapshot.Content.GetById(1).Children(_variationAccesor).ToArray();
AssertDocuments(documents, "N4", "N5", "N6");
- documents = snapshot.Content.GetById(2).Children().ToArray();
+ documents = snapshot.Content.GetById(2).Children(_variationAccesor).ToArray();
AssertDocuments(documents, "N9", "N8", "N7");
}
@@ -1321,7 +1322,7 @@ namespace Umbraco.Tests.PublishedContent
{
Assert.AreEqual(names.Length, documents.Length);
for (var i = 0; i < names.Length; i++)
- Assert.AreEqual(names[i], documents[i].Name(culture));
+ Assert.AreEqual(names[i], documents[i].Name(_variationAccesor, culture));
}
}
}
diff --git a/src/Umbraco.Tests/PublishedContent/NuCacheTests.cs b/src/Umbraco.Tests/PublishedContent/NuCacheTests.cs
index 92c0d697fb..00bad48a53 100644
--- a/src/Umbraco.Tests/PublishedContent/NuCacheTests.cs
+++ b/src/Umbraco.Tests/PublishedContent/NuCacheTests.cs
@@ -231,30 +231,30 @@ namespace Umbraco.Tests.PublishedContent
Assert.AreEqual("val-fr1", publishedContent.Value("prop", "fr-FR"));
Assert.AreEqual("val-uk1", publishedContent.Value("prop", "en-UK"));
- Assert.IsNull(publishedContent.Name()); // no invariant name for varying content
- Assert.AreEqual("name-fr1", publishedContent.Name("fr-FR"));
- Assert.AreEqual("name-uk1", publishedContent.Name("en-UK"));
+ Assert.IsNull(publishedContent.Name(_variationAccesor)); // no invariant name for varying content
+ Assert.AreEqual("name-fr1", publishedContent.Name(_variationAccesor, "fr-FR"));
+ Assert.AreEqual("name-uk1", publishedContent.Name(_variationAccesor, "en-UK"));
var draftContent = snapshot.Content.GetById(true, 1);
Assert.AreEqual("val2", draftContent.Value("prop"));
Assert.AreEqual("val-fr2", draftContent.Value("prop", "fr-FR"));
Assert.AreEqual("val-uk2", draftContent.Value("prop", "en-UK"));
- Assert.IsNull(draftContent.Name()); // no invariant name for varying content
- Assert.AreEqual("name-fr2", draftContent.Name("fr-FR"));
- Assert.AreEqual("name-uk2", draftContent.Name("en-UK"));
+ Assert.IsNull(draftContent.Name(_variationAccesor)); // no invariant name for varying content
+ Assert.AreEqual("name-fr2", draftContent.Name(_variationAccesor, "fr-FR"));
+ Assert.AreEqual("name-uk2", draftContent.Name(_variationAccesor, "en-UK"));
// now french is default
_variationAccesor.VariationContext = new VariationContext("fr-FR");
Assert.AreEqual("val-fr1", publishedContent.Value("prop"));
- Assert.AreEqual("name-fr1", publishedContent.Name());
- Assert.AreEqual(new DateTime(2018, 01, 01, 01, 00, 00), publishedContent.CultureDate());
+ Assert.AreEqual("name-fr1", publishedContent.Name(_variationAccesor));
+ Assert.AreEqual(new DateTime(2018, 01, 01, 01, 00, 00), publishedContent.CultureDate(_variationAccesor));
// now uk is default
_variationAccesor.VariationContext = new VariationContext("en-UK");
Assert.AreEqual("val-uk1", publishedContent.Value("prop"));
- Assert.AreEqual("name-uk1", publishedContent.Name());
- Assert.AreEqual(new DateTime(2018, 01, 02, 01, 00, 00), publishedContent.CultureDate());
+ Assert.AreEqual("name-uk1", publishedContent.Name(_variationAccesor));
+ Assert.AreEqual(new DateTime(2018, 01, 02, 01, 00, 00), publishedContent.CultureDate(_variationAccesor));
// invariant needs to be retrieved explicitly, when it's not default
Assert.AreEqual("val1", publishedContent.Value("prop", culture: ""));
@@ -274,7 +274,7 @@ namespace Umbraco.Tests.PublishedContent
Assert.AreEqual(ContentVariation.Nothing, againContent.ContentType.GetPropertyType("prop").Variations);
// now, "no culture" means "invariant"
- Assert.AreEqual("It Works1!", againContent.Name());
+ Assert.AreEqual("It Works1!", againContent.Name(_variationAccesor));
Assert.AreEqual("val1", againContent.Value("prop"));
}
diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentMoreTests.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentMoreTests.cs
index 440474ae74..a87e3cff8f 100644
--- a/src/Umbraco.Tests/PublishedContent/PublishedContentMoreTests.cs
+++ b/src/Umbraco.Tests/PublishedContent/PublishedContentMoreTests.cs
@@ -102,7 +102,7 @@ namespace Umbraco.Tests.PublishedContent
public void First()
{
var content = Current.UmbracoContext.Content.GetAtRoot().First();
- Assert.AreEqual("Content 1", content.Name());
+ Assert.AreEqual("Content 1", content.Name(VariationContextAccessor));
}
[Test]
diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs
index d08a573917..8428cb9ff4 100644
--- a/src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs
+++ b/src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs
@@ -184,7 +184,7 @@ namespace Umbraco.Tests.PublishedContent
{
var doc = GetNode(1173);
- var items = doc.Children().Where(x => x.IsVisible()).ToIndexedArray();
+ var items = doc.Children(VariationContextAccessor).Where(x => x.IsVisible()).ToIndexedArray();
foreach (var item in items)
{
@@ -205,7 +205,7 @@ namespace Umbraco.Tests.PublishedContent
var doc = GetNode(1173);
var items = doc
- .Children()
+ .Children(VariationContextAccessor)
.Where(x => x.IsVisible())
.ToIndexedArray();
@@ -260,7 +260,7 @@ namespace Umbraco.Tests.PublishedContent
var doc = GetNode(1173);
var ct = doc.ContentType;
- var items = doc.Children()
+ var items = doc.Children(VariationContextAccessor)
.Select(x => x.CreateModel(Current.PublishedModelFactory)) // linq, returns IEnumerable
// only way around this is to make sure every IEnumerable extension
@@ -292,7 +292,7 @@ namespace Umbraco.Tests.PublishedContent
{
var doc = GetNode(1173);
- var items = doc.Children().Take(4).ToIndexedArray();
+ var items = doc.Children(VariationContextAccessor).Take(4).ToIndexedArray();
foreach (var item in items)
{
@@ -312,7 +312,7 @@ namespace Umbraco.Tests.PublishedContent
{
var doc = GetNode(1173);
- foreach (var d in doc.Children().Skip(1).ToIndexedArray())
+ foreach (var d in doc.Children(VariationContextAccessor).Skip(1).ToIndexedArray())
{
if (d.Content.Id != 1176)
{
@@ -330,7 +330,7 @@ namespace Umbraco.Tests.PublishedContent
{
var doc = GetNode(1173);
- var items = doc.Children()
+ var items = doc.Children(VariationContextAccessor)
.Concat(new[] { GetNode(1175), GetNode(4444) })
.ToIndexedArray();
@@ -415,7 +415,7 @@ namespace Umbraco.Tests.PublishedContent
var doc = GetNode(1046);
- var found1 = doc.Children().GroupBy(x => x.ContentType.Alias).ToArray();
+ var found1 = doc.Children(VariationContextAccessor).GroupBy(x => x.ContentType.Alias).ToArray();
Assert.AreEqual(2, found1.Length);
Assert.AreEqual(2, found1.Single(x => x.Key.ToString() == "Home").Count());
@@ -436,8 +436,8 @@ namespace Umbraco.Tests.PublishedContent
var doc = GetNode(1046);
- var found1 = doc.Children().Where(x => x.ContentType.Alias == "CustomDocument");
- var found2 = doc.Children().Where(x => x.ContentType.Alias == "Home");
+ var found1 = doc.Children(VariationContextAccessor).Where(x => x.ContentType.Alias == "CustomDocument");
+ var found2 = doc.Children(VariationContextAccessor).Where(x => x.ContentType.Alias == "Home");
Assert.AreEqual(1, found1.Count());
Assert.AreEqual(2, found2.Count());
@@ -448,7 +448,7 @@ namespace Umbraco.Tests.PublishedContent
{
var doc = GetNode(1173);
- var ordered = doc.Children().OrderBy(x => x.UpdateDate);
+ var ordered = doc.Children(VariationContextAccessor).OrderBy(x => x.UpdateDate);
var correctOrder = new[] { 1178, 1177, 1174, 1176 };
for (var i = 0; i < correctOrder.Length; i++)
diff --git a/src/Umbraco.Tests/PublishedContent/PublishedMediaTests.cs b/src/Umbraco.Tests/PublishedContent/PublishedMediaTests.cs
index 1ca0d82835..94e85dd011 100644
--- a/src/Umbraco.Tests/PublishedContent/PublishedMediaTests.cs
+++ b/src/Umbraco.Tests/PublishedContent/PublishedMediaTests.cs
@@ -72,7 +72,7 @@ namespace Umbraco.Tests.PublishedContent
{
var cache = new PublishedMediaCache(new XmlStore((XmlDocument)null, null, null, null, HostingEnvironment),
ServiceContext.MediaService, ServiceContext.UserService, new DictionaryAppCache(), ContentTypesCache,
- Factory.GetInstance(), Factory.GetInstance());
+ Factory.GetInstance(), Factory.GetInstance(), VariationContextAccessor);
var doc = cache.GetById(id);
Assert.IsNotNull(doc);
return doc;
@@ -133,7 +133,7 @@ namespace Umbraco.Tests.PublishedContent
//we are using the media.xml media to test the examine results implementation, see the media.xml file in the ExamineHelpers namespace
var publishedMedia = cache.GetById(1111);
- var rootChildren = publishedMedia.Children().ToArray();
+ var rootChildren = publishedMedia.Children(VariationContextAccessor).ToArray();
var currSort = 0;
for (var i = 0; i < rootChildren.Count(); i++)
{
@@ -210,11 +210,11 @@ namespace Umbraco.Tests.PublishedContent
//we are using the media.xml media to test the examine results implementation, see the media.xml file in the ExamineHelpers namespace
var publishedMedia = cache.GetById(1111);
- var rootChildren = publishedMedia.Children();
+ var rootChildren = publishedMedia.Children(VariationContextAccessor);
Assert.IsTrue(rootChildren.Select(x => x.Id).ContainsAll(new[] { 2222, 1113, 1114, 1115, 1116 }));
var publishedChild1 = cache.GetById(2222);
- var subChildren = publishedChild1.Children();
+ var subChildren = publishedChild1.Children(VariationContextAccessor);
Assert.IsTrue(subChildren.Select(x => x.Id).ContainsAll(new[] { 2112 }));
}
}
@@ -342,11 +342,11 @@ namespace Umbraco.Tests.PublishedContent
var mSubChild3 = MakeNewMedia("SubChild3", mType, user, mChild1.Id);
var publishedMedia = GetNode(mRoot.Id);
- var rootChildren = publishedMedia.Children();
+ var rootChildren = publishedMedia.Children(VariationContextAccessor);
Assert.IsTrue(rootChildren.Select(x => x.Id).ContainsAll(new[] { mChild1.Id, mChild2.Id, mChild3.Id }));
var publishedChild1 = GetNode(mChild1.Id);
- var subChildren = publishedChild1.Children();
+ var subChildren = publishedChild1.Children(VariationContextAccessor);
Assert.IsTrue(subChildren.Select(x => x.Id).ContainsAll(new[] { mSubChild1.Id, mSubChild2.Id, mSubChild3.Id }));
}
@@ -485,7 +485,7 @@ namespace Umbraco.Tests.PublishedContent
");
var node = xml.DescendantsAndSelf("Image").Single(x => (int)x.Attribute("id") == nodeId);
- var publishedMedia = new PublishedMediaCache(new XmlStore((XmlDocument)null, null, null, null, HostingEnvironment), ServiceContext.MediaService, ServiceContext.UserService, new DictionaryAppCache(), ContentTypesCache, Factory.GetInstance(), Factory.GetInstance());
+ var publishedMedia = new PublishedMediaCache(new XmlStore((XmlDocument)null, null, null, null, HostingEnvironment), ServiceContext.MediaService, ServiceContext.UserService, new DictionaryAppCache(), ContentTypesCache, Factory.GetInstance(), Factory.GetInstance(), VariationContextAccessor);
var nav = node.CreateNavigator();
@@ -505,7 +505,7 @@ namespace Umbraco.Tests.PublishedContent
var errorXml = new XElement("error", string.Format("No media is maching '{0}'", 1234));
var nav = errorXml.CreateNavigator();
- var publishedMedia = new PublishedMediaCache(new XmlStore((XmlDocument)null, null, null, null, HostingEnvironment), ServiceContext.MediaService, ServiceContext.UserService, new DictionaryAppCache(), ContentTypesCache, Factory.GetInstance(), Factory.GetInstance());
+ var publishedMedia = new PublishedMediaCache(new XmlStore((XmlDocument)null, null, null, null, HostingEnvironment), ServiceContext.MediaService, ServiceContext.UserService, new DictionaryAppCache(), ContentTypesCache, Factory.GetInstance(), Factory.GetInstance(), VariationContextAccessor);
var converted = publishedMedia.ConvertFromXPathNodeIterator(nav.Select("/"), 1234);
Assert.IsNull(converted);
diff --git a/src/Umbraco.Tests/Routing/GetContentUrlsTests.cs b/src/Umbraco.Tests/Routing/GetContentUrlsTests.cs
index 8ff5d1cedc..377594b0f5 100644
--- a/src/Umbraco.Tests/Routing/GetContentUrlsTests.cs
+++ b/src/Umbraco.Tests/Routing/GetContentUrlsTests.cs
@@ -54,6 +54,7 @@ namespace Umbraco.Tests.Routing
var urls = content.GetContentUrls(publishedRouter,
umbContext,
GetLangService("en-US", "fr-FR"), GetTextService(), ServiceContext.ContentService,
+ VariationContextAccessor,
Logger).ToList();
Assert.AreEqual(1, urls.Count);
@@ -79,7 +80,7 @@ namespace Umbraco.Tests.Routing
var urls = content.GetContentUrls(publishedRouter,
umbContext,
GetLangService("en-US", "fr-FR"), GetTextService(), ServiceContext.ContentService,
- Logger).ToList();
+ VariationContextAccessor, Logger).ToList();
Assert.AreEqual(1, urls.Count);
Assert.AreEqual("/home/", urls[0].Text);
@@ -111,7 +112,7 @@ namespace Umbraco.Tests.Routing
var urls = child.GetContentUrls(publishedRouter,
umbContext,
GetLangService("en-US", "fr-FR"), GetTextService(), ServiceContext.ContentService,
- Logger).ToList();
+ VariationContextAccessor, Logger).ToList();
Assert.AreEqual(1, urls.Count);
Assert.AreEqual("/home/sub1/", urls[0].Text);
diff --git a/src/Umbraco.Tests/Runtimes/StandaloneTests.cs b/src/Umbraco.Tests/Runtimes/StandaloneTests.cs
index 64b45d41bf..6e35aca30d 100644
--- a/src/Umbraco.Tests/Runtimes/StandaloneTests.cs
+++ b/src/Umbraco.Tests/Runtimes/StandaloneTests.cs
@@ -71,6 +71,7 @@ namespace Umbraco.Tests.Runtimes
var backOfficeInfo = TestHelper.GetBackOfficeInfo();
var runtimeState = new RuntimeState(logger, null, null, new Lazy(() => mainDom), new Lazy(() => factory.GetInstance()), umbracoVersion, hostingEnvironment, backOfficeInfo);
var configs = TestHelper.GetConfigs();
+ var variationContextAccessor = TestHelper.VariationContextAccessor;
// create the register and the composition
var register = TestHelper.GetRegister();
@@ -103,7 +104,7 @@ namespace Umbraco.Tests.Runtimes
composition.Register(Lifetime.Singleton);
composition.Register(Lifetime.Singleton);
composition.Register(_ => Mock.Of(), Lifetime.Singleton);
- composition.RegisterUnique(f => new DistributedCache());
+ composition.RegisterUnique(f => new DistributedCache(f.GetInstance(), f.GetInstance()));
composition.WithCollectionBuilder().Append();
composition.RegisterUnique();
composition.RegisterUnique(f => ExamineManager.Instance);
@@ -203,7 +204,7 @@ namespace Umbraco.Tests.Runtimes
// but a draft document
pcontent = umbracoContext.Content.GetById(true, content.Id);
Assert.IsNotNull(pcontent);
- Assert.AreEqual("test", pcontent.Name());
+ Assert.AreEqual("test", pcontent.Name(variationContextAccessor));
Assert.IsTrue(pcontent.IsDraft());
// no published url
@@ -217,7 +218,7 @@ namespace Umbraco.Tests.Runtimes
// assert that snapshot has been updated and there is now a published document
pcontent = umbracoContext.Content.GetById(content.Id);
Assert.IsNotNull(pcontent);
- Assert.AreEqual("test", pcontent.Name());
+ Assert.AreEqual("test", pcontent.Name(variationContextAccessor));
Assert.IsFalse(pcontent.IsDraft());
// but the url is the published one - no draft url
@@ -226,7 +227,7 @@ namespace Umbraco.Tests.Runtimes
// and also an updated draft document
pcontent = umbracoContext.Content.GetById(true, content.Id);
Assert.IsNotNull(pcontent);
- Assert.AreEqual("testx", pcontent.Name());
+ Assert.AreEqual("testx", pcontent.Name(variationContextAccessor));
Assert.IsTrue(pcontent.IsDraft());
// and the published document has a url
diff --git a/src/Umbraco.Tests/Scoping/ScopeFileSystemsTests.cs b/src/Umbraco.Tests/Scoping/ScopeFileSystemsTests.cs
index 1ed1eac663..6b16f49d7d 100644
--- a/src/Umbraco.Tests/Scoping/ScopeFileSystemsTests.cs
+++ b/src/Umbraco.Tests/Scoping/ScopeFileSystemsTests.cs
@@ -4,7 +4,7 @@ using System.Text;
using Moq;
using NUnit.Framework;
using Umbraco.Core;
-using Umbraco.Core.Composing;
+using Umbraco.Web.Composing;
using Umbraco.Core.IO;
using Umbraco.Tests.TestHelpers;
using Umbraco.Tests.Testing;
diff --git a/src/Umbraco.Tests/Scoping/ScopedNuCacheTests.cs b/src/Umbraco.Tests/Scoping/ScopedNuCacheTests.cs
index 22afd913fb..366f7ce64a 100644
--- a/src/Umbraco.Tests/Scoping/ScopedNuCacheTests.cs
+++ b/src/Umbraco.Tests/Scoping/ScopedNuCacheTests.cs
@@ -29,6 +29,7 @@ using Umbraco.Web.PublishedCache.NuCache;
using Umbraco.Web.PublishedCache.NuCache.DataSource;
using Umbraco.Web.Routing;
using Umbraco.Web.Security;
+using Current = Umbraco.Web.Composing.Current;
namespace Umbraco.Tests.Scoping
{
@@ -139,7 +140,7 @@ namespace Umbraco.Tests.Scoping
var umbracoContext = GetUmbracoContextNu("http://example.com/", setSingleton: true);
// wire cache refresher
- _distributedCacheBinder = new DistributedCacheBinder(new DistributedCache(), Mock.Of(), Mock.Of());
+ _distributedCacheBinder = new DistributedCacheBinder(new DistributedCache(Current.ServerMessenger, Current.CacheRefreshers), Mock.Of(), Mock.Of());
_distributedCacheBinder.BindEvents(true);
// create document type, document
@@ -157,7 +158,7 @@ namespace Umbraco.Tests.Scoping
// during events, due to LiveSnapshot, we see the changes
Assert.IsNotNull(e);
- Assert.AreEqual("changed", e.Name());
+ Assert.AreEqual("changed", e.Name(VariationContextAccessor));
};
using (var scope = ScopeProvider.CreateScope())
@@ -169,7 +170,7 @@ namespace Umbraco.Tests.Scoping
// been created
var x = umbracoContext.Content.GetById(item.Id);
Assert.IsNotNull(x);
- Assert.AreEqual("name", x.Name());
+ Assert.AreEqual("name", x.Name(VariationContextAccessor));
ContentService.Published += OnPublishedAssert;
@@ -191,7 +192,7 @@ namespace Umbraco.Tests.Scoping
// else changes have been rolled back
x = umbracoContext.Content.GetById(item.Id);
Assert.IsNotNull(x);
- Assert.AreEqual(complete ? "changed" : "name", x.Name());
+ Assert.AreEqual(complete ? "changed" : "name", x.Name(VariationContextAccessor));
}
}
}
diff --git a/src/Umbraco.Tests/Scoping/ScopedRepositoryTests.cs b/src/Umbraco.Tests/Scoping/ScopedRepositoryTests.cs
index 7b3f9cbe70..7a0b2082b3 100644
--- a/src/Umbraco.Tests/Scoping/ScopedRepositoryTests.cs
+++ b/src/Umbraco.Tests/Scoping/ScopedRepositoryTests.cs
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using Umbraco.Core.Cache;
-using Umbraco.Core.Composing;
+using Umbraco.Web.Composing;
using Umbraco.Core.Models;
using Umbraco.Core.Models.Membership;
using Umbraco.Core.Scoping;
@@ -75,7 +75,7 @@ namespace Umbraco.Tests.Scoping
// get user again - else we'd modify the one that's in the cache
user = service.GetUserById(user.Id);
- _distributedCacheBinder = new DistributedCacheBinder(new DistributedCache(), Mock.Of(), Mock.Of());
+ _distributedCacheBinder = new DistributedCacheBinder(new DistributedCache(Current.ServerMessenger, Current.CacheRefreshers), Mock.Of(), Mock.Of());
_distributedCacheBinder.BindEvents(true);
Assert.IsNull(scopeProvider.AmbientScope);
@@ -156,7 +156,7 @@ namespace Umbraco.Tests.Scoping
Assert.AreEqual(lang.Id, globalCached.Id);
Assert.AreEqual("fr-FR", globalCached.IsoCode);
- _distributedCacheBinder = new DistributedCacheBinder(new DistributedCache(), Mock.Of(), Mock.Of());
+ _distributedCacheBinder = new DistributedCacheBinder(new DistributedCache(Current.ServerMessenger, Current.CacheRefreshers), Mock.Of(), Mock.Of());
_distributedCacheBinder.BindEvents(true);
Assert.IsNull(scopeProvider.AmbientScope);
@@ -248,7 +248,7 @@ namespace Umbraco.Tests.Scoping
Assert.AreEqual(item.Id, globalCached.Id);
Assert.AreEqual("item-key", globalCached.ItemKey);
- _distributedCacheBinder = new DistributedCacheBinder(new DistributedCache(), Mock.Of(), Mock.Of());
+ _distributedCacheBinder = new DistributedCacheBinder(new DistributedCache(Current.ServerMessenger, Current.CacheRefreshers), Mock.Of(), Mock.Of());
_distributedCacheBinder.BindEvents(true);
Assert.IsNull(scopeProvider.AmbientScope);
diff --git a/src/Umbraco.Tests/Scoping/ScopedXmlTests.cs b/src/Umbraco.Tests/Scoping/ScopedXmlTests.cs
index d57845ec10..24b41d3322 100644
--- a/src/Umbraco.Tests/Scoping/ScopedXmlTests.cs
+++ b/src/Umbraco.Tests/Scoping/ScopedXmlTests.cs
@@ -5,7 +5,7 @@ using Moq;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Cache;
-using Umbraco.Core.Composing;
+using Umbraco.Web.Composing;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.Events;
using Umbraco.Core.Logging;
@@ -93,7 +93,7 @@ namespace Umbraco.Tests.Scoping
var item = new Content("name", -1, contentType);
// wire cache refresher
- _distributedCacheBinder = new DistributedCacheBinder(new DistributedCache(), Mock.Of(), Mock.Of());
+ _distributedCacheBinder = new DistributedCacheBinder(new DistributedCache(Current.ServerMessenger, Current.CacheRefreshers), Mock.Of(), Mock.Of());
_distributedCacheBinder.BindEvents(true);
// check xml in context = "before"
@@ -206,7 +206,7 @@ namespace Umbraco.Tests.Scoping
Current.Services.ContentTypeService.Save(contentType);
// wire cache refresher
- _distributedCacheBinder = new DistributedCacheBinder(new DistributedCache(), Mock.Of(), Mock.Of());
+ _distributedCacheBinder = new DistributedCacheBinder(new DistributedCache(Current.ServerMessenger, Current.CacheRefreshers), Mock.Of(), Mock.Of());
_distributedCacheBinder.BindEvents(true);
// check xml in context = "before"
diff --git a/src/Umbraco.Tests/Services/MemberServiceTests.cs b/src/Umbraco.Tests/Services/MemberServiceTests.cs
index 510ca99b7a..e95d3a6f60 100644
--- a/src/Umbraco.Tests/Services/MemberServiceTests.cs
+++ b/src/Umbraco.Tests/Services/MemberServiceTests.cs
@@ -2,12 +2,9 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading;
-using System.Web.Security;
-using Moq;
using NUnit.Framework;
using Umbraco.Core;
-using Umbraco.Core.Composing;
-using Umbraco.Core.Events;
+using Umbraco.Web.Composing;
using Umbraco.Core.Models;
using Umbraco.Core.Models.Entities;
using Umbraco.Core.Models.Membership;
diff --git a/src/Umbraco.Tests/Services/PerformanceTests.cs b/src/Umbraco.Tests/Services/PerformanceTests.cs
index 0ac6eeb863..f42d61b5de 100644
--- a/src/Umbraco.Tests/Services/PerformanceTests.cs
+++ b/src/Umbraco.Tests/Services/PerformanceTests.cs
@@ -6,7 +6,7 @@ using System.Threading;
using NPoco;
using NUnit.Framework;
using Umbraco.Core;
-using Umbraco.Core.Composing;
+using Umbraco.Web.Composing;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
using Umbraco.Core.Persistence;
diff --git a/src/Umbraco.Tests/TestHelpers/TestHelper.cs b/src/Umbraco.Tests/TestHelpers/TestHelper.cs
index 64e7b7e040..b6b7658bfa 100644
--- a/src/Umbraco.Tests/TestHelpers/TestHelper.cs
+++ b/src/Umbraco.Tests/TestHelpers/TestHelper.cs
@@ -19,12 +19,14 @@ using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
using Umbraco.Core.Models.Entities;
+using Umbraco.Core.Models.PublishedContent;
using Umbraco.Core.Persistence;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Services;
using Umbraco.Core.Strings;
using Umbraco.Core.Sync;
using Umbraco.Net;
+using Umbraco.Tests.Testing.Objects.Accessors;
using Umbraco.Web;
using Umbraco.Web.Hosting;
using File = System.IO.File;
@@ -86,6 +88,7 @@ namespace Umbraco.Tests.TestHelpers
}
public static IShortStringHelper ShortStringHelper => new DefaultShortStringHelper(new DefaultShortStringHelperConfig());
+ public static IVariationContextAccessor VariationContextAccessor => new TestVariationContextAccessor();
public static IDbProviderFactoryCreator DbProviderFactoryCreator => new UmbracoDbProviderFactoryCreator(Constants.DbProviderNames.SqlCe);
public static IBulkSqlInsertProvider BulkSqlInsertProvider => new SqlCeBulkSqlInsertProvider();
public static IMarchal Marchal => new FrameworkMarchal();
diff --git a/src/Umbraco.Tests/TestHelpers/TestWithDatabaseBase.cs b/src/Umbraco.Tests/TestHelpers/TestWithDatabaseBase.cs
index d38dcfc888..76f9d53222 100644
--- a/src/Umbraco.Tests/TestHelpers/TestWithDatabaseBase.cs
+++ b/src/Umbraco.Tests/TestHelpers/TestWithDatabaseBase.cs
@@ -22,7 +22,7 @@ using Umbraco.Web.PublishedCache;
using Umbraco.Web.Security;
using Umbraco.Web.Routing;
using File = System.IO.File;
-using Umbraco.Core.Composing;
+using Umbraco.Web.Composing;
using Umbraco.Core.Persistence.Mappers;
using Umbraco.Core.Scoping;
using Umbraco.Tests.Testing;
@@ -55,6 +55,7 @@ namespace Umbraco.Tests.TestHelpers
protected override ISqlSyntaxProvider SqlSyntax => GetSyntaxProvider();
protected ServiceContext ServiceContext => Current.Services;
+ protected IVariationContextAccessor VariationContextAccessor => new TestVariationContextAccessor();
internal ScopeProvider ScopeProvider => Current.ScopeProvider as ScopeProvider;
diff --git a/src/Umbraco.Tests/Web/Controllers/AuthenticationControllerTests.cs b/src/Umbraco.Tests/Web/Controllers/AuthenticationControllerTests.cs
index e99d3eb165..1e0e592252 100644
--- a/src/Umbraco.Tests/Web/Controllers/AuthenticationControllerTests.cs
+++ b/src/Umbraco.Tests/Web/Controllers/AuthenticationControllerTests.cs
@@ -14,7 +14,7 @@ using Newtonsoft.Json;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Cache;
-using Umbraco.Core.Composing;
+using Umbraco.Web.Composing;
using Umbraco.Core.Configuration;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
diff --git a/src/Umbraco.Tests/Web/Controllers/UsersControllerTests.cs b/src/Umbraco.Tests/Web/Controllers/UsersControllerTests.cs
index bfd1f10233..e36d2bdb12 100644
--- a/src/Umbraco.Tests/Web/Controllers/UsersControllerTests.cs
+++ b/src/Umbraco.Tests/Web/Controllers/UsersControllerTests.cs
@@ -12,7 +12,7 @@ using Newtonsoft.Json;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Cache;
-using Umbraco.Core.Composing;
+using Umbraco.Web.Composing;
using Umbraco.Core.Configuration;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
diff --git a/src/Umbraco.Tests/Web/Mvc/UmbracoViewPageTests.cs b/src/Umbraco.Tests/Web/Mvc/UmbracoViewPageTests.cs
index 50d18bb52a..adc0cbe770 100644
--- a/src/Umbraco.Tests/Web/Mvc/UmbracoViewPageTests.cs
+++ b/src/Umbraco.Tests/Web/Mvc/UmbracoViewPageTests.cs
@@ -7,7 +7,7 @@ using Moq;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Cache;
-using Umbraco.Core.Composing;
+using Umbraco.Web.Composing;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.Logging;
using Umbraco.Core.Models.PublishedContent;
diff --git a/src/Umbraco.Tests/Web/Mvc/ValidateUmbracoFormRouteStringAttributeTests.cs b/src/Umbraco.Tests/Web/Mvc/ValidateUmbracoFormRouteStringAttributeTests.cs
index d4c3b7c887..9d9c965440 100644
--- a/src/Umbraco.Tests/Web/Mvc/ValidateUmbracoFormRouteStringAttributeTests.cs
+++ b/src/Umbraco.Tests/Web/Mvc/ValidateUmbracoFormRouteStringAttributeTests.cs
@@ -1,4 +1,5 @@
using NUnit.Framework;
+using Umbraco.Composing;
using Umbraco.Web;
using Umbraco.Web.Mvc;
diff --git a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/Gallery.cshtml b/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/Gallery.cshtml
index 5aa09a3cb3..fa86862c9a 100755
--- a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/Gallery.cshtml
+++ b/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/Gallery.cshtml
@@ -1,6 +1,7 @@
@using Umbraco.Core.Models.PublishedContent
@using Umbraco.Web
@using Umbraco.Core
+@using Umbraco.Web.Composing
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@*
@@ -33,7 +34,7 @@
}
@* a folder with images under it *@
- foreach (var image in media.Children())
+ foreach (var image in media.Children(Current.VariationContextAccessor))
{
@Render(image);
}
diff --git a/src/Umbraco.Web/Cache/DistributedCache.cs b/src/Umbraco.Web/Cache/DistributedCache.cs
index 1e0e33ebd7..d77c3c056b 100644
--- a/src/Umbraco.Web/Cache/DistributedCache.cs
+++ b/src/Umbraco.Web/Cache/DistributedCache.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using Umbraco.Core;
using Umbraco.Core.Cache;
+using Umbraco.Core.Sync;
using Umbraco.Web.Composing;
namespace Umbraco.Web.Cache
@@ -21,6 +22,15 @@ namespace Umbraco.Web.Cache
///
public sealed class DistributedCache
{
+ private readonly IServerMessenger _serverMessenger;
+ private readonly CacheRefresherCollection _cacheRefreshers;
+
+ public DistributedCache(IServerMessenger serverMessenger, CacheRefresherCollection cacheRefreshers)
+ {
+ _serverMessenger = serverMessenger;
+ _cacheRefreshers = cacheRefreshers;
+ }
+
#region Core notification methods
///
@@ -37,7 +47,7 @@ namespace Umbraco.Web.Cache
{
if (refresherGuid == Guid.Empty || instances.Length == 0 || getNumericId == null) return;
- Current.ServerMessenger.PerformRefresh(
+ _serverMessenger.PerformRefresh(
GetRefresherById(refresherGuid),
getNumericId,
instances);
@@ -52,7 +62,7 @@ namespace Umbraco.Web.Cache
{
if (refresherGuid == Guid.Empty || id == default(int)) return;
- Current.ServerMessenger.PerformRefresh(
+ _serverMessenger.PerformRefresh(
GetRefresherById(refresherGuid),
id);
}
@@ -66,7 +76,7 @@ namespace Umbraco.Web.Cache
{
if (refresherGuid == Guid.Empty || id == Guid.Empty) return;
- Current.ServerMessenger.PerformRefresh(
+ _serverMessenger.PerformRefresh(
GetRefresherById(refresherGuid),
id);
}
@@ -77,7 +87,7 @@ namespace Umbraco.Web.Cache
{
if (refresherGuid == Guid.Empty || payload == null) return;
- Current.ServerMessenger.PerformRefresh(
+ _serverMessenger.PerformRefresh(
GetRefresherById(refresherGuid),
payload);
}
@@ -88,7 +98,7 @@ namespace Umbraco.Web.Cache
{
if (refresherGuid == Guid.Empty || payloads == null) return;
- Current.ServerMessenger.PerformRefresh(
+ _serverMessenger.PerformRefresh(
GetRefresherById(refresherGuid),
payloads.ToArray());
}
@@ -101,7 +111,7 @@ namespace Umbraco.Web.Cache
{
if (refresherGuid == Guid.Empty || jsonPayload.IsNullOrWhiteSpace()) return;
- Current.ServerMessenger.PerformRefresh(
+ _serverMessenger.PerformRefresh(
GetRefresherById(refresherGuid),
jsonPayload);
}
@@ -115,7 +125,7 @@ namespace Umbraco.Web.Cache
//{
// if (refresherId == Guid.Empty || payload == null) return;
- // Current.ServerMessenger.Notify(
+ // _serverMessenger.Notify(
// Current.ServerRegistrar.Registrations,
// GetRefresherById(refresherId),
// json);
@@ -129,7 +139,7 @@ namespace Umbraco.Web.Cache
{
if (refresherGuid == Guid.Empty) return;
- Current.ServerMessenger.PerformRefreshAll(
+ _serverMessenger.PerformRefreshAll(
GetRefresherById(refresherGuid));
}
@@ -142,7 +152,7 @@ namespace Umbraco.Web.Cache
{
if (refresherGuid == Guid.Empty || id == default(int)) return;
- Current.ServerMessenger.PerformRemove(
+ _serverMessenger.PerformRemove(
GetRefresherById(refresherGuid),
id);
}
@@ -159,7 +169,7 @@ namespace Umbraco.Web.Cache
///
public void Remove(Guid refresherGuid, Func getNumericId, params T[] instances)
{
- Current.ServerMessenger.PerformRemove(
+ _serverMessenger.PerformRemove(
GetRefresherById(refresherGuid),
getNumericId,
instances);
@@ -168,9 +178,9 @@ namespace Umbraco.Web.Cache
#endregion
// helper method to get an ICacheRefresher by its unique identifier
- private static ICacheRefresher GetRefresherById(Guid refresherGuid)
+ private ICacheRefresher GetRefresherById(Guid refresherGuid)
{
- return Current.CacheRefreshers[refresherGuid];
+ return _cacheRefreshers[refresherGuid];
}
}
}
diff --git a/src/Umbraco.Web/Composing/Current.cs b/src/Umbraco.Web/Composing/Current.cs
index 1a90f68898..6a208d88bc 100644
--- a/src/Umbraco.Web/Composing/Current.cs
+++ b/src/Umbraco.Web/Composing/Current.cs
@@ -168,68 +168,70 @@ namespace Umbraco.Web.Composing
// proxy Core for convenience
- public static UmbracoMapper Mapper => CoreCurrent.Mapper;
+ public static IMediaFileSystem MediaFileSystem => Factory.GetInstance();
- public static IRuntimeState RuntimeState => CoreCurrent.RuntimeState;
+ public static UmbracoMapper Mapper => Factory.GetInstance();
- public static TypeLoader TypeLoader => CoreCurrent.TypeLoader;
+ public static IRuntimeState RuntimeState => Factory.GetInstance();
- public static Configs Configs => CoreCurrent.Configs;
+ public static TypeLoader TypeLoader => Factory.GetInstance();
- public static UrlSegmentProviderCollection UrlSegmentProviders => CoreCurrent.UrlSegmentProviders;
+ public static Configs Configs => Factory.GetInstance();
- public static CacheRefresherCollection CacheRefreshers => CoreCurrent.CacheRefreshers;
+ public static UrlSegmentProviderCollection UrlSegmentProviders => Factory.GetInstance();
- public static DataEditorCollection DataEditors => CoreCurrent.DataEditors;
+ public static CacheRefresherCollection CacheRefreshers => Factory.GetInstance();
- public static DataValueReferenceFactoryCollection DataValueReferenceFactories => CoreCurrent.DataValueReferenceFactories;
+ public static DataEditorCollection DataEditors => Factory.GetInstance();
- public static PropertyEditorCollection PropertyEditors => CoreCurrent.PropertyEditors;
+ public static DataValueReferenceFactoryCollection DataValueReferenceFactories => Factory.GetInstance();
- public static ParameterEditorCollection ParameterEditors => CoreCurrent.ParameterEditors;
+ public static PropertyEditorCollection PropertyEditors => Factory.GetInstance();
- internal static ManifestValueValidatorCollection ManifestValidators => CoreCurrent.ManifestValidators;
+ public static ParameterEditorCollection ParameterEditors => Factory.GetInstance();
- internal static IPackageActionRunner PackageActionRunner => CoreCurrent.PackageActionRunner;
+ internal static ManifestValueValidatorCollection ManifestValidators => Factory.GetInstance();
- internal static PackageActionCollection PackageActions => CoreCurrent.PackageActions;
+ internal static IPackageActionRunner PackageActionRunner => Factory.GetInstance();
- internal static PropertyValueConverterCollection PropertyValueConverters => CoreCurrent.PropertyValueConverters;
+ internal static PackageActionCollection PackageActions => Factory.GetInstance();
- internal static IPublishedModelFactory PublishedModelFactory => CoreCurrent.PublishedModelFactory;
+ internal static PropertyValueConverterCollection PropertyValueConverters => Factory.GetInstance();
- public static IServerMessenger ServerMessenger => CoreCurrent.ServerMessenger;
+ internal static IPublishedModelFactory PublishedModelFactory => Factory.GetInstance();
- public static IServerRegistrar ServerRegistrar => CoreCurrent.ServerRegistrar;
+ public static IServerMessenger ServerMessenger => Factory.GetInstance();
- public static ICultureDictionaryFactory CultureDictionaryFactory => CoreCurrent.CultureDictionaryFactory;
+ public static IServerRegistrar ServerRegistrar => Factory.GetInstance();
- public static IShortStringHelper ShortStringHelper => CoreCurrent.ShortStringHelper;
+ public static ICultureDictionaryFactory CultureDictionaryFactory => Factory.GetInstance();
- public static ILogger Logger => CoreCurrent.Logger;
+ public static IShortStringHelper ShortStringHelper => Factory.GetInstance();
- public static IProfiler Profiler => CoreCurrent.Profiler;
+ public static ILogger Logger => Umbraco.Composing.Current.Logger;
- public static IProfilingLogger ProfilingLogger => CoreCurrent.ProfilingLogger;
+ public static IProfiler Profiler => Factory.GetInstance();
- public static AppCaches AppCaches => CoreCurrent.AppCaches;
+ public static IProfilingLogger ProfilingLogger => Factory.GetInstance();
- public static ServiceContext Services => CoreCurrent.Services;
+ public static AppCaches AppCaches => Factory.GetInstance();
- public static IScopeProvider ScopeProvider => CoreCurrent.ScopeProvider;
+ public static ServiceContext Services => Factory.GetInstance();
- public static IFileSystems FileSystems => CoreCurrent.FileSystems;
+ public static IScopeProvider ScopeProvider => Factory.GetInstance();
- public static ISqlContext SqlContext=> CoreCurrent.SqlContext;
+ public static IFileSystems FileSystems => Factory.GetInstance();
- public static IPublishedContentTypeFactory PublishedContentTypeFactory => CoreCurrent.PublishedContentTypeFactory;
+ public static ISqlContext SqlContext=> Factory.GetInstance();
- public static IPublishedValueFallback PublishedValueFallback => CoreCurrent.PublishedValueFallback;
+ public static IPublishedContentTypeFactory PublishedContentTypeFactory => Factory.GetInstance();
- public static IVariationContextAccessor VariationContextAccessor => CoreCurrent.VariationContextAccessor;
+ public static IPublishedValueFallback PublishedValueFallback => Factory.GetInstance();
- public static IIOHelper IOHelper => CoreCurrent.IOHelper;
- public static IHostingEnvironment HostingEnvironment => CoreCurrent.HostingEnvironment;
+ public static IVariationContextAccessor VariationContextAccessor => Factory.GetInstance();
+
+ public static IIOHelper IOHelper => Factory.GetInstance();
+ public static IHostingEnvironment HostingEnvironment => Factory.GetInstance();
public static IIpResolver IpResolver => Factory.GetInstance();
public static IUmbracoVersion UmbracoVersion => Factory.GetInstance();
diff --git a/src/Umbraco.Web/Editors/DataTypeValidateAttribute.cs b/src/Umbraco.Web/Editors/DataTypeValidateAttribute.cs
index 1337545ee0..efdcf93fff 100644
--- a/src/Umbraco.Web/Editors/DataTypeValidateAttribute.cs
+++ b/src/Umbraco.Web/Editors/DataTypeValidateAttribute.cs
@@ -5,7 +5,7 @@ using System.Net.Http;
using System.Web.Http.Controllers;
using System.Web.Http.Filters;
using Umbraco.Core;
-using Umbraco.Core.Composing;
+using Umbraco.Web.Composing;
using Umbraco.Core.Models;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Services;
diff --git a/src/Umbraco.Web/Editors/Filters/UserGroupValidateAttribute.cs b/src/Umbraco.Web/Editors/Filters/UserGroupValidateAttribute.cs
index 78cd8e6a4d..f17eddd44b 100644
--- a/src/Umbraco.Web/Editors/Filters/UserGroupValidateAttribute.cs
+++ b/src/Umbraco.Web/Editors/Filters/UserGroupValidateAttribute.cs
@@ -5,7 +5,7 @@ using System.Web.Http.Controllers;
using System.Web.Http.Filters;
using Umbraco.Core;
using Umbraco.Core.Mapping;
-using Umbraco.Core.Composing;
+using Umbraco.Web.Composing;
using Umbraco.Core.Models.Membership;
using Umbraco.Core.Services;
using Umbraco.Web.Models.ContentEditing;
diff --git a/src/Umbraco.Web/Editors/TemplateQueryController.cs b/src/Umbraco.Web/Editors/TemplateQueryController.cs
index ed737e7749..8148d24887 100644
--- a/src/Umbraco.Web/Editors/TemplateQueryController.cs
+++ b/src/Umbraco.Web/Editors/TemplateQueryController.cs
@@ -4,7 +4,11 @@ using System.Diagnostics;
using System.Linq;
using System.Text;
using Umbraco.Core;
+using Umbraco.Core.Cache;
+using Umbraco.Core.Configuration;
+using Umbraco.Core.Logging;
using Umbraco.Core.Models.PublishedContent;
+using Umbraco.Core.Persistence;
using Umbraco.Core.Services;
using Umbraco.Web.Models.TemplateQuery;
using Umbraco.Web.Mvc;
@@ -19,6 +23,23 @@ namespace Umbraco.Web.Editors
[JsonCamelCaseFormatter]
public class TemplateQueryController : UmbracoAuthorizedJsonController
{
+ private readonly IVariationContextAccessor _variationContextAccessor;
+
+ public TemplateQueryController(
+ IGlobalSettings globalSettings,
+ IUmbracoContextAccessor umbracoContextAccessor,
+ ISqlContext sqlContext,
+ ServiceContext services,
+ AppCaches appCaches,
+ IProfilingLogger logger,
+ IRuntimeState runtimeState,
+ UmbracoHelper umbracoHelper,
+ IVariationContextAccessor variationContextAccessor)
+ : base(globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoHelper)
+ {
+ _variationContextAccessor = variationContextAccessor;
+ }
+
private IEnumerable Terms => new List
{
new OperatorTerm(Services.TextService.Localize("template/is"), Operator.Equals, new [] {"string"}),
@@ -52,7 +73,7 @@ namespace Umbraco.Web.Editors
if (model == null)
{
- contents = Umbraco.ContentAtRoot().FirstOrDefault().Children();
+ contents = Umbraco.ContentAtRoot().FirstOrDefault().Children(_variationContextAccessor);
queryExpression.Append("Umbraco.ContentAtRoot().FirstOrDefault().Children()");
}
else
@@ -110,7 +131,7 @@ namespace Umbraco.Web.Editors
{
contents = sourceDocument == null
? Enumerable.Empty()
- : sourceDocument.Children();
+ : sourceDocument.Children(_variationContextAccessor);
queryExpression.Append(".Children()");
}
diff --git a/src/Umbraco.Web/Editors/UsersController.cs b/src/Umbraco.Web/Editors/UsersController.cs
index 64c8417893..a0616cbd4d 100644
--- a/src/Umbraco.Web/Editors/UsersController.cs
+++ b/src/Umbraco.Web/Editors/UsersController.cs
@@ -13,7 +13,7 @@ using System.Web.Mvc;
using Microsoft.AspNet.Identity;
using Umbraco.Core;
using Umbraco.Core.Cache;
-using Umbraco.Core.Composing;
+using Umbraco.Web.Composing;
using Umbraco.Core.Configuration;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
diff --git a/src/Umbraco.Web/HtmlHelperBackOfficeExtensions.cs b/src/Umbraco.Web/HtmlHelperBackOfficeExtensions.cs
index d9c2e2b881..c56cbb983c 100644
--- a/src/Umbraco.Web/HtmlHelperBackOfficeExtensions.cs
+++ b/src/Umbraco.Web/HtmlHelperBackOfficeExtensions.cs
@@ -5,7 +5,7 @@ using System.Web;
using System.Web.Mvc;
using Microsoft.Owin.Security;
using Newtonsoft.Json;
-using Umbraco.Core.Composing;
+using Umbraco.Web.Composing;
using Umbraco.Web.Editors;
using Umbraco.Web.Features;
using Umbraco.Web.Models;
diff --git a/src/Umbraco.Web/ImageCropperTemplateExtensions.cs b/src/Umbraco.Web/ImageCropperTemplateExtensions.cs
index 656f1e05a2..440083a11f 100644
--- a/src/Umbraco.Web/ImageCropperTemplateExtensions.cs
+++ b/src/Umbraco.Web/ImageCropperTemplateExtensions.cs
@@ -4,7 +4,7 @@ using System.Globalization;
using System.Text;
using Newtonsoft.Json;
using Umbraco.Core;
-using Umbraco.Core.Composing;
+using Umbraco.Web.Composing;
using Umbraco.Core.Models;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Core.PropertyEditors.ValueConverters;
diff --git a/src/Umbraco.Web/Install/InstallSteps/UpgradeStep.cs b/src/Umbraco.Web/Install/InstallSteps/UpgradeStep.cs
index a844da87b4..a59d7394f0 100644
--- a/src/Umbraco.Web/Install/InstallSteps/UpgradeStep.cs
+++ b/src/Umbraco.Web/Install/InstallSteps/UpgradeStep.cs
@@ -1,6 +1,6 @@
using System;
using System.Threading.Tasks;
-using Umbraco.Core.Composing;
+using Umbraco.Web.Composing;
using Umbraco.Core.Configuration;
using Umbraco.Web.Install.Models;
diff --git a/src/Umbraco.Web/Models/Mapping/ContentMapDefinition.cs b/src/Umbraco.Web/Models/Mapping/ContentMapDefinition.cs
index fd76ce4943..24afd68a87 100644
--- a/src/Umbraco.Web/Models/Mapping/ContentMapDefinition.cs
+++ b/src/Umbraco.Web/Models/Mapping/ContentMapDefinition.cs
@@ -6,6 +6,7 @@ using Umbraco.Core.Dictionary;
using Umbraco.Core.Logging;
using Umbraco.Core.Mapping;
using Umbraco.Core.Models;
+using Umbraco.Core.Models.PublishedContent;
using Umbraco.Core.Services;
using Umbraco.Web.Models.ContentEditing;
using Umbraco.Web.Routing;
@@ -29,6 +30,7 @@ namespace Umbraco.Web.Models.Mapping
private readonly ILocalizationService _localizationService;
private readonly ILogger _logger;
private readonly IUserService _userService;
+ private readonly IVariationContextAccessor _variationContextAccessor;
private readonly TabsAndPropertiesMapper _tabsAndPropertiesMapper;
private readonly ContentSavedStateMapper _stateMapper;
private readonly ContentBasicSavedStateMapper _basicStateMapper;
@@ -36,7 +38,7 @@ namespace Umbraco.Web.Models.Mapping
public ContentMapDefinition(CommonMapper commonMapper, ICultureDictionary cultureDictionary, ILocalizedTextService localizedTextService, IContentService contentService, IContentTypeService contentTypeService,
IFileService fileService, IUmbracoContextAccessor umbracoContextAccessor, IPublishedRouter publishedRouter, ILocalizationService localizationService, ILogger logger,
- IUserService userService)
+ IUserService userService, IVariationContextAccessor variationContextAccessor)
{
_commonMapper = commonMapper;
_cultureDictionary = cultureDictionary;
@@ -49,6 +51,7 @@ namespace Umbraco.Web.Models.Mapping
_localizationService = localizationService;
_logger = logger;
_userService = userService;
+ _variationContextAccessor = variationContextAccessor;
_tabsAndPropertiesMapper = new TabsAndPropertiesMapper(cultureDictionary, localizedTextService);
_stateMapper = new ContentSavedStateMapper();
@@ -174,7 +177,7 @@ namespace Umbraco.Web.Models.Mapping
var urls = umbracoContext == null
? new[] { UrlInfo.Message("Cannot generate urls without a current Umbraco Context") }
- : source.GetContentUrls(_publishedRouter, umbracoContext, _localizationService, _localizedTextService, _contentService, _logger).ToArray();
+ : source.GetContentUrls(_publishedRouter, umbracoContext, _localizationService, _localizedTextService, _contentService, _variationContextAccessor, _logger).ToArray();
return urls;
}
diff --git a/src/Umbraco.Web/Models/Mapping/MemberTabsAndPropertiesMapper.cs b/src/Umbraco.Web/Models/Mapping/MemberTabsAndPropertiesMapper.cs
index 616ad81fa4..8d00fd911d 100644
--- a/src/Umbraco.Web/Models/Mapping/MemberTabsAndPropertiesMapper.cs
+++ b/src/Umbraco.Web/Models/Mapping/MemberTabsAndPropertiesMapper.cs
@@ -3,13 +3,11 @@ using System.Collections.Generic;
using System.Linq;
using Umbraco.Core;
using Umbraco.Core.Mapping;
-using Umbraco.Core.Composing;
+using Umbraco.Web.Composing;
using Umbraco.Core.Models;
using Umbraco.Core.Services;
using Umbraco.Web.Models.ContentEditing;
using Umbraco.Core.Dictionary;
-using Umbraco.Web.Security;
-using Umbraco.Web.Security.Providers;
using Umbraco.Core.Configuration;
namespace Umbraco.Web.Models.Mapping
@@ -125,10 +123,10 @@ namespace Umbraco.Web.Models.Mapping
{
Alias = $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}password",
Label = _localizedTextService.Localize("password"),
-
+
Value = new Dictionary
{
- // TODO: why ignoreCase, what are we doing here?!
+ // TODO: why ignoreCase, what are we doing here?!
{"newPassword", member.GetAdditionalDataValueIgnoreCase("NewPassword", null)},
},
// TODO: Hard coding this because the changepassword doesn't necessarily need to be a resolvable (real) property editor
diff --git a/src/Umbraco.Web/Models/PublishedContentBase.cs b/src/Umbraco.Web/Models/PublishedContentBase.cs
index 148bab11c0..23fef7959e 100644
--- a/src/Umbraco.Web/Models/PublishedContentBase.cs
+++ b/src/Umbraco.Web/Models/PublishedContentBase.cs
@@ -14,6 +14,13 @@ namespace Umbraco.Web.Models
[DebuggerDisplay("Content Id: {Id}")]
public abstract class PublishedContentBase : IPublishedContent
{
+ private readonly IVariationContextAccessor _variationContextAccessor;
+
+ protected PublishedContentBase(IVariationContextAccessor variationContextAccessor)
+ {
+ _variationContextAccessor = variationContextAccessor;
+ }
+
#region ContentType
public abstract IPublishedContentType ContentType { get; }
@@ -33,10 +40,10 @@ namespace Umbraco.Web.Models
public abstract int Id { get; }
///
- public virtual string Name => this.Name();
+ public virtual string Name => this.Name(_variationContextAccessor);
///
- public virtual string UrlSegment => this.UrlSegment();
+ public virtual string UrlSegment => this.UrlSegment(_variationContextAccessor);
///
public abstract int SortOrder { get; }
@@ -91,7 +98,7 @@ namespace Umbraco.Web.Models
public abstract IPublishedContent Parent { get; }
///
- public virtual IEnumerable Children => this.Children();
+ public virtual IEnumerable Children => this.Children(_variationContextAccessor);
///
public abstract IEnumerable ChildrenForAllCultures { get; }
diff --git a/src/Umbraco.Web/PublishedCache/NuCache/ContentCache.cs b/src/Umbraco.Web/PublishedCache/NuCache/ContentCache.cs
index 84edb9113c..dd5a76837e 100644
--- a/src/Umbraco.Web/PublishedCache/NuCache/ContentCache.cs
+++ b/src/Umbraco.Web/PublishedCache/NuCache/ContentCache.cs
@@ -104,8 +104,8 @@ namespace Umbraco.Web.PublishedCache.NuCache
// hideTopLevelNode = support legacy stuff, look for /*/path/to/node
// else normal, look for /path/to/node
content = hideTopLevelNode.Value
- ? GetAtRoot(preview).SelectMany(x => x.Children(culture)).FirstOrDefault(x => x.UrlSegment(culture) == parts[0])
- : GetAtRoot(preview).FirstOrDefault(x => x.UrlSegment(culture) == parts[0]);
+ ? GetAtRoot(preview).SelectMany(x => x.Children(_variationContextAccessor, culture)).FirstOrDefault(x => x.UrlSegment(_variationContextAccessor, culture) == parts[0])
+ : GetAtRoot(preview).FirstOrDefault(x => x.UrlSegment(_variationContextAccessor, culture) == parts[0]);
content = FollowRoute(content, parts, 1, culture);
}
@@ -114,7 +114,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
// have to look for /foo (see note in ApplyHideTopLevelNodeFromPath).
if (content == null && hideTopLevelNode.Value && parts.Length == 1)
{
- content = GetAtRoot(preview).FirstOrDefault(x => x.UrlSegment(culture) == parts[0]);
+ content = GetAtRoot(preview).FirstOrDefault(x => x.UrlSegment(_variationContextAccessor, culture) == parts[0]);
}
return content;
@@ -144,7 +144,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
// or we reach the content root, collecting urls in the way
var pathParts = new List();
var n = node;
- var urlSegment = n.UrlSegment(culture);
+ var urlSegment = n.UrlSegment(_variationContextAccessor, culture);
var hasDomains = _domainCache.HasAssigned(n.Id);
while (hasDomains == false && n != null) // n is null at root
{
@@ -156,7 +156,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
// move to parent node
n = n.Parent;
if (n != null)
- urlSegment = n.UrlSegment(culture);
+ urlSegment = n.UrlSegment(_variationContextAccessor, culture);
hasDomains = n != null && _domainCache.HasAssigned(n.Id);
}
@@ -184,9 +184,9 @@ namespace Umbraco.Web.PublishedCache.NuCache
while (content != null && i < parts.Count)
{
var part = parts[i++];
- content = content.Children(culture).FirstOrDefault(x =>
+ content = content.Children(_variationContextAccessor, culture).FirstOrDefault(x =>
{
- var urlSegment = x.UrlSegment(culture);
+ var urlSegment = x.UrlSegment(_variationContextAccessor, culture);
return urlSegment == part;
});
}
diff --git a/src/Umbraco.Web/PublishedCache/NuCache/PublishedContent.cs b/src/Umbraco.Web/PublishedCache/NuCache/PublishedContent.cs
index 02cf88e74c..ac7b11a123 100644
--- a/src/Umbraco.Web/PublishedCache/NuCache/PublishedContent.cs
+++ b/src/Umbraco.Web/PublishedCache/NuCache/PublishedContent.cs
@@ -26,7 +26,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
ContentData contentData,
IPublishedSnapshotAccessor publishedSnapshotAccessor,
IVariationContextAccessor variationContextAccessor,
- IPublishedModelFactory publishedModelFactory)
+ IPublishedModelFactory publishedModelFactory) : base(variationContextAccessor)
{
_contentNode = contentNode ?? throw new ArgumentNullException(nameof(contentNode));
ContentData = contentData ?? throw new ArgumentNullException(nameof(contentData));
@@ -71,7 +71,11 @@ namespace Umbraco.Web.PublishedCache.NuCache
}
// used when cloning in ContentNode
- public PublishedContent(ContentNode contentNode, PublishedContent origin)
+ public PublishedContent(
+ ContentNode contentNode,
+ PublishedContent origin,
+ IVariationContextAccessor variationContextAccessor)
+ : base(variationContextAccessor)
{
_contentNode = contentNode;
_publishedSnapshotAccessor = origin._publishedSnapshotAccessor;
@@ -88,7 +92,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
}
// clone for previewing as draft a published content that is published and has no draft
- private PublishedContent(PublishedContent origin)
+ private PublishedContent(PublishedContent origin) : base(origin.VariationContextAccessor)
{
_publishedSnapshotAccessor = origin._publishedSnapshotAccessor;
VariationContextAccessor = origin.VariationContextAccessor;
diff --git a/src/Umbraco.Web/PublishedCache/PublishedMember.cs b/src/Umbraco.Web/PublishedCache/PublishedMember.cs
index ed8e3bd7cf..f4293b3dfb 100644
--- a/src/Umbraco.Web/PublishedCache/PublishedMember.cs
+++ b/src/Umbraco.Web/PublishedCache/PublishedMember.cs
@@ -24,7 +24,8 @@ namespace Umbraco.Web.PublishedCache
public PublishedMember(
IMember member,
IPublishedContentType publishedMemberType,
- IUserService userService)
+ IUserService userService,
+ IVariationContextAccessor variationContextAccessor) : base(variationContextAccessor)
{
_member = member ?? throw new ArgumentNullException(nameof(member));
_membershipUser = member;
diff --git a/src/Umbraco.Web/PublishedContentExtensions.cs b/src/Umbraco.Web/PublishedContentExtensions.cs
index 75eb6adbcb..0b8cc7ce74 100644
--- a/src/Umbraco.Web/PublishedContentExtensions.cs
+++ b/src/Umbraco.Web/PublishedContentExtensions.cs
@@ -27,6 +27,7 @@ namespace Umbraco.Web
private static IPublishedSnapshot PublishedSnapshot => Current.PublishedSnapshot;
private static UmbracoContext UmbracoContext => Current.UmbracoContext;
private static ISiteDomainHelper SiteDomainHelper => Current.Factory.GetInstance();
+ private static IVariationContextAccessor VariationContextAccessor => Current.VariationContextAccessor;
#region IsComposedOf
@@ -771,7 +772,7 @@ namespace Umbraco.Web
public static IPublishedContent Descendant(this IPublishedContent content, string culture = null)
{
- return content.Children(culture).FirstOrDefault();
+ return content.Children(VariationContextAccessor, culture).FirstOrDefault();
}
public static IPublishedContent Descendant(this IPublishedContent content, int level, string culture = null)
@@ -833,7 +834,7 @@ namespace Umbraco.Web
if (content == null) throw new ArgumentNullException(nameof(content));
if (orSelf) yield return content;
- foreach (var desc in content.Children(culture).SelectMany(x => x.EnumerateDescendants(culture)))
+ foreach (var desc in content.Children(VariationContextAccessor, culture).SelectMany(x => x.EnumerateDescendants(culture)))
yield return desc;
}
@@ -841,7 +842,7 @@ namespace Umbraco.Web
{
yield return content;
- foreach (var desc in content.Children(culture).SelectMany(x => x.EnumerateDescendants(culture)))
+ foreach (var desc in content.Children(VariationContextAccessor, culture).SelectMany(x => x.EnumerateDescendants(culture)))
yield return desc;
}
@@ -880,7 +881,7 @@ namespace Umbraco.Web
///
public static IEnumerable Children(this IPublishedContent content, Func predicate, string culture = null)
{
- return content.Children(culture).Where(predicate);
+ return content.Children(VariationContextAccessor, culture).Where(predicate);
}
///
@@ -908,12 +909,12 @@ namespace Umbraco.Web
public static IEnumerable Children(this IPublishedContent content, string culture = null)
where T : class, IPublishedContent
{
- return content.Children(culture).OfType();
+ return content.Children(VariationContextAccessor, culture).OfType();
}
public static IPublishedContent FirstChild(this IPublishedContent content, string culture = null)
{
- return content.Children(culture).FirstOrDefault();
+ return content.Children(VariationContextAccessor, culture).FirstOrDefault();
}
///
@@ -970,10 +971,10 @@ namespace Umbraco.Web
private static DataTable GenerateDataTable(IPublishedContent content, ServiceContext services, string contentTypeAliasFilter = "", string culture = null)
{
var firstNode = contentTypeAliasFilter.IsNullOrWhiteSpace()
- ? content.Children(culture).Any()
- ? content.Children(culture).ElementAt(0)
+ ? content.Children(VariationContextAccessor, culture).Any()
+ ? content.Children(VariationContextAccessor, culture).ElementAt(0)
: null
- : content.Children(culture).FirstOrDefault(x => x.ContentType.Alias.InvariantEquals(contentTypeAliasFilter));
+ : content.Children(VariationContextAccessor, culture).FirstOrDefault(x => x.ContentType.Alias.InvariantEquals(contentTypeAliasFilter));
if (firstNode == null)
return new DataTable(); //no children found
@@ -989,7 +990,7 @@ namespace Umbraco.Web
//create all row data
var tableData = Core.DataTableExtensions.CreateTableData();
//loop through each child and create row data for it
- foreach (var n in content.Children().OrderBy(x => x.SortOrder))
+ foreach (var n in content.Children(VariationContextAccessor).OrderBy(x => x.SortOrder))
{
if (contentTypeAliasFilter.IsNullOrWhiteSpace() == false)
{
@@ -1000,7 +1001,7 @@ namespace Umbraco.Web
var standardVals = new Dictionary
{
{ "Id", n.Id },
- { "NodeName", n.Name() },
+ { "NodeName", n.Name(VariationContextAccessor) },
{ "NodeTypeAlias", n.ContentType.Alias },
{ "CreateDate", n.CreateDate },
{ "UpdateDate", n.UpdateDate },
@@ -1082,8 +1083,8 @@ namespace Umbraco.Web
public static IEnumerable SiblingsAndSelf(this IPublishedContent content, string culture = null)
{
return content.Parent != null
- ? content.Parent.Children(culture)
- : PublishedSnapshot.Content.GetAtRoot().WhereIsInvariantOrHasCulture(culture);
+ ? content.Parent.Children(VariationContextAccessor, culture)
+ : PublishedSnapshot.Content.GetAtRoot().WhereIsInvariantOrHasCulture(VariationContextAccessor, culture);
}
///
@@ -1097,7 +1098,7 @@ namespace Umbraco.Web
{
return content.Parent != null
? content.Parent.ChildrenOfType(contentTypeAlias, culture)
- : PublishedSnapshot.Content.GetAtRoot().OfTypes(contentTypeAlias).WhereIsInvariantOrHasCulture(culture);
+ : PublishedSnapshot.Content.GetAtRoot().OfTypes(contentTypeAlias).WhereIsInvariantOrHasCulture(VariationContextAccessor, culture);
}
///
@@ -1112,7 +1113,7 @@ namespace Umbraco.Web
{
return content.Parent != null
? content.Parent.Children(culture)
- : PublishedSnapshot.Content.GetAtRoot().OfType().WhereIsInvariantOrHasCulture(culture);
+ : PublishedSnapshot.Content.GetAtRoot().OfType().WhereIsInvariantOrHasCulture(VariationContextAccessor, culture);
}
#endregion
diff --git a/src/Umbraco.Web/PublishedElementExtensions.cs b/src/Umbraco.Web/PublishedElementExtensions.cs
index f3bc27182f..982f5566f5 100644
--- a/src/Umbraco.Web/PublishedElementExtensions.cs
+++ b/src/Umbraco.Web/PublishedElementExtensions.cs
@@ -1,9 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using System.Web;
using Umbraco.Core;
-using Umbraco.Core.Composing;
+using Umbraco.Web.Composing;
using Umbraco.Core.Models.PublishedContent;
namespace Umbraco.Web
diff --git a/src/Umbraco.Web/PublishedPropertyExtension.cs b/src/Umbraco.Web/PublishedPropertyExtension.cs
index b431f24828..829b9ced43 100644
--- a/src/Umbraco.Web/PublishedPropertyExtension.cs
+++ b/src/Umbraco.Web/PublishedPropertyExtension.cs
@@ -1,6 +1,6 @@
using System.Collections.Generic;
using Umbraco.Core;
-using Umbraco.Core.Composing;
+using Umbraco.Web.Composing;
using Umbraco.Core.Models.PublishedContent;
namespace Umbraco.Web
diff --git a/src/Umbraco.Web/Routing/UrlProviderExtensions.cs b/src/Umbraco.Web/Routing/UrlProviderExtensions.cs
index 077680d2e2..9a0579daa1 100644
--- a/src/Umbraco.Web/Routing/UrlProviderExtensions.cs
+++ b/src/Umbraco.Web/Routing/UrlProviderExtensions.cs
@@ -5,6 +5,7 @@ using Umbraco.Core.Models;
using Umbraco.Core.Services;
using Umbraco.Core;
using Umbraco.Core.Logging;
+using Umbraco.Core.Models.PublishedContent;
namespace Umbraco.Web.Routing
{
@@ -23,6 +24,7 @@ namespace Umbraco.Web.Routing
ILocalizationService localizationService,
ILocalizedTextService textService,
IContentService contentService,
+ IVariationContextAccessor variationContextAccessor,
ILogger logger)
{
if (content == null) throw new ArgumentNullException(nameof(content));
@@ -32,6 +34,7 @@ namespace Umbraco.Web.Routing
if (textService == null) throw new ArgumentNullException(nameof(textService));
if (contentService == null) throw new ArgumentNullException(nameof(contentService));
if (logger == null) throw new ArgumentNullException(nameof(logger));
+ if (variationContextAccessor == null) throw new ArgumentNullException(nameof(variationContextAccessor));
if (content.Published == false)
{
@@ -56,7 +59,7 @@ namespace Umbraco.Web.Routing
//get all URLs for all cultures
//in a HashSet, so de-duplicates too
- foreach (var cultureUrl in GetContentUrlsByCulture(content, cultures, publishedRouter, umbracoContext, contentService, textService, logger))
+ foreach (var cultureUrl in GetContentUrlsByCulture(content, cultures, publishedRouter, umbracoContext, contentService, textService, variationContextAccessor, logger))
{
urls.Add(cultureUrl);
}
@@ -78,7 +81,7 @@ namespace Umbraco.Web.Routing
if (urls.Add(otherUrl)) //avoid duplicates
yield return otherUrl;
}
-
+
///
/// Tries to return a for each culture for the content while detecting collisions/errors
///
@@ -96,6 +99,7 @@ namespace Umbraco.Web.Routing
UmbracoContext umbracoContext,
IContentService contentService,
ILocalizedTextService textService,
+ IVariationContextAccessor variationContextAccessor,
ILogger logger)
{
foreach (var culture in cultures)
@@ -131,7 +135,7 @@ namespace Umbraco.Web.Routing
// got a url, deal with collisions, add url
default:
- if (DetectCollision(content, url, culture, umbracoContext, publishedRouter, textService, out var urlInfo)) // detect collisions, etc
+ if (DetectCollision(content, url, culture, umbracoContext, publishedRouter, textService, variationContextAccessor, out var urlInfo)) // detect collisions, etc
yield return urlInfo;
else
yield return UrlInfo.Url(url, culture);
@@ -161,7 +165,7 @@ namespace Umbraco.Web.Routing
return UrlInfo.Message(textService.Localize("content/parentCultureNotPublished", new[] {parent.Name}), culture);
}
- private static bool DetectCollision(IContent content, string url, string culture, UmbracoContext umbracoContext, IPublishedRouter publishedRouter, ILocalizedTextService textService, out UrlInfo urlInfo)
+ private static bool DetectCollision(IContent content, string url, string culture, UmbracoContext umbracoContext, IPublishedRouter publishedRouter, ILocalizedTextService textService, IVariationContextAccessor variationContextAccessor, out UrlInfo urlInfo)
{
// test for collisions on the 'main' url
var uri = new Uri(url.TrimEnd('/'), UriKind.RelativeOrAbsolute);
@@ -187,7 +191,7 @@ namespace Umbraco.Web.Routing
var l = new List();
while (o != null)
{
- l.Add(o.Name());
+ l.Add(o.Name(variationContextAccessor));
o = o.Parent;
}
l.Reverse();
diff --git a/src/Umbraco.Web/Runtime/WebInitialComposer.cs b/src/Umbraco.Web/Runtime/WebInitialComposer.cs
index 9b36012ca2..0c87ac78cb 100644
--- a/src/Umbraco.Web/Runtime/WebInitialComposer.cs
+++ b/src/Umbraco.Web/Runtime/WebInitialComposer.cs
@@ -4,6 +4,7 @@ using System.Web.Security;
using Examine;
using Microsoft.AspNet.SignalR;
using Umbraco.Core;
+using Umbraco.Core.Cache;
using Umbraco.Core.Composing;
using Umbraco.Core.Dashboards;
using Umbraco.Core.Dictionary;
@@ -15,6 +16,7 @@ using Umbraco.Core.PropertyEditors.ValueConverters;
using Umbraco.Core.Runtime;
using Umbraco.Core.Security;
using Umbraco.Core.Services;
+using Umbraco.Core.Sync;
using Umbraco.Net;
using Umbraco.Web.Actions;
using Umbraco.Web.Cache;
@@ -133,7 +135,7 @@ namespace Umbraco.Web.Runtime
composition.Register(_ => new UmbracoHelper());
// register distributed cache
- composition.RegisterUnique(f => new DistributedCache());
+ composition.RegisterUnique(f => new DistributedCache(f.GetInstance(), f.GetInstance()));
composition.RegisterUnique();
diff --git a/src/Umbraco.Web/Security/AuthenticationOptionsExtensions.cs b/src/Umbraco.Web/Security/AuthenticationOptionsExtensions.cs
index 568bfc1a26..7616282689 100644
--- a/src/Umbraco.Web/Security/AuthenticationOptionsExtensions.cs
+++ b/src/Umbraco.Web/Security/AuthenticationOptionsExtensions.cs
@@ -3,7 +3,8 @@ using Microsoft.Owin;
using Microsoft.Owin.Security;
using Umbraco.Core;
using Umbraco.Core.Composing;
-using Umbraco.Core.Exceptions;
+using Current = Umbraco.Web.Composing.Current;
+
namespace Umbraco.Web.Security
{
diff --git a/src/Umbraco.Web/Security/MembershipProviderBase.cs b/src/Umbraco.Web/Security/MembershipProviderBase.cs
index 5060b417f5..eacb992b0b 100644
--- a/src/Umbraco.Web/Security/MembershipProviderBase.cs
+++ b/src/Umbraco.Web/Security/MembershipProviderBase.cs
@@ -9,7 +9,7 @@ using System.Web.Hosting;
using System.Web.Configuration;
using System.Web.Security;
using Umbraco.Core;
-using Umbraco.Core.Composing;
+using Umbraco.Web.Composing;
using Umbraco.Core.Hosting;
using Umbraco.Core.Logging;
using Umbraco.Core.Security;
@@ -300,7 +300,7 @@ namespace Umbraco.Web.Security
public override bool ChangePassword(string username, string oldPassword, string newPassword)
{
string rawPasswordValue = string.Empty;
-
+
var args = new ValidatePasswordEventArgs(username, newPassword, false);
OnValidatingPassword(args);
diff --git a/src/Umbraco.Web/Security/MembershipProviderExtensions.cs b/src/Umbraco.Web/Security/MembershipProviderExtensions.cs
index fd2c9c19aa..8e558c9d00 100644
--- a/src/Umbraco.Web/Security/MembershipProviderExtensions.cs
+++ b/src/Umbraco.Web/Security/MembershipProviderExtensions.cs
@@ -3,12 +3,9 @@ using System.Security.Principal;
using System.Threading;
using System.Web;
using System.Web.Security;
-using Umbraco.Core.Composing;
+using Umbraco.Web.Composing;
using Umbraco.Core;
-using Umbraco.Core.Models;
using Umbraco.Core.Models.Membership;
-using Umbraco.Core.Security;
-using Umbraco.Core.Services;
using Umbraco.Web.Models.Membership;
using Umbraco.Web.Security.Providers;
diff --git a/src/Umbraco.Web/Suspendable.cs b/src/Umbraco.Web/Suspendable.cs
index cfe4d28e8b..619f6d7eda 100644
--- a/src/Umbraco.Web/Suspendable.cs
+++ b/src/Umbraco.Web/Suspendable.cs
@@ -1,8 +1,5 @@
-using System;
-using Examine;
-using Examine.Providers;
-using Umbraco.Core.Logging;
-using Umbraco.Core.Composing;
+using Umbraco.Core.Logging;
+using Umbraco.Web.Composing;
using Umbraco.Examine;
using Umbraco.Web.Cache;
using Umbraco.Web.Search;
diff --git a/src/Umbraco.Web/UmbracoApplicationBase.cs b/src/Umbraco.Web/UmbracoApplicationBase.cs
index 8fd7d3c504..7f6d91cbed 100644
--- a/src/Umbraco.Web/UmbracoApplicationBase.cs
+++ b/src/Umbraco.Web/UmbracoApplicationBase.cs
@@ -11,8 +11,8 @@ using Umbraco.Core.Hosting;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.Logging.Serilog;
-using Umbraco.Core.Strings;
using Umbraco.Web.Hosting;
+using Current = Umbraco.Web.Composing.Current;
namespace Umbraco.Web
{
diff --git a/src/Umbraco.Web/UmbracoContext.cs b/src/Umbraco.Web/UmbracoContext.cs
index 40db02b44c..ea8a6d5481 100644
--- a/src/Umbraco.Web/UmbracoContext.cs
+++ b/src/Umbraco.Web/UmbracoContext.cs
@@ -4,7 +4,7 @@ using System.IO;
using System.Web;
using System.Web.Routing;
using Umbraco.Core;
-using Umbraco.Core.Composing;
+using Umbraco.Web.Composing;
using Umbraco.Core.Configuration;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.Events;
diff --git a/src/Umbraco.Web/UmbracoDefaultOwinStartup.cs b/src/Umbraco.Web/UmbracoDefaultOwinStartup.cs
index bd3ca2a156..e5aade0169 100644
--- a/src/Umbraco.Web/UmbracoDefaultOwinStartup.cs
+++ b/src/Umbraco.Web/UmbracoDefaultOwinStartup.cs
@@ -30,7 +30,7 @@ namespace Umbraco.Web
protected IGlobalSettings GlobalSettings => Current.Configs.Global();
protected IUmbracoSettingsSection UmbracoSettings => Current.Configs.Settings();
protected IUserPasswordConfiguration UserPasswordConfig => Current.Configs.UserPasswordConfig();
- protected IRuntimeState RuntimeState => Core.Composing.Current.RuntimeState;
+ protected IRuntimeState RuntimeState => Current.RuntimeState;
protected ServiceContext Services => Current.Services;
protected UmbracoMapper Mapper => Current.Mapper;
protected IIpResolver IpResolver => Current.IpResolver;
diff --git a/src/Umbraco.Web/UmbracoInjectedModule.cs b/src/Umbraco.Web/UmbracoInjectedModule.cs
index 4b66c605a7..110fe4abd8 100644
--- a/src/Umbraco.Web/UmbracoInjectedModule.cs
+++ b/src/Umbraco.Web/UmbracoInjectedModule.cs
@@ -366,7 +366,7 @@ namespace Umbraco.Web
// also, if something goes wrong with our DI setup, the logging subsystem may
// not even kick in, so here we try to give as much detail as possible
- BootFailedException.Rethrow(Core.Composing.Current.RuntimeState.BootFailedException);
+ BootFailedException.Rethrow(Current.RuntimeState.BootFailedException);
};
return;
}
diff --git a/src/Umbraco.Web/WebApi/Filters/CheckIfUserTicketDataIsStaleAttribute.cs b/src/Umbraco.Web/WebApi/Filters/CheckIfUserTicketDataIsStaleAttribute.cs
index c3070fcf53..20419cc99a 100644
--- a/src/Umbraco.Web/WebApi/Filters/CheckIfUserTicketDataIsStaleAttribute.cs
+++ b/src/Umbraco.Web/WebApi/Filters/CheckIfUserTicketDataIsStaleAttribute.cs
@@ -5,7 +5,7 @@ using System.Threading.Tasks;
using System.Web.Http.Controllers;
using System.Web.Http.Filters;
using Umbraco.Core;
-using Umbraco.Core.Composing;
+using Umbraco.Web.Composing;
using Umbraco.Core.Models.Identity;
using Umbraco.Core.Models.Membership;
using Umbraco.Core.Security;
diff --git a/src/Umbraco.Web/WebApi/UmbracoApiControllerBase.cs b/src/Umbraco.Web/WebApi/UmbracoApiControllerBase.cs
index a1cd7708e2..cebb5306c9 100644
--- a/src/Umbraco.Web/WebApi/UmbracoApiControllerBase.cs
+++ b/src/Umbraco.Web/WebApi/UmbracoApiControllerBase.cs
@@ -4,7 +4,7 @@ using System.Web.Http;
using Microsoft.Owin;
using Umbraco.Core;
using Umbraco.Core.Cache;
-using Umbraco.Core.Composing;
+using Umbraco.Web.Composing;
using Umbraco.Core.Configuration;
using Umbraco.Core.Logging;
using Umbraco.Core.Mapping;
diff --git a/src/Umbraco.Web/WebApi/UnhandledExceptionLogger.cs b/src/Umbraco.Web/WebApi/UnhandledExceptionLogger.cs
index 1dd43f5b2a..323ab2e727 100644
--- a/src/Umbraco.Web/WebApi/UnhandledExceptionLogger.cs
+++ b/src/Umbraco.Web/WebApi/UnhandledExceptionLogger.cs
@@ -1,6 +1,5 @@
using System.Web.Http.ExceptionHandling;
-using Umbraco.Core;
-using Umbraco.Core.Composing;
+using Umbraco.Web.Composing;
using Umbraco.Core.Logging;
namespace Umbraco.Web.WebApi