Rename accessors
This commit is contained in:
@@ -1,13 +0,0 @@
|
||||
namespace Umbraco.Core.Models.PublishedContent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gives access to the current <see cref="PublishedContent.CurrentVariation"/>.
|
||||
/// </summary>
|
||||
public interface ICurrentVariationAccessor
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the current <see cref="PublishedContent.CurrentVariation"/>.
|
||||
/// </summary>
|
||||
CurrentVariation CurrentVariation { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
namespace Umbraco.Core.Models.PublishedContent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gives access to the current <see cref="VariationContext"/>.
|
||||
/// </summary>
|
||||
public interface IVariationContextAccessor
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the current <see cref="VariationContext"/>.
|
||||
/// </summary>
|
||||
VariationContext VariationContext { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -5,18 +5,18 @@ using System.Threading;
|
||||
namespace Umbraco.Core.Models.PublishedContent
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides a CurrentUICulture-based implementation of <see cref="ICurrentVariationAccessor"/>.
|
||||
/// Provides a CurrentUICulture-based implementation of <see cref="IVariationContextAccessor"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>This accessor does not support segments. There is no need to set the current context.</para>
|
||||
/// </remarks>
|
||||
public class ThreadCultureCurrentVariationAccessor : ICurrentVariationAccessor
|
||||
public class ThreadCultureVariationContextAccessor : IVariationContextAccessor
|
||||
{
|
||||
private readonly ConcurrentDictionary<string, CurrentVariation> _contexts = new ConcurrentDictionary<string, CurrentVariation>();
|
||||
private readonly ConcurrentDictionary<string, VariationContext> _contexts = new ConcurrentDictionary<string, VariationContext>();
|
||||
|
||||
public CurrentVariation CurrentVariation
|
||||
public VariationContext VariationContext
|
||||
{
|
||||
get => _contexts.GetOrAdd(Thread.CurrentThread.CurrentUICulture.Name, culture => new CurrentVariation(culture));
|
||||
get => _contexts.GetOrAdd(Thread.CurrentThread.CurrentUICulture.Name, culture => new VariationContext(culture));
|
||||
set => throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
@@ -3,18 +3,18 @@
|
||||
namespace Umbraco.Core.Models.PublishedContent
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides a ThreadStatic-based implementation of <see cref="ICurrentVariationAccessor"/>.
|
||||
/// Provides a ThreadStatic-based implementation of <see cref="IVariationContextAccessor"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>Something must set the current context.</para>
|
||||
/// </remarks>
|
||||
public class ThreadStaticCurrentVariationAccessor : ICurrentVariationAccessor
|
||||
public class ThreadStaticVariationContextAccessor : IVariationContextAccessor
|
||||
{
|
||||
[ThreadStatic]
|
||||
private static CurrentVariation _context;
|
||||
private static VariationContext _context;
|
||||
|
||||
/// <inheritdoc />
|
||||
public CurrentVariation CurrentVariation
|
||||
public VariationContext VariationContext
|
||||
{
|
||||
get => _context;
|
||||
set => _context = value;
|
||||
@@ -1,14 +1,14 @@
|
||||
namespace Umbraco.Core.Models.PublishedContent
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the current variation.
|
||||
/// Represents the variation context.
|
||||
/// </summary>
|
||||
public class CurrentVariation
|
||||
public class VariationContext
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CurrentVariation"/> class.
|
||||
/// Initializes a new instance of the <see cref="VariationContext"/> class.
|
||||
/// </summary>
|
||||
public CurrentVariation(string culture = null, string segment = null)
|
||||
public VariationContext(string culture = null, string segment = null)
|
||||
{
|
||||
Culture = culture ?? ""; // cannot be null, default to invariant
|
||||
Segment = segment ?? ""; // cannot be null, default to neutral
|
||||
@@ -369,11 +369,11 @@
|
||||
<Compile Include="Models\Entities\TreeEntityBase.cs" />
|
||||
<Compile Include="Models\PropertyTagsExtensions.cs" />
|
||||
<Compile Include="Models\PublishedContent\PublishedCultureInfos.cs" />
|
||||
<Compile Include="Models\PublishedContent\ICurrentVariationAccessor.cs" />
|
||||
<Compile Include="Models\PublishedContent\IVariationContextAccessor.cs" />
|
||||
<Compile Include="Models\PublishedContent\IPublishedValueFallback.cs" />
|
||||
<Compile Include="Models\PublishedContent\CurrentVariation.cs" />
|
||||
<Compile Include="Models\PublishedContent\ThreadCultureCurrentVariationAccessor.cs" />
|
||||
<Compile Include="Models\PublishedContent\ThreadStaticCurrentVariationAccessor.cs" />
|
||||
<Compile Include="Models\PublishedContent\VariationContext.cs" />
|
||||
<Compile Include="Models\PublishedContent\ThreadCultureVariationContextAccessor.cs" />
|
||||
<Compile Include="Models\PublishedContent\ThreadStaticVariationContextAccessor.cs" />
|
||||
<Compile Include="Persistence\Dtos\AuditEntryDto.cs" />
|
||||
<Compile Include="Persistence\Dtos\ConsentDto.cs" />
|
||||
<Compile Include="Persistence\Dtos\ContentVersionCultureVariationDto.cs" />
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace Umbraco.Tests.Cache.PublishedCache
|
||||
_xml.LoadXml(GetXml());
|
||||
var xmlStore = new XmlStore(() => _xml, null, null, null);
|
||||
var cacheProvider = new StaticCacheProvider();
|
||||
var domainCache = new DomainCache(ServiceContext.DomainService, SystemDefaultCultureAccessor);
|
||||
var domainCache = new DomainCache(ServiceContext.DomainService, DefaultCultureAccessor);
|
||||
var publishedShapshot = new Umbraco.Web.PublishedCache.XmlPublishedCache.PublishedSnapshot(
|
||||
new PublishedContentCache(xmlStore, domainCache, cacheProvider, globalSettings, new SiteDomainHelper(), ContentTypesCache, null, null),
|
||||
new PublishedMediaCache(xmlStore, ServiceContext.MediaService, ServiceContext.UserService, cacheProvider, ContentTypesCache),
|
||||
@@ -79,7 +79,7 @@ namespace Umbraco.Tests.Cache.PublishedCache
|
||||
umbracoSettings,
|
||||
Enumerable.Empty<IUrlProvider>(),
|
||||
globalSettings,
|
||||
new TestCurrentVariationAccessor());
|
||||
new TestVariationContextAccessor());
|
||||
|
||||
_cache = _umbracoContext.ContentCache;
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
dataTypeService);
|
||||
|
||||
// create a variation accessor
|
||||
var variationAccessor = new TestCurrentVariationAccessor();
|
||||
var variationAccessor = new TestVariationContextAccessor();
|
||||
|
||||
// at last, create the complete NuCache snapshot service!
|
||||
var options = new PublishedSnapshotService.Options { IgnoreLocalDb = true };
|
||||
@@ -145,7 +145,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
Mock.Of<IDocumentRepository>(),
|
||||
Mock.Of<IMediaRepository>(),
|
||||
Mock.Of<IMemberRepository>(),
|
||||
new TestSystemDefaultCultureAccessor(),
|
||||
new TestDefaultCultureAccessor(),
|
||||
dataSource,
|
||||
globalSettings,
|
||||
new SiteDomainHelper());
|
||||
@@ -155,7 +155,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
var publishedContent = snapshot.Content.GetById(1);
|
||||
|
||||
// invariant is the current default
|
||||
variationAccessor.CurrentVariation = new CurrentVariation();
|
||||
variationAccessor.VariationContext = new VariationContext();
|
||||
|
||||
Assert.IsNotNull(publishedContent);
|
||||
Assert.AreEqual("It Works1!", publishedContent.Name);
|
||||
@@ -176,14 +176,14 @@ namespace Umbraco.Tests.PublishedContent
|
||||
Assert.AreEqual("name-uk2", draftContent.GetCulture("en-UK").Name);
|
||||
|
||||
// now french is default
|
||||
variationAccessor.CurrentVariation = new CurrentVariation("fr-FR");
|
||||
variationAccessor.VariationContext = new VariationContext("fr-FR");
|
||||
Assert.AreEqual("val-fr1", publishedContent.Value<string>("prop"));
|
||||
Assert.AreEqual("name-fr1", publishedContent.GetCulture().Name);
|
||||
Assert.AreEqual("name-fr1", publishedContent.Name);
|
||||
Assert.AreEqual(new DateTime(2018, 01, 01, 01, 00, 00), publishedContent.GetCulture().Date);
|
||||
|
||||
// now uk is default
|
||||
variationAccessor.CurrentVariation = new CurrentVariation("en-UK");
|
||||
variationAccessor.VariationContext = new VariationContext("en-UK");
|
||||
Assert.AreEqual("val-uk1", publishedContent.Value<string>("prop"));
|
||||
Assert.AreEqual("name-uk1", publishedContent.GetCulture().Name);
|
||||
Assert.AreEqual("name-uk1", publishedContent.Name);
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
TestObjects.GetUmbracoSettings(),
|
||||
Enumerable.Empty<IUrlProvider>(),
|
||||
globalSettings,
|
||||
new TestCurrentVariationAccessor());
|
||||
new TestVariationContextAccessor());
|
||||
|
||||
return umbracoContext;
|
||||
}
|
||||
|
||||
@@ -90,11 +90,11 @@ namespace Umbraco.Tests.Scoping
|
||||
contentTypeFactory,
|
||||
null,
|
||||
publishedSnapshotAccessor,
|
||||
Mock.Of<ICurrentVariationAccessor>(),
|
||||
Mock.Of<IVariationContextAccessor>(),
|
||||
Logger,
|
||||
ScopeProvider,
|
||||
documentRepository, mediaRepository, memberRepository,
|
||||
SystemDefaultCultureAccessor,
|
||||
DefaultCultureAccessor,
|
||||
new DatabaseDataSource(),
|
||||
Container.GetInstance<IGlobalSettings>(), new SiteDomainHelper());
|
||||
}
|
||||
@@ -114,7 +114,7 @@ namespace Umbraco.Tests.Scoping
|
||||
umbracoSettings ?? SettingsForTests.GetDefaultUmbracoSettings(),
|
||||
urlProviders ?? Enumerable.Empty<IUrlProvider>(),
|
||||
globalSettings,
|
||||
new TestCurrentVariationAccessor());
|
||||
new TestVariationContextAccessor());
|
||||
|
||||
if (setSingleton)
|
||||
Umbraco.Web.Composing.Current.UmbracoContextAccessor.UmbracoContext = umbracoContext;
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Umbraco.Tests.Security
|
||||
Mock.Of<IPublishedSnapshotService>(),
|
||||
new WebSecurity(Mock.Of<HttpContextBase>(), Current.Services.UserService, globalSettings),
|
||||
TestObjects.GetUmbracoSettings(), new List<IUrlProvider>(),globalSettings,
|
||||
new TestCurrentVariationAccessor());
|
||||
new TestVariationContextAccessor());
|
||||
|
||||
var runtime = Mock.Of<IRuntimeState>(x => x.Level == RuntimeLevel.Install);
|
||||
var mgr = new BackOfficeCookieManager(
|
||||
@@ -54,7 +54,7 @@ namespace Umbraco.Tests.Security
|
||||
Mock.Of<IPublishedSnapshotService>(),
|
||||
new WebSecurity(Mock.Of<HttpContextBase>(), Current.Services.UserService, globalSettings),
|
||||
TestObjects.GetUmbracoSettings(), new List<IUrlProvider>(), globalSettings,
|
||||
new TestCurrentVariationAccessor());
|
||||
new TestVariationContextAccessor());
|
||||
|
||||
var runtime = Mock.Of<IRuntimeState>(x => x.Level == RuntimeLevel.Run);
|
||||
var mgr = new BackOfficeCookieManager(Mock.Of<IUmbracoContextAccessor>(accessor => accessor.UmbracoContext == umbCtx), runtime, TestObjects.GetGlobalSettings());
|
||||
|
||||
@@ -150,7 +150,7 @@ namespace Umbraco.Tests.TestHelpers.ControllerTesting
|
||||
Mock.Of<IUmbracoSettingsSection>(section => section.WebRouting == Mock.Of<IWebRoutingSection>(routingSection => routingSection.UrlProviderMode == UrlProviderMode.Auto.ToString())),
|
||||
Enumerable.Empty<IUrlProvider>(),
|
||||
globalSettings,
|
||||
new TestCurrentVariationAccessor(),
|
||||
new TestVariationContextAccessor(),
|
||||
true); //replace it
|
||||
|
||||
var urlHelper = new Mock<IUrlProvider>();
|
||||
|
||||
@@ -18,12 +18,12 @@ namespace Umbraco.Tests.TestHelpers.Stubs
|
||||
public int TemplateId { get; set; }
|
||||
public int SortOrder { get; set; }
|
||||
public string Name { get; set; }
|
||||
public ICurrentVariationAccessor VariationAccessor { get; set; }
|
||||
public IVariationContextAccessor VariationContextAccessor { get; set; }
|
||||
public PublishedCultureInfos GetCulture(string culture = null)
|
||||
{
|
||||
// handle context culture
|
||||
if (culture == null)
|
||||
culture = VariationAccessor?.CurrentVariation.Culture;
|
||||
culture = VariationContextAccessor?.VariationContext.Culture;
|
||||
|
||||
// no invariant culture infos
|
||||
if (culture == "" || Cultures == null) return null;
|
||||
|
||||
@@ -120,7 +120,7 @@ namespace Umbraco.Tests.TestHelpers
|
||||
var urlProviders = Enumerable.Empty<IUrlProvider>();
|
||||
|
||||
if (accessor == null) accessor = new TestUmbracoContextAccessor();
|
||||
return UmbracoContext.EnsureContext(accessor, httpContext, publishedSnapshotService, webSecurity, umbracoSettings, urlProviders, globalSettings, new TestCurrentVariationAccessor(), true);
|
||||
return UmbracoContext.EnsureContext(accessor, httpContext, publishedSnapshotService, webSecurity, umbracoSettings, urlProviders, globalSettings, new TestVariationContextAccessor(), true);
|
||||
}
|
||||
|
||||
public IUmbracoSettingsSection GetUmbracoSettings()
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace Umbraco.Tests.TestHelpers
|
||||
|
||||
Container.Register<ISqlSyntaxProvider, SqlCeSyntaxProvider>();
|
||||
Container.Register(factory => PublishedSnapshotService);
|
||||
Container.Register(factory => SystemDefaultCultureAccessor);
|
||||
Container.Register(factory => DefaultCultureAccessor);
|
||||
|
||||
Container.GetInstance<DataEditorCollectionBuilder>()
|
||||
.Clear()
|
||||
@@ -231,7 +231,7 @@ namespace Umbraco.Tests.TestHelpers
|
||||
}
|
||||
}
|
||||
|
||||
protected ISystemDefaultCultureAccessor SystemDefaultCultureAccessor { get; set; }
|
||||
protected IDefaultCultureAccessor DefaultCultureAccessor { get; set; }
|
||||
|
||||
protected IPublishedSnapshotService PublishedSnapshotService { get; set; }
|
||||
|
||||
@@ -239,7 +239,7 @@ namespace Umbraco.Tests.TestHelpers
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SystemDefaultCultureAccessor = new TestSystemDefaultCultureAccessor();
|
||||
DefaultCultureAccessor = new TestDefaultCultureAccessor();
|
||||
|
||||
CreateAndInitializeDatabase();
|
||||
|
||||
@@ -264,14 +264,14 @@ namespace Umbraco.Tests.TestHelpers
|
||||
// testing=true so XmlStore will not use the file nor the database
|
||||
|
||||
var publishedSnapshotAccessor = new UmbracoContextPublishedSnapshotAccessor(Umbraco.Web.Composing.Current.UmbracoContextAccessor);
|
||||
var variationContextAccessor = new TestCurrentVariationAccessor();
|
||||
var variationContextAccessor = new TestVariationContextAccessor();
|
||||
var service = new PublishedSnapshotService(
|
||||
ServiceContext,
|
||||
Container.GetInstance<IPublishedContentTypeFactory>(),
|
||||
ScopeProvider,
|
||||
cache, publishedSnapshotAccessor, variationContextAccessor,
|
||||
Container.GetInstance<IDocumentRepository>(), Container.GetInstance<IMediaRepository>(), Container.GetInstance<IMemberRepository>(),
|
||||
SystemDefaultCultureAccessor,
|
||||
DefaultCultureAccessor,
|
||||
Logger,
|
||||
Container.GetInstance<IGlobalSettings>(), new SiteDomainHelper(),
|
||||
ContentTypesCache,
|
||||
@@ -379,7 +379,7 @@ namespace Umbraco.Tests.TestHelpers
|
||||
umbracoSettings ?? Container.GetInstance<IUmbracoSettingsSection>(),
|
||||
urlProviders ?? Enumerable.Empty<IUrlProvider>(),
|
||||
globalSettings ?? Container.GetInstance<IGlobalSettings>(),
|
||||
new TestCurrentVariationAccessor());
|
||||
new TestVariationContextAccessor());
|
||||
|
||||
if (setSingleton)
|
||||
Umbraco.Web.Composing.Current.UmbracoContextAccessor.UmbracoContext = umbracoContext;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Umbraco.Tests.Testing.Objects.Accessors
|
||||
{
|
||||
public class TestSystemDefaultCultureAccessor : ISystemDefaultCultureAccessor
|
||||
public class TestDefaultCultureAccessor : IDefaultCultureAccessor
|
||||
{
|
||||
private string _defaultCulture = string.Empty;
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
namespace Umbraco.Tests.Testing.Objects.Accessors
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides an implementation of <see cref="ICurrentVariationAccessor"/> for tests.
|
||||
/// Provides an implementation of <see cref="IVariationContextAccessor"/> for tests.
|
||||
/// </summary>
|
||||
public class TestCurrentVariationAccessor : ICurrentVariationAccessor
|
||||
public class TestVariationContextAccessor : IVariationContextAccessor
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public CurrentVariation CurrentVariation
|
||||
public VariationContext VariationContext
|
||||
{
|
||||
get;
|
||||
set;
|
||||
@@ -81,7 +81,7 @@ namespace Umbraco.Tests.Testing.TestingTests
|
||||
.Returns("/hello/world/1234");
|
||||
var urlProvider = urlProviderMock.Object;
|
||||
|
||||
var theUrlProvider = new UrlProvider(umbracoContext, new [] { urlProvider }, umbracoContext.CurrentVariationAccessor);
|
||||
var theUrlProvider = new UrlProvider(umbracoContext, new [] { urlProvider }, umbracoContext.VariationContextAccessor);
|
||||
|
||||
var contentType = new PublishedContentType(666, "alias", PublishedItemType.Content, Enumerable.Empty<string>(), Enumerable.Empty<PublishedPropertyType>(),
|
||||
ContentVariation.InvariantNeutral);
|
||||
|
||||
@@ -181,9 +181,9 @@
|
||||
<Compile Include="Testing\Objects\Accessors\NoHttpContextAccessor.cs" />
|
||||
<Compile Include="TestHelpers\Stubs\TestExamineManager.cs" />
|
||||
<Compile Include="TestHelpers\Stubs\TestPublishedContent.cs" />
|
||||
<Compile Include="Testing\Objects\Accessors\TestCurrentVariationAccessor.cs" />
|
||||
<Compile Include="Testing\Objects\Accessors\TestVariationContextAccessor.cs" />
|
||||
<Compile Include="Testing\ContentBaseExtensions.cs" />
|
||||
<Compile Include="Testing\Objects\Accessors\TestSystemDefaultCultureAccessor.cs" />
|
||||
<Compile Include="Testing\Objects\Accessors\TestDefaultCultureAccessor.cs" />
|
||||
<Compile Include="Testing\TestDatabase.cs" />
|
||||
<Compile Include="Testing\TestingTests\NUnitTests.cs" />
|
||||
<Compile Include="Persistence\LocksTests.cs" />
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace Umbraco.Tests.Web.Mvc
|
||||
TestObjects.GetUmbracoSettings(),
|
||||
Enumerable.Empty<IUrlProvider>(),
|
||||
globalSettings,
|
||||
new TestCurrentVariationAccessor(),
|
||||
new TestVariationContextAccessor(),
|
||||
true);
|
||||
var ctrl = new MatchesDefaultIndexController { UmbracoContext = umbCtx };
|
||||
var controllerCtx = new ControllerContext(req, ctrl);
|
||||
@@ -97,7 +97,7 @@ namespace Umbraco.Tests.Web.Mvc
|
||||
TestObjects.GetUmbracoSettings(),
|
||||
Enumerable.Empty<IUrlProvider>(),
|
||||
globalSettings,
|
||||
new TestCurrentVariationAccessor(),
|
||||
new TestVariationContextAccessor(),
|
||||
true);
|
||||
var ctrl = new MatchesOverriddenIndexController { UmbracoContext = umbCtx };
|
||||
var controllerCtx = new ControllerContext(req, ctrl);
|
||||
@@ -121,7 +121,7 @@ namespace Umbraco.Tests.Web.Mvc
|
||||
TestObjects.GetUmbracoSettings(),
|
||||
Enumerable.Empty<IUrlProvider>(),
|
||||
globalSettings,
|
||||
new TestCurrentVariationAccessor(),
|
||||
new TestVariationContextAccessor(),
|
||||
true);
|
||||
var ctrl = new MatchesCustomIndexController { UmbracoContext = umbCtx };
|
||||
var controllerCtx = new ControllerContext(req, ctrl);
|
||||
@@ -145,7 +145,7 @@ namespace Umbraco.Tests.Web.Mvc
|
||||
TestObjects.GetUmbracoSettings(),
|
||||
Enumerable.Empty<IUrlProvider>(),
|
||||
globalSettings,
|
||||
new TestCurrentVariationAccessor(),
|
||||
new TestVariationContextAccessor(),
|
||||
true);
|
||||
var ctrl = new MatchesAsyncIndexController { UmbracoContext = umbCtx };
|
||||
var controllerCtx = new ControllerContext(req, ctrl);
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace Umbraco.Tests.Web.Mvc
|
||||
TestObjects.GetUmbracoSettings(),
|
||||
Enumerable.Empty<IUrlProvider>(),
|
||||
globalSettings,
|
||||
new TestCurrentVariationAccessor(),
|
||||
new TestVariationContextAccessor(),
|
||||
true);
|
||||
|
||||
var ctrl = new TestSurfaceController { UmbracoContext = umbracoContext };
|
||||
@@ -68,7 +68,7 @@ namespace Umbraco.Tests.Web.Mvc
|
||||
TestObjects.GetUmbracoSettings(),
|
||||
Enumerable.Empty<IUrlProvider>(),
|
||||
globalSettings,
|
||||
new TestCurrentVariationAccessor(),
|
||||
new TestVariationContextAccessor(),
|
||||
true);
|
||||
|
||||
var ctrl = new TestSurfaceController { UmbracoContext = umbCtx };
|
||||
@@ -88,7 +88,7 @@ namespace Umbraco.Tests.Web.Mvc
|
||||
TestObjects.GetUmbracoSettings(),
|
||||
Enumerable.Empty<IUrlProvider>(),
|
||||
globalSettings,
|
||||
new TestCurrentVariationAccessor(),
|
||||
new TestVariationContextAccessor(),
|
||||
true);
|
||||
|
||||
var controller = new TestSurfaceController { UmbracoContext = umbracoContext };
|
||||
@@ -115,7 +115,7 @@ namespace Umbraco.Tests.Web.Mvc
|
||||
Mock.Of<IUmbracoSettingsSection>(section => section.WebRouting == Mock.Of<IWebRoutingSection>(routingSection => routingSection.UrlProviderMode == "AutoLegacy")),
|
||||
Enumerable.Empty<IUrlProvider>(),
|
||||
globalSettings,
|
||||
new TestCurrentVariationAccessor(),
|
||||
new TestVariationContextAccessor(),
|
||||
true);
|
||||
|
||||
var helper = new UmbracoHelper(
|
||||
@@ -153,7 +153,7 @@ namespace Umbraco.Tests.Web.Mvc
|
||||
Mock.Of<IUmbracoSettingsSection>(section => section.WebRouting == webRoutingSettings),
|
||||
Enumerable.Empty<IUrlProvider>(),
|
||||
globalSettings,
|
||||
new TestCurrentVariationAccessor(),
|
||||
new TestVariationContextAccessor(),
|
||||
true);
|
||||
|
||||
var content = Mock.Of<IPublishedContent>(publishedContent => publishedContent.Id == 12345);
|
||||
|
||||
@@ -427,7 +427,7 @@ namespace Umbraco.Tests.Web.Mvc
|
||||
_service = new PublishedSnapshotService(svcCtx, factory, scopeProvider, cache, Enumerable.Empty<IUrlSegmentProvider>(),
|
||||
null, null,
|
||||
null, null, null,
|
||||
new TestSystemDefaultCultureAccessor(),
|
||||
new TestDefaultCultureAccessor(),
|
||||
Current.Logger, TestObjects.GetGlobalSettings(), new SiteDomainHelper(), null, true, false); // no events
|
||||
|
||||
var http = GetHttpContextFactory(url, routeData).HttpContext;
|
||||
@@ -441,7 +441,7 @@ namespace Umbraco.Tests.Web.Mvc
|
||||
TestObjects.GetUmbracoSettings(),
|
||||
Enumerable.Empty<IUrlProvider>(),
|
||||
globalSettings,
|
||||
new TestCurrentVariationAccessor());
|
||||
new TestVariationContextAccessor());
|
||||
|
||||
//if (setSingleton)
|
||||
//{
|
||||
|
||||
@@ -104,7 +104,7 @@ namespace Umbraco.Tests.Web
|
||||
//pass in the custom url provider
|
||||
new[]{ testUrlProvider.Object },
|
||||
globalSettings,
|
||||
new TestCurrentVariationAccessor(),
|
||||
new TestVariationContextAccessor(),
|
||||
true))
|
||||
{
|
||||
var output = TemplateUtilities.ParseInternalLinks(input, umbCtx.UrlProvider);
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Umbraco.Tests.Web
|
||||
TestObjects.GetUmbracoSettings(),
|
||||
new List<IUrlProvider>(),
|
||||
TestObjects.GetGlobalSettings(),
|
||||
new TestCurrentVariationAccessor());
|
||||
new TestVariationContextAccessor());
|
||||
var r1 = new RouteData();
|
||||
r1.DataTokens.Add(Core.Constants.Web.UmbracoContextDataToken, umbCtx);
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace Umbraco.Tests.Web
|
||||
TestObjects.GetUmbracoSettings(),
|
||||
new List<IUrlProvider>(),
|
||||
TestObjects.GetGlobalSettings(),
|
||||
new TestCurrentVariationAccessor());
|
||||
new TestVariationContextAccessor());
|
||||
|
||||
var r1 = new RouteData();
|
||||
r1.DataTokens.Add(Core.Constants.Web.UmbracoContextDataToken, umbCtx);
|
||||
@@ -78,7 +78,7 @@ namespace Umbraco.Tests.Web
|
||||
TestObjects.GetUmbracoSettings(),
|
||||
new List<IUrlProvider>(),
|
||||
TestObjects.GetGlobalSettings(),
|
||||
new TestCurrentVariationAccessor());
|
||||
new TestVariationContextAccessor());
|
||||
|
||||
var httpContext = Mock.Of<HttpContextBase>();
|
||||
|
||||
|
||||
@@ -237,7 +237,7 @@ namespace Umbraco.Web.Cache
|
||||
UmbracoConfig.For.UmbracoSettings(),
|
||||
Current.UrlProviders,
|
||||
UmbracoConfig.For.GlobalSettings(),
|
||||
Current.Container.GetInstance<ICurrentVariationAccessor>(),
|
||||
Current.Container.GetInstance<IVariationContextAccessor>(),
|
||||
true);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,11 +27,11 @@ namespace Umbraco.Web.Editors
|
||||
[PluginController("UmbracoApi")]
|
||||
public class MacroController : UmbracoAuthorizedJsonController, IRequiresSessionState
|
||||
{
|
||||
private readonly ICurrentVariationAccessor _variationAccessor;
|
||||
private readonly IVariationContextAccessor _variationContextAccessor;
|
||||
|
||||
public MacroController(ICurrentVariationAccessor variationAccessor)
|
||||
public MacroController(IVariationContextAccessor variationContextAccessor)
|
||||
{
|
||||
_variationAccessor = variationAccessor;
|
||||
_variationContextAccessor = variationContextAccessor;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -121,7 +121,7 @@ namespace Umbraco.Web.Editors
|
||||
//the 'easiest' way might be to create an IPublishedContent manually and populate the legacy 'page' object with that
|
||||
//and then set the legacy parameters.
|
||||
|
||||
var legacyPage = new global::umbraco.page(doc, _variationAccessor);
|
||||
var legacyPage = new global::umbraco.page(doc, _variationContextAccessor);
|
||||
UmbracoContext.HttpContext.Items["pageID"] = doc.Id;
|
||||
UmbracoContext.HttpContext.Items["pageElements"] = legacyPage.Elements;
|
||||
UmbracoContext.HttpContext.Items[global::Umbraco.Core.Constants.Conventions.Url.AltTemplate] = null;
|
||||
|
||||
@@ -3,17 +3,17 @@
|
||||
namespace Umbraco.Web.PublishedCache
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides the default implementation of <see cref="ISystemDefaultCultureAccessor"/>.
|
||||
/// Provides the default implementation of <see cref="IDefaultCultureAccessor"/>.
|
||||
/// </summary>
|
||||
public class SystemDefaultCultureAccessor : ISystemDefaultCultureAccessor
|
||||
public class DefaultCultureAccessor : IDefaultCultureAccessor
|
||||
{
|
||||
private readonly ILocalizationService _localizationService;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SystemDefaultCultureAccessor"/> class.
|
||||
/// Initializes a new instance of the <see cref="DefaultCultureAccessor"/> class.
|
||||
/// </summary>
|
||||
/// <param name="localizationService"></param>
|
||||
public SystemDefaultCultureAccessor(ILocalizationService localizationService)
|
||||
public DefaultCultureAccessor(ILocalizationService localizationService)
|
||||
{
|
||||
_localizationService = localizationService;
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
namespace Umbraco.Web.PublishedCache
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides the system default culture.
|
||||
/// Gives access to the default culture.
|
||||
/// </summary>
|
||||
public interface ISystemDefaultCultureAccessor
|
||||
public interface IDefaultCultureAccessor
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the system default culture.
|
||||
@@ -34,10 +34,10 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
DateTime createDate, int creatorId,
|
||||
ContentData draftData, ContentData publishedData,
|
||||
IPublishedSnapshotAccessor publishedSnapshotAccessor,
|
||||
ICurrentVariationAccessor variationAccessor)
|
||||
IVariationContextAccessor variationContextAccessor)
|
||||
: this(id, uid, level, path, sortOrder, parentContentId, createDate, creatorId)
|
||||
{
|
||||
SetContentTypeAndData(contentType, draftData, publishedData, publishedSnapshotAccessor, variationAccessor);
|
||||
SetContentTypeAndData(contentType, draftData, publishedData, publishedSnapshotAccessor, variationContextAccessor);
|
||||
}
|
||||
|
||||
// 2-phases ctor, phase 1
|
||||
@@ -59,7 +59,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
}
|
||||
|
||||
// two-phase ctor, phase 2
|
||||
public void SetContentTypeAndData(PublishedContentType contentType, ContentData draftData, ContentData publishedData, IPublishedSnapshotAccessor publishedSnapshotAccessor, ICurrentVariationAccessor variationAccessor)
|
||||
public void SetContentTypeAndData(PublishedContentType contentType, ContentData draftData, ContentData publishedData, IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor)
|
||||
{
|
||||
ContentType = contentType;
|
||||
|
||||
@@ -67,9 +67,9 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
throw new ArgumentException("Both draftData and publishedData cannot be null at the same time.");
|
||||
|
||||
if (draftData != null)
|
||||
Draft = new PublishedContent(this, draftData, publishedSnapshotAccessor, variationAccessor).CreateModel();
|
||||
Draft = new PublishedContent(this, draftData, publishedSnapshotAccessor, variationContextAccessor).CreateModel();
|
||||
if (publishedData != null)
|
||||
Published = new PublishedContent(this, publishedData, publishedSnapshotAccessor, variationAccessor).CreateModel();
|
||||
Published = new PublishedContent(this, publishedData, publishedSnapshotAccessor, variationContextAccessor).CreateModel();
|
||||
}
|
||||
|
||||
// clone parent
|
||||
@@ -98,7 +98,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
}
|
||||
|
||||
// clone with new content type
|
||||
public ContentNode(ContentNode origin, PublishedContentType contentType, IPublishedSnapshotAccessor publishedSnapshotAccessor, ICurrentVariationAccessor variationAccessor)
|
||||
public ContentNode(ContentNode origin, PublishedContentType contentType, IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor)
|
||||
{
|
||||
Id = origin.Id;
|
||||
Uid = origin.Uid;
|
||||
@@ -113,8 +113,8 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
var originDraft = origin.Draft == null ? null : PublishedContent.UnwrapIPublishedContent(origin.Draft);
|
||||
var originPublished = origin.Published == null ? null : PublishedContent.UnwrapIPublishedContent(origin.Published);
|
||||
|
||||
Draft = originDraft == null ? null : new PublishedContent(this, originDraft._contentData, publishedSnapshotAccessor, variationAccessor).CreateModel();
|
||||
Published = originPublished == null ? null : new PublishedContent(this, originPublished._contentData, publishedSnapshotAccessor, variationAccessor).CreateModel();
|
||||
Draft = originDraft == null ? null : new PublishedContent(this, originDraft._contentData, publishedSnapshotAccessor, variationContextAccessor).CreateModel();
|
||||
Published = originPublished == null ? null : new PublishedContent(this, originPublished._contentData, publishedSnapshotAccessor, variationContextAccessor).CreateModel();
|
||||
|
||||
ChildContentIds = origin.ChildContentIds; // can be the *same* list FIXME oh really?
|
||||
}
|
||||
|
||||
@@ -17,9 +17,9 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
|
||||
public static ContentNodeKit Null { get; } = new ContentNodeKit { ContentTypeId = -1 };
|
||||
|
||||
public void Build(PublishedContentType contentType, IPublishedSnapshotAccessor publishedSnapshotAccessor, ICurrentVariationAccessor variationAccessor)
|
||||
public void Build(PublishedContentType contentType, IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor)
|
||||
{
|
||||
Node.SetContentTypeAndData(contentType, DraftData, PublishedData, publishedSnapshotAccessor, variationAccessor);
|
||||
Node.SetContentTypeAndData(contentType, DraftData, PublishedData, publishedSnapshotAccessor, variationContextAccessor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
// SnapDictionary has unit tests to ensure it all works correctly
|
||||
|
||||
private readonly IPublishedSnapshotAccessor _publishedSnapshotAccessor;
|
||||
private readonly ICurrentVariationAccessor _variationAccessor;
|
||||
private readonly IVariationContextAccessor _variationContextAccessor;
|
||||
private readonly ConcurrentDictionary<int, LinkedNode<ContentNode>> _contentNodes;
|
||||
private readonly ConcurrentDictionary<int, LinkedNode<object>> _contentRootNodes;
|
||||
private readonly ConcurrentDictionary<int, LinkedNode<PublishedContentType>> _contentTypesById;
|
||||
@@ -44,10 +44,10 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
|
||||
#region Ctor
|
||||
|
||||
public ContentStore(IPublishedSnapshotAccessor publishedSnapshotAccessor, ICurrentVariationAccessor variationAccessor, ILogger logger, BPlusTree<int, ContentNodeKit> localDb = null)
|
||||
public ContentStore(IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor, ILogger logger, BPlusTree<int, ContentNodeKit> localDb = null)
|
||||
{
|
||||
_publishedSnapshotAccessor = publishedSnapshotAccessor;
|
||||
_variationAccessor = variationAccessor;
|
||||
_variationContextAccessor = variationContextAccessor;
|
||||
_logger = logger;
|
||||
_localDb = localDb;
|
||||
|
||||
@@ -279,7 +279,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
if (node == null) continue;
|
||||
var contentTypeId = node.ContentType.Id;
|
||||
if (index.TryGetValue(contentTypeId, out PublishedContentType contentType) == false) continue;
|
||||
SetValueLocked(_contentNodes, node.Id, new ContentNode(node, contentType, _publishedSnapshotAccessor, _variationAccessor));
|
||||
SetValueLocked(_contentNodes, node.Id, new ContentNode(node, contentType, _publishedSnapshotAccessor, _variationContextAccessor));
|
||||
}
|
||||
}
|
||||
finally
|
||||
@@ -393,7 +393,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
_contentNodes.TryGetValue(id, out LinkedNode<ContentNode> link);
|
||||
if (link?.Value == null)
|
||||
continue;
|
||||
var node = new ContentNode(link.Value, contentType, _publishedSnapshotAccessor, _variationAccessor);
|
||||
var node = new ContentNode(link.Value, contentType, _publishedSnapshotAccessor, _variationContextAccessor);
|
||||
SetValueLocked(_contentNodes, id, node);
|
||||
if (_localDb != null) RegisterChange(id, node.ToKit());
|
||||
}
|
||||
@@ -416,7 +416,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
return false;
|
||||
|
||||
// and use
|
||||
kit.Build(link.Value, _publishedSnapshotAccessor, _variationAccessor);
|
||||
kit.Build(link.Value, _publishedSnapshotAccessor, _variationContextAccessor);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
class MemberCache : IPublishedMemberCache, INavigableData
|
||||
{
|
||||
private readonly IPublishedSnapshotAccessor _publishedSnapshotAccessor;
|
||||
public readonly ICurrentVariationAccessor VariationAccessor;
|
||||
public readonly IVariationContextAccessor VariationContextAccessor;
|
||||
private readonly ICacheProvider _snapshotCache;
|
||||
private readonly IMemberService _memberService;
|
||||
private readonly IDataTypeService _dataTypeService;
|
||||
@@ -24,11 +24,11 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
private readonly PublishedContentTypeCache _contentTypeCache;
|
||||
private readonly bool _previewDefault;
|
||||
|
||||
public MemberCache(bool previewDefault, ICacheProvider snapshotCache, IMemberService memberService, IDataTypeService dataTypeService, ILocalizationService localizationService, PublishedContentTypeCache contentTypeCache, IPublishedSnapshotAccessor publishedSnapshotAccessor, ICurrentVariationAccessor variationAccessor)
|
||||
public MemberCache(bool previewDefault, ICacheProvider snapshotCache, IMemberService memberService, IDataTypeService dataTypeService, ILocalizationService localizationService, PublishedContentTypeCache contentTypeCache, IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor)
|
||||
{
|
||||
_snapshotCache = snapshotCache;
|
||||
_publishedSnapshotAccessor = publishedSnapshotAccessor;
|
||||
VariationAccessor = variationAccessor;
|
||||
VariationContextAccessor = variationContextAccessor;
|
||||
_memberService = memberService;
|
||||
_dataTypeService = dataTypeService;
|
||||
_localizationService = localizationService;
|
||||
@@ -65,14 +65,14 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
var member = _memberService.GetById(memberId);
|
||||
return member == null
|
||||
? null
|
||||
: PublishedMember.Create(member, GetContentType(member.ContentTypeId), _previewDefault, _publishedSnapshotAccessor, VariationAccessor);
|
||||
: PublishedMember.Create(member, GetContentType(member.ContentTypeId), _previewDefault, _publishedSnapshotAccessor, VariationContextAccessor);
|
||||
});
|
||||
}
|
||||
|
||||
private IPublishedContent /*IPublishedMember*/ GetById(IMember member, bool previewing)
|
||||
{
|
||||
return GetCacheItem(CacheKeys.MemberCacheMember("ById", _previewDefault, member.Id), () =>
|
||||
PublishedMember.Create(member, GetContentType(member.ContentTypeId), previewing, _publishedSnapshotAccessor, VariationAccessor));
|
||||
PublishedMember.Create(member, GetContentType(member.ContentTypeId), previewing, _publishedSnapshotAccessor, VariationContextAccessor));
|
||||
}
|
||||
|
||||
public IPublishedContent /*IPublishedMember*/ GetByProviderKey(object key)
|
||||
@@ -107,7 +107,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
|
||||
public IPublishedContent /*IPublishedMember*/ GetByMember(IMember member)
|
||||
{
|
||||
return PublishedMember.Create(member, GetContentType(member.ContentTypeId), _previewDefault, _publishedSnapshotAccessor, VariationAccessor);
|
||||
return PublishedMember.Create(member, GetContentType(member.ContentTypeId), _previewDefault, _publishedSnapshotAccessor, VariationContextAccessor);
|
||||
}
|
||||
|
||||
public IEnumerable<IPublishedContent> GetAtRoot(bool preview)
|
||||
@@ -115,7 +115,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
// because members are flat (not a tree) everything is at root
|
||||
// because we're loading everything... let's just not cache?
|
||||
var members = _memberService.GetAllMembers();
|
||||
return members.Select(m => PublishedMember.Create(m, GetContentType(m.ContentTypeId), preview, _publishedSnapshotAccessor, VariationAccessor));
|
||||
return members.Select(m => PublishedMember.Create(m, GetContentType(m.ContentTypeId), preview, _publishedSnapshotAccessor, VariationContextAccessor));
|
||||
}
|
||||
|
||||
public XPathNavigator CreateNavigator()
|
||||
|
||||
@@ -191,7 +191,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
|
||||
// use context values
|
||||
// fixme CultureSegment?
|
||||
var publishedVariationContext = _content.VariationAccessor?.CurrentVariation;
|
||||
var publishedVariationContext = _content.VariationContextAccessor?.VariationContext;
|
||||
if (culture == null) culture = _variations.Has(ContentVariation.CultureNeutral) ? publishedVariationContext?.Culture : "";
|
||||
if (segment == null) segment = _variations.Has(ContentVariation.CultureNeutral) ? publishedVariationContext?.Segment : "";
|
||||
}
|
||||
|
||||
@@ -22,12 +22,12 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
|
||||
#region Constructors
|
||||
|
||||
public PublishedContent(ContentNode contentNode, ContentData contentData, IPublishedSnapshotAccessor publishedSnapshotAccessor, ICurrentVariationAccessor variationAccessor)
|
||||
public PublishedContent(ContentNode contentNode, ContentData contentData, IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor)
|
||||
{
|
||||
_contentNode = contentNode;
|
||||
_contentData = contentData;
|
||||
_publishedSnapshotAccessor = publishedSnapshotAccessor;
|
||||
VariationAccessor = variationAccessor; // fixme why is this a property? should be be on the base class?
|
||||
VariationContextAccessor = variationContextAccessor; // fixme why is this a property? should be be on the base class?
|
||||
|
||||
_urlSegment = _contentData.Name.ToUrlSegment();
|
||||
IsPreviewing = _contentData.Published == false;
|
||||
@@ -70,7 +70,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
{
|
||||
_contentNode = contentNode;
|
||||
_publishedSnapshotAccessor = origin._publishedSnapshotAccessor;
|
||||
VariationAccessor = origin.VariationAccessor;
|
||||
VariationContextAccessor = origin.VariationContextAccessor;
|
||||
_contentData = origin._contentData;
|
||||
|
||||
_urlSegment = origin._urlSegment;
|
||||
@@ -86,7 +86,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
private PublishedContent(PublishedContent origin)
|
||||
{
|
||||
_publishedSnapshotAccessor = origin._publishedSnapshotAccessor;
|
||||
VariationAccessor = origin.VariationAccessor;
|
||||
VariationContextAccessor = origin.VariationContextAccessor;
|
||||
_contentNode = origin._contentNode;
|
||||
_contentData = origin._contentData;
|
||||
|
||||
@@ -181,7 +181,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
if (!ContentType.Variations.Has(ContentVariation.CultureNeutral)) // fixme CultureSegment?
|
||||
return _contentData.Name;
|
||||
|
||||
var culture = VariationAccessor.CurrentVariation.Culture;
|
||||
var culture = VariationContextAccessor.VariationContext.Culture;
|
||||
if (culture == "")
|
||||
return _contentData.Name;
|
||||
|
||||
@@ -197,7 +197,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
if (!ContentType.Variations.Has(ContentVariation.CultureNeutral)) // fixme CultureSegment?
|
||||
return _urlSegment;
|
||||
|
||||
var culture = VariationAccessor.CurrentVariation.Culture;
|
||||
var culture = VariationContextAccessor.VariationContext.Culture;
|
||||
if (culture == "")
|
||||
return _urlSegment;
|
||||
|
||||
@@ -244,7 +244,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
{
|
||||
// handle context culture
|
||||
if (culture == null)
|
||||
culture = VariationAccessor.CurrentVariation.Culture;
|
||||
culture = VariationContextAccessor.VariationContext.Culture;
|
||||
|
||||
// no invariant culture infos
|
||||
if (culture == "") return null;
|
||||
@@ -397,7 +397,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
|
||||
#region Internal
|
||||
|
||||
internal ICurrentVariationAccessor VariationAccessor { get; }
|
||||
internal IVariationContextAccessor VariationContextAccessor { get; }
|
||||
|
||||
// used by navigable content
|
||||
internal IPublishedProperty[] PropertiesArray { get; }
|
||||
|
||||
@@ -15,13 +15,13 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
{
|
||||
private readonly IMember _member;
|
||||
|
||||
private PublishedMember(IMember member, ContentNode contentNode, ContentData contentData, IPublishedSnapshotAccessor publishedSnapshotAccessor, ICurrentVariationAccessor variationAccessor)
|
||||
: base(contentNode, contentData, publishedSnapshotAccessor, variationAccessor)
|
||||
private PublishedMember(IMember member, ContentNode contentNode, ContentData contentData, IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor)
|
||||
: base(contentNode, contentData, publishedSnapshotAccessor, variationContextAccessor)
|
||||
{
|
||||
_member = member;
|
||||
}
|
||||
|
||||
public static IPublishedContent Create(IMember member, PublishedContentType contentType, bool previewing, IPublishedSnapshotAccessor publishedSnapshotAccessor, ICurrentVariationAccessor variationAccessor)
|
||||
public static IPublishedContent Create(IMember member, PublishedContentType contentType, bool previewing, IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor)
|
||||
{
|
||||
var d = new ContentData
|
||||
{
|
||||
@@ -37,7 +37,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
member.Level, member.Path, member.SortOrder,
|
||||
member.ParentId,
|
||||
member.CreateDate, member.CreatorId);
|
||||
return new PublishedMember(member, n, d, publishedSnapshotAccessor, variationAccessor).CreateModel();
|
||||
return new PublishedMember(member, n, d, publishedSnapshotAccessor, variationContextAccessor).CreateModel();
|
||||
}
|
||||
|
||||
private static Dictionary<string, PropertyData[]> GetPropertyValues(PublishedContentType contentType, IMember member)
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
private readonly IMemberRepository _memberRepository;
|
||||
private readonly IGlobalSettings _globalSettings;
|
||||
private readonly ISiteDomainHelper _siteDomainHelper;
|
||||
private readonly ISystemDefaultCultureAccessor _systemDefaultCultureAccessor;
|
||||
private readonly IDefaultCultureAccessor _defaultCultureAccessor;
|
||||
|
||||
// volatile because we read it with no lock
|
||||
private volatile bool _isReady;
|
||||
@@ -81,12 +81,12 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
|
||||
public PublishedSnapshotService(Options options, MainDom mainDom, IRuntimeState runtime,
|
||||
ServiceContext serviceContext, IPublishedContentTypeFactory publishedContentTypeFactory, IdkMap idkMap,
|
||||
IPublishedSnapshotAccessor publishedSnapshotAccessor, ICurrentVariationAccessor variationAccessor,
|
||||
IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor,
|
||||
ILogger logger, IScopeProvider scopeProvider,
|
||||
IDocumentRepository documentRepository, IMediaRepository mediaRepository, IMemberRepository memberRepository,
|
||||
ISystemDefaultCultureAccessor systemDefaultCultureAccessor,
|
||||
IDefaultCultureAccessor defaultCultureAccessor,
|
||||
IDataSource dataSource, IGlobalSettings globalSettings, ISiteDomainHelper siteDomainHelper)
|
||||
: base(publishedSnapshotAccessor, variationAccessor)
|
||||
: base(publishedSnapshotAccessor, variationContextAccessor)
|
||||
{
|
||||
//if (Interlocked.Increment(ref _singletonCheck) > 1)
|
||||
// throw new Exception("Singleton must be instancianted only once!");
|
||||
@@ -99,7 +99,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
_documentRepository = documentRepository;
|
||||
_mediaRepository = mediaRepository;
|
||||
_memberRepository = memberRepository;
|
||||
_systemDefaultCultureAccessor = systemDefaultCultureAccessor;
|
||||
_defaultCultureAccessor = defaultCultureAccessor;
|
||||
_globalSettings = globalSettings;
|
||||
_siteDomainHelper = siteDomainHelper;
|
||||
|
||||
@@ -145,13 +145,13 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
// stores are created with a db so they can write to it, but they do not read from it,
|
||||
// stores need to be populated, happens in OnResolutionFrozen which uses _localDbExists to
|
||||
// figure out whether it can read the dbs or it should populate them from sql
|
||||
_contentStore = new ContentStore(publishedSnapshotAccessor, variationAccessor, logger, _localContentDb);
|
||||
_mediaStore = new ContentStore(publishedSnapshotAccessor, variationAccessor, logger, _localMediaDb);
|
||||
_contentStore = new ContentStore(publishedSnapshotAccessor, variationContextAccessor, logger, _localContentDb);
|
||||
_mediaStore = new ContentStore(publishedSnapshotAccessor, variationContextAccessor, logger, _localMediaDb);
|
||||
}
|
||||
else
|
||||
{
|
||||
_contentStore = new ContentStore(publishedSnapshotAccessor, variationAccessor, logger);
|
||||
_mediaStore = new ContentStore(publishedSnapshotAccessor, variationAccessor, logger);
|
||||
_contentStore = new ContentStore(publishedSnapshotAccessor, variationContextAccessor, logger);
|
||||
_mediaStore = new ContentStore(publishedSnapshotAccessor, variationContextAccessor, logger);
|
||||
}
|
||||
|
||||
_domainStore = new SnapDictionary<int, Domain>();
|
||||
@@ -996,7 +996,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
|
||||
var memberTypeCache = new PublishedContentTypeCache(null, null, _serviceContext.MemberTypeService, _publishedContentTypeFactory, _logger);
|
||||
|
||||
var defaultCulture = _systemDefaultCultureAccessor.DefaultCulture;
|
||||
var defaultCulture = _defaultCultureAccessor.DefaultCulture;
|
||||
var domainCache = new DomainCache(domainSnap, defaultCulture);
|
||||
var domainHelper = new DomainHelper(domainCache, _siteDomainHelper);
|
||||
|
||||
@@ -1004,7 +1004,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
{
|
||||
ContentCache = new ContentCache(previewDefault, contentSnap, snapshotCache, elementsCache, domainHelper, _globalSettings, _serviceContext.LocalizationService),
|
||||
MediaCache = new MediaCache(previewDefault, mediaSnap, snapshotCache, elementsCache),
|
||||
MemberCache = new MemberCache(previewDefault, snapshotCache, _serviceContext.MemberService, _serviceContext.DataTypeService, _serviceContext.LocalizationService, memberTypeCache, PublishedSnapshotAccessor, VariationAccessor),
|
||||
MemberCache = new MemberCache(previewDefault, snapshotCache, _serviceContext.MemberService, _serviceContext.DataTypeService, _serviceContext.LocalizationService, memberTypeCache, PublishedSnapshotAccessor, VariationContextAccessor),
|
||||
DomainCache = domainCache,
|
||||
SnapshotCache = snapshotCache,
|
||||
ElementsCache = elementsCache
|
||||
|
||||
@@ -7,14 +7,14 @@ namespace Umbraco.Web.PublishedCache
|
||||
{
|
||||
abstract class PublishedSnapshotServiceBase : IPublishedSnapshotService
|
||||
{
|
||||
protected PublishedSnapshotServiceBase(IPublishedSnapshotAccessor publishedSnapshotAccessor, ICurrentVariationAccessor variationAccessor)
|
||||
protected PublishedSnapshotServiceBase(IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor)
|
||||
{
|
||||
PublishedSnapshotAccessor = publishedSnapshotAccessor;
|
||||
VariationAccessor = variationAccessor;
|
||||
VariationContextAccessor = variationContextAccessor;
|
||||
}
|
||||
|
||||
public IPublishedSnapshotAccessor PublishedSnapshotAccessor { get; }
|
||||
public ICurrentVariationAccessor VariationAccessor { get; }
|
||||
public IVariationContextAccessor VariationContextAccessor { get; }
|
||||
|
||||
// note: NOT setting _publishedSnapshotAccessor.PublishedSnapshot here because it is the
|
||||
// responsibility of the caller to manage what the 'current' facade is
|
||||
|
||||
@@ -11,10 +11,10 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
{
|
||||
private readonly IDomainService _domainService;
|
||||
|
||||
public DomainCache(IDomainService domainService, ISystemDefaultCultureAccessor systemDefaultCultureAccessor)
|
||||
public DomainCache(IDomainService domainService, IDefaultCultureAccessor defaultCultureAccessor)
|
||||
{
|
||||
_domainService = domainService;
|
||||
DefaultCulture = systemDefaultCultureAccessor.DefaultCulture;
|
||||
DefaultCulture = defaultCultureAccessor.DefaultCulture;
|
||||
}
|
||||
|
||||
public IEnumerable<Domain> GetAll(bool includeWildcards)
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
private readonly IUserService _userService;
|
||||
private readonly ICacheProvider _requestCache;
|
||||
private readonly IGlobalSettings _globalSettings;
|
||||
private readonly ISystemDefaultCultureAccessor _systemDefaultCultureAccessor;
|
||||
private readonly IDefaultCultureAccessor _defaultCultureAccessor;
|
||||
private readonly ISiteDomainHelper _siteDomainHelper;
|
||||
|
||||
#region Constructors
|
||||
@@ -43,18 +43,18 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
IScopeProvider scopeProvider,
|
||||
ICacheProvider requestCache,
|
||||
IEnumerable<IUrlSegmentProvider> segmentProviders,
|
||||
IPublishedSnapshotAccessor publishedSnapshotAccessor, ICurrentVariationAccessor variationAccessor,
|
||||
IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor,
|
||||
IDocumentRepository documentRepository, IMediaRepository mediaRepository, IMemberRepository memberRepository,
|
||||
ISystemDefaultCultureAccessor systemDefaultCultureAccessor,
|
||||
IDefaultCultureAccessor defaultCultureAccessor,
|
||||
ILogger logger,
|
||||
IGlobalSettings globalSettings,
|
||||
ISiteDomainHelper siteDomainHelper,
|
||||
MainDom mainDom,
|
||||
bool testing = false, bool enableRepositoryEvents = true)
|
||||
: this(serviceContext, publishedContentTypeFactory, scopeProvider, requestCache, segmentProviders,
|
||||
publishedSnapshotAccessor, variationAccessor,
|
||||
publishedSnapshotAccessor, variationContextAccessor,
|
||||
documentRepository, mediaRepository, memberRepository,
|
||||
systemDefaultCultureAccessor,
|
||||
defaultCultureAccessor,
|
||||
logger, globalSettings, siteDomainHelper, null, mainDom, testing, enableRepositoryEvents)
|
||||
{ }
|
||||
|
||||
@@ -63,9 +63,9 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
IPublishedContentTypeFactory publishedContentTypeFactory,
|
||||
IScopeProvider scopeProvider,
|
||||
ICacheProvider requestCache,
|
||||
IPublishedSnapshotAccessor publishedSnapshotAccessor, ICurrentVariationAccessor variationAccessor,
|
||||
IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor,
|
||||
IDocumentRepository documentRepository, IMediaRepository mediaRepository, IMemberRepository memberRepository,
|
||||
ISystemDefaultCultureAccessor systemDefaultCultureAccessor,
|
||||
IDefaultCultureAccessor defaultCultureAccessor,
|
||||
ILogger logger,
|
||||
IGlobalSettings globalSettings,
|
||||
ISiteDomainHelper siteDomainHelper,
|
||||
@@ -73,9 +73,9 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
MainDom mainDom,
|
||||
bool testing, bool enableRepositoryEvents)
|
||||
: this(serviceContext, publishedContentTypeFactory, scopeProvider, requestCache, Enumerable.Empty<IUrlSegmentProvider>(),
|
||||
publishedSnapshotAccessor, variationAccessor,
|
||||
publishedSnapshotAccessor, variationContextAccessor,
|
||||
documentRepository, mediaRepository, memberRepository,
|
||||
systemDefaultCultureAccessor,
|
||||
defaultCultureAccessor,
|
||||
logger, globalSettings, siteDomainHelper, contentTypeCache, mainDom, testing, enableRepositoryEvents)
|
||||
{ }
|
||||
|
||||
@@ -84,16 +84,16 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
IScopeProvider scopeProvider,
|
||||
ICacheProvider requestCache,
|
||||
IEnumerable<IUrlSegmentProvider> segmentProviders,
|
||||
IPublishedSnapshotAccessor publishedSnapshotAccessor, ICurrentVariationAccessor variationAccessor,
|
||||
IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor,
|
||||
IDocumentRepository documentRepository, IMediaRepository mediaRepository, IMemberRepository memberRepository,
|
||||
ISystemDefaultCultureAccessor systemDefaultCultureAccessor,
|
||||
IDefaultCultureAccessor defaultCultureAccessor,
|
||||
ILogger logger,
|
||||
IGlobalSettings globalSettings,
|
||||
ISiteDomainHelper siteDomainHelper,
|
||||
PublishedContentTypeCache contentTypeCache,
|
||||
MainDom mainDom,
|
||||
bool testing, bool enableRepositoryEvents)
|
||||
: base(publishedSnapshotAccessor, variationAccessor)
|
||||
: base(publishedSnapshotAccessor, variationContextAccessor)
|
||||
{
|
||||
_routesCache = new RoutesCache();
|
||||
_publishedContentTypeFactory = publishedContentTypeFactory;
|
||||
@@ -108,7 +108,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
_memberService = serviceContext.MemberService;
|
||||
_mediaService = serviceContext.MediaService;
|
||||
_userService = serviceContext.UserService;
|
||||
_systemDefaultCultureAccessor = systemDefaultCultureAccessor;
|
||||
_defaultCultureAccessor = defaultCultureAccessor;
|
||||
|
||||
_requestCache = requestCache;
|
||||
_globalSettings = globalSettings;
|
||||
@@ -153,7 +153,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
// the current caches, but that would mean creating an extra cache (StaticCache
|
||||
// probably) so better use RequestCache.
|
||||
|
||||
var domainCache = new DomainCache(_domainService, _systemDefaultCultureAccessor);
|
||||
var domainCache = new DomainCache(_domainService, _defaultCultureAccessor);
|
||||
|
||||
return new PublishedSnapshot(
|
||||
new PublishedContentCache(_xmlStore, domainCache, _requestCache, _globalSettings, _siteDomainHelper, _contentTypeCache, _routesCache, previewToken),
|
||||
|
||||
@@ -29,11 +29,11 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
factory.GetInstance<CacheHelper>().RequestCache,
|
||||
factory.GetInstance<UrlSegmentProviderCollection>(),
|
||||
factory.GetInstance<IPublishedSnapshotAccessor>(),
|
||||
factory.GetInstance<ICurrentVariationAccessor>(),
|
||||
factory.GetInstance<IVariationContextAccessor>(),
|
||||
factory.GetInstance<IDocumentRepository>(),
|
||||
factory.GetInstance<IMediaRepository>(),
|
||||
factory.GetInstance<IMemberRepository>(),
|
||||
factory.GetInstance<ISystemDefaultCultureAccessor>(),
|
||||
factory.GetInstance<IDefaultCultureAccessor>(),
|
||||
factory.GetInstance<ILogger>(),
|
||||
factory.GetInstance<IGlobalSettings>(),
|
||||
factory.GetInstance<ISiteDomainHelper>(),
|
||||
|
||||
@@ -22,14 +22,14 @@ namespace Umbraco.Web.Routing
|
||||
/// <param name="umbracoContext">The Umbraco context.</param>
|
||||
/// <param name="routingSettings">Routing settings.</param>
|
||||
/// <param name="urlProviders">The list of url providers.</param>
|
||||
/// <param name="variationAccessor">The current variation accessor.</param>
|
||||
public UrlProvider(UmbracoContext umbracoContext, IWebRoutingSection routingSettings, IEnumerable<IUrlProvider> urlProviders, ICurrentVariationAccessor variationAccessor)
|
||||
/// <param name="variationContextAccessor">The current variation accessor.</param>
|
||||
public UrlProvider(UmbracoContext umbracoContext, IWebRoutingSection routingSettings, IEnumerable<IUrlProvider> urlProviders, IVariationContextAccessor variationContextAccessor)
|
||||
{
|
||||
if (routingSettings == null) throw new ArgumentNullException(nameof(routingSettings));
|
||||
|
||||
_umbracoContext = umbracoContext ?? throw new ArgumentNullException(nameof(umbracoContext));
|
||||
_urlProviders = urlProviders;
|
||||
_variationAccessor = variationAccessor ?? throw new ArgumentNullException(nameof(variationAccessor));
|
||||
_variationContextAccessor = variationContextAccessor ?? throw new ArgumentNullException(nameof(variationContextAccessor));
|
||||
var provider = UrlProviderMode.Auto;
|
||||
Mode = provider;
|
||||
|
||||
@@ -44,20 +44,20 @@ namespace Umbraco.Web.Routing
|
||||
/// </summary>
|
||||
/// <param name="umbracoContext">The Umbraco context.</param>
|
||||
/// <param name="urlProviders">The list of url providers.</param>
|
||||
/// <param name="variationAccessor">The current variation accessor.</param>
|
||||
/// <param name="variationContextAccessor">The current variation accessor.</param>
|
||||
/// <param name="mode">An optional provider mode.</param>
|
||||
public UrlProvider(UmbracoContext umbracoContext, IEnumerable<IUrlProvider> urlProviders, ICurrentVariationAccessor variationAccessor, UrlProviderMode mode = UrlProviderMode.Auto)
|
||||
public UrlProvider(UmbracoContext umbracoContext, IEnumerable<IUrlProvider> urlProviders, IVariationContextAccessor variationContextAccessor, UrlProviderMode mode = UrlProviderMode.Auto)
|
||||
{
|
||||
_umbracoContext = umbracoContext ?? throw new ArgumentNullException(nameof(umbracoContext));
|
||||
_urlProviders = urlProviders;
|
||||
_variationAccessor = variationAccessor;
|
||||
_variationContextAccessor = variationContextAccessor;
|
||||
|
||||
Mode = mode;
|
||||
}
|
||||
|
||||
private readonly UmbracoContext _umbracoContext;
|
||||
private readonly IEnumerable<IUrlProvider> _urlProviders;
|
||||
private readonly ICurrentVariationAccessor _variationAccessor;
|
||||
private readonly IVariationContextAccessor _variationContextAccessor;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the provider url mode.
|
||||
@@ -203,7 +203,7 @@ namespace Umbraco.Web.Routing
|
||||
if (culture == null)
|
||||
{
|
||||
culture = content.ContentType.Variations.Has(ContentVariation.CultureNeutral) // fixme CultureSegment
|
||||
? _variationAccessor.CurrentVariation.Culture
|
||||
? _variationContextAccessor.VariationContext.Culture
|
||||
: null;
|
||||
}
|
||||
|
||||
|
||||
@@ -71,8 +71,8 @@ namespace Umbraco.Web.Runtime
|
||||
composition.Container.RegisterFrom<InstallerCompositionRoot>();
|
||||
|
||||
// register accessors for cultures
|
||||
composition.Container.RegisterSingleton<ISystemDefaultCultureAccessor, SystemDefaultCultureAccessor>();
|
||||
composition.Container.RegisterSingleton<ICurrentVariationAccessor, ThreadCultureCurrentVariationAccessor>();
|
||||
composition.Container.RegisterSingleton<IDefaultCultureAccessor, DefaultCultureAccessor>();
|
||||
composition.Container.RegisterSingleton<IVariationContextAccessor, ThreadCultureVariationContextAccessor>();
|
||||
|
||||
var typeLoader = composition.Container.GetInstance<TypeLoader>();
|
||||
var logger = composition.Container.GetInstance<ILogger>();
|
||||
@@ -218,7 +218,7 @@ namespace Umbraco.Web.Runtime
|
||||
IUmbracoSettingsSection umbracoSettings,
|
||||
IGlobalSettings globalSettings,
|
||||
IEntityService entityService,
|
||||
ICurrentVariationAccessor variationAccessor,
|
||||
IVariationContextAccessor variationContextAccessor,
|
||||
UrlProviderCollection urlProviders)
|
||||
{
|
||||
// setup mvc and webapi services
|
||||
@@ -256,7 +256,7 @@ namespace Umbraco.Web.Runtime
|
||||
umbracoSettings,
|
||||
urlProviders,
|
||||
globalSettings,
|
||||
variationAccessor);
|
||||
variationContextAccessor);
|
||||
|
||||
// ensure WebAPI is initialized, after everything
|
||||
GlobalConfiguration.Configuration.EnsureInitialized();
|
||||
|
||||
@@ -343,7 +343,7 @@
|
||||
<Compile Include="PropertyEditors\ValueConverters\MultiNodeTreePickerValueConverter.cs" />
|
||||
<Compile Include="PropertyEditors\ValueListUniqueValueValidator.cs" />
|
||||
<Compile Include="PublishedCache\IPublishedSnapshot.cs" />
|
||||
<Compile Include="PublishedCache\ISystemDefaultCultureAccessor.cs" />
|
||||
<Compile Include="PublishedCache\IDefaultCultureAccessor.cs" />
|
||||
<Compile Include="PublishedCache\NuCache\DataSource\BTree.ContentDataSerializer.cs" />
|
||||
<Compile Include="PublishedCache\NuCache\DataSource\BTree.ContentNodeKitSerializer.cs" />
|
||||
<Compile Include="PublishedCache\NuCache\DataSource\BTree.DictionaryOfCultureVariationSerializer.cs" />
|
||||
@@ -389,7 +389,7 @@
|
||||
<Compile Include="PublishedCache\NuCache\SnapDictionary.cs" />
|
||||
<Compile Include="PublishedCache\PublishedCacheBase.cs" />
|
||||
<Compile Include="PublishedCache\PublishedContentTypeCache.cs" />
|
||||
<Compile Include="PublishedCache\SystemDefaultCultureAccessor.cs" />
|
||||
<Compile Include="PublishedCache\DefaultCultureAccessor.cs" />
|
||||
<Compile Include="PublishedCache\UmbracoContextPublishedSnapshotAccessor.cs" />
|
||||
<Compile Include="PublishedCache\XmlPublishedCache\DictionaryPublishedContent.cs" />
|
||||
<Compile Include="PublishedCache\XmlPublishedCache\DomainCache.cs" />
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace Umbraco.Web
|
||||
IUmbracoSettingsSection umbracoSettings,
|
||||
IEnumerable<IUrlProvider> urlProviders,
|
||||
IGlobalSettings globalSettings,
|
||||
ICurrentVariationAccessor variationAccessor,
|
||||
IVariationContextAccessor variationContextAccessor,
|
||||
bool replace = false)
|
||||
{
|
||||
if (umbracoContextAccessor == null) throw new ArgumentNullException(nameof(umbracoContextAccessor));
|
||||
@@ -88,7 +88,7 @@ namespace Umbraco.Web
|
||||
|
||||
// create & assign to accessor, dispose existing if any
|
||||
umbracoContextAccessor.UmbracoContext?.Dispose();
|
||||
return umbracoContextAccessor.UmbracoContext = new UmbracoContext(httpContext, publishedSnapshotService, webSecurity, umbracoSettings, urlProviders, globalSettings, variationAccessor);
|
||||
return umbracoContextAccessor.UmbracoContext = new UmbracoContext(httpContext, publishedSnapshotService, webSecurity, umbracoSettings, urlProviders, globalSettings, variationContextAccessor);
|
||||
}
|
||||
|
||||
// initializes a new instance of the UmbracoContext class
|
||||
@@ -101,14 +101,14 @@ namespace Umbraco.Web
|
||||
IUmbracoSettingsSection umbracoSettings,
|
||||
IEnumerable<IUrlProvider> urlProviders,
|
||||
IGlobalSettings globalSettings,
|
||||
ICurrentVariationAccessor variationAccessor)
|
||||
IVariationContextAccessor variationContextAccessor)
|
||||
{
|
||||
if (httpContext == null) throw new ArgumentNullException(nameof(httpContext));
|
||||
if (publishedSnapshotService == null) throw new ArgumentNullException(nameof(publishedSnapshotService));
|
||||
if (webSecurity == null) throw new ArgumentNullException(nameof(webSecurity));
|
||||
if (umbracoSettings == null) throw new ArgumentNullException(nameof(umbracoSettings));
|
||||
if (urlProviders == null) throw new ArgumentNullException(nameof(urlProviders));
|
||||
CurrentVariationAccessor = variationAccessor ?? throw new ArgumentNullException(nameof(variationAccessor));
|
||||
VariationContextAccessor = variationContextAccessor ?? throw new ArgumentNullException(nameof(variationContextAccessor));
|
||||
_globalSettings = globalSettings ?? throw new ArgumentNullException(nameof(globalSettings));
|
||||
|
||||
// ensure that this instance is disposed when the request terminates, though we *also* ensure
|
||||
@@ -138,7 +138,7 @@ namespace Umbraco.Web
|
||||
//
|
||||
OriginalRequestUrl = GetRequestFromContext()?.Url ?? new Uri("http://localhost");
|
||||
CleanedUmbracoUrl = UriUtility.UriToUmbraco(OriginalRequestUrl);
|
||||
UrlProvider = new UrlProvider(this, umbracoSettings.WebRouting, urlProviders, variationAccessor);
|
||||
UrlProvider = new UrlProvider(this, umbracoSettings.WebRouting, urlProviders, variationContextAccessor);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -215,7 +215,7 @@ namespace Umbraco.Web
|
||||
/// </summary>
|
||||
public HttpContextBase HttpContext { get; }
|
||||
|
||||
public ICurrentVariationAccessor CurrentVariationAccessor { get; }
|
||||
public IVariationContextAccessor VariationContextAccessor { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Creates and caches an instance of a DomainHelper
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace Umbraco.Web
|
||||
internal IUmbracoDatabaseFactory DatabaseFactory { get; set; }
|
||||
|
||||
[Inject]
|
||||
internal ICurrentVariationAccessor CurrentVariationAccessor { get; set; }
|
||||
internal IVariationContextAccessor VariationContextAccessor { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -113,7 +113,7 @@ namespace Umbraco.Web
|
||||
UmbracoConfig.For.UmbracoSettings(),
|
||||
UrlProviders,
|
||||
GlobalSettings,
|
||||
CurrentVariationAccessor,
|
||||
VariationContextAccessor,
|
||||
true);
|
||||
}
|
||||
|
||||
|
||||
@@ -108,8 +108,8 @@ namespace umbraco
|
||||
/// </summary>
|
||||
/// <param name="content">The content.</param>
|
||||
/// <remarks>This is for <see cref="MacroController"/> usage only.</remarks>
|
||||
internal page(IContent content, ICurrentVariationAccessor variationAccessor)
|
||||
: this(new PagePublishedContent(content, variationAccessor))
|
||||
internal page(IContent content, IVariationContextAccessor variationContextAccessor)
|
||||
: this(new PagePublishedContent(content, variationContextAccessor))
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
@@ -409,7 +409,7 @@ namespace umbraco
|
||||
private readonly IPublishedProperty[] _properties;
|
||||
private readonly IPublishedContent _parent;
|
||||
private IReadOnlyDictionary<string, PublishedCultureInfos> _cultureInfos;
|
||||
private readonly ICurrentVariationAccessor _variationAccessor;
|
||||
private readonly IVariationContextAccessor _variationContextAccessor;
|
||||
|
||||
private static readonly IReadOnlyDictionary<string, PublishedCultureInfos> NoCultureInfos = new Dictionary<string, PublishedCultureInfos>();
|
||||
|
||||
@@ -418,13 +418,13 @@ namespace umbraco
|
||||
_id = id;
|
||||
}
|
||||
|
||||
public PagePublishedContent(IContent inner, ICurrentVariationAccessor variationAccessor)
|
||||
public PagePublishedContent(IContent inner, IVariationContextAccessor variationContextAccessor)
|
||||
{
|
||||
if (inner == null)
|
||||
throw new NullReferenceException("content");
|
||||
|
||||
_inner = inner;
|
||||
_variationAccessor = variationAccessor;
|
||||
_variationContextAccessor = variationContextAccessor;
|
||||
_id = _inner.Id;
|
||||
_key = _inner.Key;
|
||||
|
||||
@@ -480,7 +480,7 @@ namespace umbraco
|
||||
{
|
||||
// handle context culture
|
||||
if (culture == null)
|
||||
culture = _variationAccessor.CurrentVariation.Culture;
|
||||
culture = _variationContextAccessor.VariationContext.Culture;
|
||||
|
||||
// no invariant culture infos
|
||||
if (culture == "") return null;
|
||||
|
||||
Reference in New Issue
Block a user