diff --git a/src/Umbraco.Core/DependencyInjection/LightInjectExtensions.cs b/src/Umbraco.Core/DependencyInjection/LightInjectExtensions.cs index 78679613f9..9c673421f3 100644 --- a/src/Umbraco.Core/DependencyInjection/LightInjectExtensions.cs +++ b/src/Umbraco.Core/DependencyInjection/LightInjectExtensions.cs @@ -11,7 +11,7 @@ namespace Umbraco.Core.DependencyInjection /// public static void RegisterSingleton(this IServiceRegistry container, Func factory, string serviceName) { - container.Register(factory, new PerContainerLifetime()); + container.Register(factory, serviceName, new PerContainerLifetime()); } /// diff --git a/src/Umbraco.Core/DependencyInjection/ServicesCompositionRoot.cs b/src/Umbraco.Core/DependencyInjection/ServicesCompositionRoot.cs index c0131541e7..9eeefc5759 100644 --- a/src/Umbraco.Core/DependencyInjection/ServicesCompositionRoot.cs +++ b/src/Umbraco.Core/DependencyInjection/ServicesCompositionRoot.cs @@ -1,6 +1,10 @@ +using System; using System.Collections.Generic; +using System.IO; +using System.Linq; using LightInject; using Umbraco.Core.Events; +using Umbraco.Core.IO; using Umbraco.Core.Logging; using Umbraco.Core.Persistence; using Umbraco.Core.Persistence.UnitOfWork; @@ -27,8 +31,7 @@ namespace Umbraco.Core.DependencyInjection container.RegisterSingleton(); container.RegisterSingleton(); container.RegisterSingleton(); - container.RegisterSingleton(); - container.RegisterSingleton(); + container.RegisterSingleton(); container.RegisterSingleton(); container.RegisterSingleton(); container.RegisterSingleton(); @@ -44,8 +47,41 @@ namespace Umbraco.Core.DependencyInjection container.RegisterSingleton(); container.RegisterSingleton(); container.RegisterSingleton(); + container.RegisterSingleton(); container.RegisterSingleton(); container.RegisterSingleton(); + container.Register(factory => + { + var mainLangFolder = new DirectoryInfo(IOHelper.MapPath(SystemDirectories.Umbraco + "/config/lang/")); + var appPlugins = new DirectoryInfo(IOHelper.MapPath(SystemDirectories.AppPlugins)); + var configLangFolder = new DirectoryInfo(IOHelper.MapPath(SystemDirectories.Config + "/lang/")); + + var pluginLangFolders = appPlugins.Exists == false + ? Enumerable.Empty() + : appPlugins.GetDirectories() + .SelectMany(x => x.GetDirectories("Lang")) + .SelectMany(x => x.GetFiles("*.xml", SearchOption.TopDirectoryOnly)) + .Where(x => Path.GetFileNameWithoutExtension(x.FullName).Length == 5) + .Select(x => new LocalizedTextServiceSupplementaryFileSource(x, false)); + + //user defined langs that overwrite the default, these should not be used by plugin creators + var userLangFolders = configLangFolder.Exists == false + ? Enumerable.Empty() + : configLangFolder + .GetFiles("*.user.xml", SearchOption.TopDirectoryOnly) + .Where(x => Path.GetFileNameWithoutExtension(x.FullName).Length == 10) + .Select(x => new LocalizedTextServiceSupplementaryFileSource(x, true)); + + return new LocalizedTextServiceFileSources( + factory.GetInstance(), + factory.GetInstance().RuntimeCache, + mainLangFolder, + pluginLangFolders.Concat(userLangFolders)); + }); + container.RegisterSingleton(factory => new LocalizedTextService( + factory.GetInstance>(), + factory.GetInstance())); + //TODO: These are replaced in the web project - we need to declare them so that // something is wired up, just not sure this is very nice but will work for now. container.RegisterSingleton(); diff --git a/src/Umbraco.Core/Services/ServiceContext.cs b/src/Umbraco.Core/Services/ServiceContext.cs index 139e232abe..0887bc6a3e 100644 --- a/src/Umbraco.Core/Services/ServiceContext.cs +++ b/src/Umbraco.Core/Services/ServiceContext.cs @@ -109,6 +109,7 @@ namespace Umbraco.Core.Services /// /// /// + /// public ServiceContext( IContentService contentService = null, IMediaService mediaService = null, @@ -134,8 +135,10 @@ namespace Umbraco.Core.Services IMacroService macroService = null, IPublicAccessService publicAccessService = null, IExternalLoginService externalLoginService = null, - IMigrationEntryService migrationEntryService = null) + IMigrationEntryService migrationEntryService = null, + IServerRegistrationService serverRegistrationService = null) { + if (serverRegistrationService != null) _serverRegistrationService = new Lazy(() => serverRegistrationService); if (migrationEntryService != null) _migrationEntryService = new Lazy(() => migrationEntryService); if (externalLoginService != null) _externalLoginService = new Lazy(() => externalLoginService); if (auditService != null) _auditService = new Lazy(() => auditService); diff --git a/src/Umbraco.Web.UI/Umbraco/Views/AuthorizeUpgrade.cshtml b/src/Umbraco.Web.UI/Umbraco/Views/AuthorizeUpgrade.cshtml index 3d4f6baa7e..c17e69a2d5 100644 --- a/src/Umbraco.Web.UI/Umbraco/Views/AuthorizeUpgrade.cshtml +++ b/src/Umbraco.Web.UI/Umbraco/Views/AuthorizeUpgrade.cshtml @@ -11,7 +11,7 @@ @using Umbraco.Web @using Umbraco.Web.Editors @using umbraco -@inherits System.Web.Mvc.WebViewPage +@inherits System.Web.Mvc.WebViewPage @{ Layout = null; @@ -25,7 +25,7 @@ - + diff --git a/src/Umbraco.Web/Editors/BackOfficeController.cs b/src/Umbraco.Web/Editors/BackOfficeController.cs index 1c262b192c..856e1d9ec0 100644 --- a/src/Umbraco.Web/Editors/BackOfficeController.cs +++ b/src/Umbraco.Web/Editors/BackOfficeController.cs @@ -38,6 +38,11 @@ using Constants = Umbraco.Core.Constants; namespace Umbraco.Web.Editors { + public class AuthorizeUpgradeModel + { + public string Path { get; set; } + } + /// /// A controller to render out the default back office view and JS results /// @@ -84,7 +89,7 @@ namespace Umbraco.Web.Editors { return await RenderDefaultOrProcessExternalLoginAsync( //The default view to render when there is no external login info or errors - () => View(GlobalSettings.Path.EnsureEndsWith('/') + "Views/AuthorizeUpgrade.cshtml"), + () => View(GlobalSettings.Path.EnsureEndsWith('/') + "Views/AuthorizeUpgrade.cshtml", new AuthorizeUpgradeModel { Path = GlobalSettings.Path}), //The ActionResult to perform if external login is successful () => Redirect("/")); }