Files
Umbraco-CMS/src/Umbraco.Web/Mvc/UmbracoController.cs

99 lines
3.1 KiB
C#
Raw Normal View History

2018-06-29 19:52:40 +02:00
using System;
using System.Web;
using System.Web.Mvc;
using Microsoft.Owin;
using Umbraco.Core.Cache;
2018-07-06 17:36:33 +02:00
using Umbraco.Core.Composing;
2018-06-29 19:52:40 +02:00
using Umbraco.Core.Configuration;
using Umbraco.Core.Logging;
2018-07-20 09:49:05 +02:00
using Umbraco.Core;
2018-06-29 19:52:40 +02:00
using Umbraco.Core.Services;
using Umbraco.Web.Security;
namespace Umbraco.Web.Mvc
{
/// <summary>
/// Provides a base class for Umbraco controllers.
/// </summary>
public abstract class UmbracoController : Controller
{
// for debugging purposes
internal Guid InstanceId { get; } = Guid.NewGuid();
/// <summary>
/// Gets or sets the Umbraco context.
/// </summary>
public IGlobalSettings GlobalSettings { get; }
2018-06-29 19:52:40 +02:00
/// <summary>
/// Gets the Umbraco context.
/// </summary>
public virtual UmbracoContext UmbracoContext => UmbracoContextAccessor.UmbracoContext;
/// <summary>
/// Gets or sets the Umbraco context accessor.
2018-06-29 19:52:40 +02:00
/// </summary>
public virtual IUmbracoContextAccessor UmbracoContextAccessor { get; set; }
2018-06-29 19:52:40 +02:00
/// <summary>
/// Gets or sets the services context.
/// </summary>
public ServiceContext Services { get; }
2018-06-29 19:52:40 +02:00
/// <summary>
/// Gets or sets the application cache.
/// </summary>
public AppCaches AppCaches { get; }
2018-06-29 19:52:40 +02:00
/// <summary>
/// Gets or sets the logger.
/// </summary>
public ILogger Logger { get; }
2018-06-29 19:52:40 +02:00
/// <summary>
/// Gets or sets the profiling logger.
/// </summary>
2018-11-27 13:46:43 +01:00
public IProfilingLogger ProfilingLogger { get; set; }
2018-06-29 19:52:40 +02:00
protected IOwinContext OwinContext => Request.GetOwinContext();
/// <summary>
/// Gets the membership helper.
/// </summary>
public MembershipHelper Members => Umbraco.MembershipHelper;
/// <summary>
/// Gets the Umbraco helper.
/// </summary>
public UmbracoHelper Umbraco { get; }
2018-06-29 19:52:40 +02:00
/// <summary>
/// Gets the web security helper.
/// </summary>
public virtual WebSecurity Security => UmbracoContext.Security;
2018-07-06 17:36:33 +02:00
protected UmbracoController()
: this(
2018-11-28 11:05:41 +01:00
Current.Factory.GetInstance<IGlobalSettings>(),
Current.Factory.GetInstance<IUmbracoContextAccessor>(),
2018-11-28 11:05:41 +01:00
Current.Factory.GetInstance<ServiceContext>(),
2019-01-17 08:34:29 +01:00
Current.Factory.GetInstance<AppCaches>(),
Current.Factory.GetInstance<IProfilingLogger>(),
Current.Factory.GetInstance<UmbracoHelper>()
2018-07-06 17:36:33 +02:00
)
{
}
2018-07-06 17:36:33 +02:00
protected UmbracoController(IGlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ServiceContext services, AppCaches appCaches, IProfilingLogger profilingLogger, UmbracoHelper umbracoHelper)
2018-07-06 17:36:33 +02:00
{
GlobalSettings = globalSettings;
UmbracoContextAccessor = umbracoContextAccessor;
2018-07-06 17:36:33 +02:00
Services = services;
2019-01-18 15:05:20 +01:00
AppCaches = appCaches;
2019-02-01 15:44:32 +11:00
Logger = profilingLogger;
2018-07-06 17:36:33 +02:00
ProfilingLogger = profilingLogger;
Umbraco = umbracoHelper;
2018-07-06 17:36:33 +02:00
}
2018-06-29 19:52:40 +02:00
}
}