Gets the Services IoC working!!
This commit is contained in:
@@ -11,7 +11,7 @@ namespace Umbraco.Core.DependencyInjection
|
||||
/// </summary>
|
||||
public static void RegisterSingleton<TService>(this IServiceRegistry container, Func<IServiceFactory, TService> factory, string serviceName)
|
||||
{
|
||||
container.Register<TService>(factory, new PerContainerLifetime());
|
||||
container.Register<TService>(factory, serviceName, new PerContainerLifetime());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -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<IPublicAccessService, PublicAccessService>();
|
||||
container.RegisterSingleton<ITaskService, TaskService>();
|
||||
container.RegisterSingleton<IDomainService, DomainService>();
|
||||
container.RegisterSingleton<IAuditService, AuditService>();
|
||||
container.RegisterSingleton<ILocalizedTextService, LocalizedTextService>();
|
||||
container.RegisterSingleton<IAuditService, AuditService>();
|
||||
container.RegisterSingleton<ITagService, TagService>();
|
||||
container.RegisterSingleton<IContentService, ContentService>();
|
||||
container.RegisterSingleton<IUserService, UserService>();
|
||||
@@ -44,8 +47,41 @@ namespace Umbraco.Core.DependencyInjection
|
||||
container.RegisterSingleton<IRelationService, RelationService>();
|
||||
container.RegisterSingleton<IMacroService, MacroService>();
|
||||
container.RegisterSingleton<IMemberTypeService, MemberTypeService>();
|
||||
container.RegisterSingleton<IMemberGroupService, MemberGroupService>();
|
||||
container.RegisterSingleton<INotificationService, NotificationService>();
|
||||
container.RegisterSingleton<IExternalLoginService, ExternalLoginService>();
|
||||
container.Register<LocalizedTextServiceFileSources>(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<LocalizedTextServiceSupplementaryFileSource>()
|
||||
: 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<LocalizedTextServiceSupplementaryFileSource>()
|
||||
: 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<ILogger>(),
|
||||
factory.GetInstance<CacheHelper>().RuntimeCache,
|
||||
mainLangFolder,
|
||||
pluginLangFolders.Concat(userLangFolders));
|
||||
});
|
||||
container.RegisterSingleton<ILocalizedTextService>(factory => new LocalizedTextService(
|
||||
factory.GetInstance<Lazy<LocalizedTextServiceFileSources>>(),
|
||||
factory.GetInstance<ILogger>()));
|
||||
|
||||
//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<IApplicationTreeService, EmptyApplicationTreeService>();
|
||||
|
||||
@@ -109,6 +109,7 @@ namespace Umbraco.Core.Services
|
||||
/// <param name="publicAccessService"></param>
|
||||
/// <param name="externalLoginService"></param>
|
||||
/// <param name="migrationEntryService"></param>
|
||||
/// <param name="serverRegistrationService"></param>
|
||||
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<IServerRegistrationService>(() => serverRegistrationService);
|
||||
if (migrationEntryService != null) _migrationEntryService = new Lazy<IMigrationEntryService>(() => migrationEntryService);
|
||||
if (externalLoginService != null) _externalLoginService = new Lazy<IExternalLoginService>(() => externalLoginService);
|
||||
if (auditService != null) _auditService = new Lazy<IAuditService>(() => auditService);
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
@using Umbraco.Web
|
||||
@using Umbraco.Web.Editors
|
||||
@using umbraco
|
||||
@inherits System.Web.Mvc.WebViewPage
|
||||
@inherits System.Web.Mvc.WebViewPage<Umbraco.Web.Editors.AuthorizeUpgradeModel>
|
||||
@{
|
||||
Layout = null;
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<base href="@GlobalSettings.Path.EnsureEndsWith('/')" />
|
||||
<base href="@Model.Path.EnsureEndsWith('/')" />
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
|
||||
@@ -38,6 +38,11 @@ using Constants = Umbraco.Core.Constants;
|
||||
|
||||
namespace Umbraco.Web.Editors
|
||||
{
|
||||
public class AuthorizeUpgradeModel
|
||||
{
|
||||
public string Path { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A controller to render out the default back office view and JS results
|
||||
/// </summary>
|
||||
@@ -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("/"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user