Moves culture dictionary implementation to Core instead of web since it has nothing to do with Web really, fixes tests

# Conflicts:
#	src/Umbraco.Core/Persistence/Repositories/Implement/UserRepository.cs
#	src/Umbraco.Core/Runtime/CoreInitialComposer.cs
#	src/Umbraco.Web/Editors/AuthenticationController.cs
#	src/Umbraco.Web/Install/InstallSteps/NewInstallStep.cs
This commit is contained in:
Shannon
2019-11-25 23:10:54 +11:00
parent 310597ce27
commit ed9a6d3f22
10 changed files with 13 additions and 26 deletions

View File

@@ -3,6 +3,7 @@ using System.IO;
using System.Linq;
using Umbraco.Core.Cache;
using Umbraco.Core.Configuration;
using Umbraco.Core.Dictionary;
using Umbraco.Core.Events;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;

View File

@@ -5,9 +5,8 @@ using System.Linq;
using Umbraco.Core.Cache;
using Umbraco.Core.Models;
using Umbraco.Core.Services;
using Umbraco.Web.Composing;
namespace Umbraco.Web.Dictionary
namespace Umbraco.Core.Dictionary
{
/// <summary>
@@ -18,7 +17,7 @@ namespace Umbraco.Web.Dictionary
/// The ILocalizationService is the service used for interacting with this data from the database which isn't all that fast
/// (even though there is caching involved, if there's lots of dictionary items the caching is not great)
/// </remarks>
public class DefaultCultureDictionary : Core.Dictionary.ICultureDictionary
public class DefaultCultureDictionary : ICultureDictionary
{
private readonly ILocalizationService _localizationService;
private readonly IAppCache _requestCache;

View File

@@ -1,7 +1,7 @@
using Umbraco.Core.Cache;
using Umbraco.Core.Services;
namespace Umbraco.Web.Dictionary
namespace Umbraco.Core.Dictionary
{
/// <summary>
/// A culture dictionary factory used to create an Umbraco.Core.Dictionary.ICultureDictionary.
@@ -9,7 +9,7 @@ namespace Umbraco.Web.Dictionary
/// <remarks>
/// In the future this will allow use to potentially store dictionary items elsewhere and allows for maximum flexibility.
/// </remarks>
internal class DefaultCultureDictionaryFactory : Umbraco.Core.Dictionary.ICultureDictionaryFactory
internal class DefaultCultureDictionaryFactory : ICultureDictionaryFactory
{
private readonly ILocalizationService _localizationService;
private readonly AppCaches _appCaches;
@@ -20,7 +20,7 @@ namespace Umbraco.Web.Dictionary
_appCaches = appCaches;
}
public Umbraco.Core.Dictionary.ICultureDictionary CreateDictionary()
public ICultureDictionary CreateDictionary()
{
return new DefaultCultureDictionary(_localizationService, _appCaches.RequestCache);
}

View File

@@ -44,8 +44,8 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
public UserRepository(IScopeAccessor scopeAccessor, AppCaches appCaches, ILogger logger, IMapperCollection mapperCollection, IGlobalSettings globalSettings)
: base(scopeAccessor, appCaches, logger)
{
_mapperCollection = mapperCollection;
_globalSettings = globalSettings;
_mapperCollection = mapperCollection ?? throw new ArgumentNullException(nameof(mapperCollection));
_globalSettings = globalSettings ?? throw new ArgumentNullException(nameof(globalSettings));
}
// for tests

View File

@@ -4,6 +4,7 @@ using Umbraco.Core.Composing;
using Umbraco.Core.Composing.CompositionExtensions;
using Umbraco.Core.Configuration;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.Dictionary;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.Manifest;
@@ -130,6 +131,8 @@ namespace Umbraco.Core.Runtime
// by default, register a noop rebuilder
composition.RegisterUnique<IPublishedSnapshotRebuilder, PublishedSnapshotRebuilder>();
composition.SetCultureDictionaryFactory<DefaultCultureDictionaryFactory>();
composition.Register(f => f.GetInstance<ICultureDictionaryFactory>().CreateDictionary(), Lifetime.Singleton);
}
}
}

View File

@@ -147,6 +147,8 @@
<Compile Include="Configuration\GlobalSettingsExtensions.cs" />
<Compile Include="ConventionsHelper.cs" />
<Compile Include="Deploy\IGridCellValueConnector.cs" />
<Compile Include="Dictionary\UmbracoCultureDictionary.cs" />
<Compile Include="Dictionary\UmbracoCultureDictionaryFactory.cs" />
<Compile Include="Events\ContentPublishedEventArgs.cs" />
<Compile Include="Events\ContentPublishingEventArgs.cs" />
<Compile Include="Events\ContentSavedEventArgs.cs" />

View File

@@ -31,9 +31,6 @@ namespace Umbraco.Tests.Models.Mapping
{
base.Compose();
Composition.RegisterUnique(f => Mock.Of<ICultureDictionaryFactory>());
Composition.Register(_ => Mock.Of<ILogger>());
Composition.ComposeFileSystems();
Composition.Register(_ => Mock.Of<IDataTypeService>());

View File

@@ -10,15 +10,5 @@ namespace Umbraco.Web.Runtime
[ComposeAfter(typeof(ICoreComposer))]
public class WebFinalComposer : ComponentComposer<WebFinalComponent>
{
public override void Compose(Composition composition)
{
base.Compose(composition);
// now that user composers have had a chance to register their own factory, we can add the result of the factory
// to the container.
composition.Register(f => f.GetInstance<ICultureDictionaryFactory>().CreateDictionary(), Lifetime.Singleton);
}
}
}

View File

@@ -20,7 +20,6 @@ using Umbraco.Web.Cache;
using Umbraco.Web.Composing.CompositionExtensions;
using Umbraco.Web.ContentApps;
using Umbraco.Web.Dashboards;
using Umbraco.Web.Dictionary;
using Umbraco.Web.Editors;
using Umbraco.Web.Features;
using Umbraco.Web.HealthCheck;
@@ -202,8 +201,6 @@ namespace Umbraco.Web.Runtime
composition.RegisterUnique<ISiteDomainHelper, SiteDomainHelper>();
composition.SetCultureDictionaryFactory<DefaultCultureDictionaryFactory>();
// register *all* checks, except those marked [HideFromTypeFinder] of course
composition.WithCollectionBuilder<HealthCheckCollectionBuilder>()
.Add(() => composition.TypeLoader.GetTypes<HealthCheck.HealthCheck>());

View File

@@ -1044,8 +1044,6 @@
<Compile Include="Models\PublishedContentBase.cs" />
<Compile Include="Mvc\AreaRegistrationExtensions.cs" />
<Compile Include="Mvc\QueryStringFilterAttribute.cs" />
<Compile Include="Dictionary\UmbracoCultureDictionary.cs" />
<Compile Include="Dictionary\UmbracoCultureDictionaryFactory.cs" />
<Compile Include="Mvc\MemberAuthorizeAttribute.cs" />
<Compile Include="Mvc\BackOfficeArea.cs" />
<Compile Include="Mvc\ControllerFactoryExtensions.cs" />