Files
Umbraco-CMS/src/Umbraco.Web/UmbracoWebService.cs

78 lines
2.6 KiB
C#
Raw Normal View History

2020-09-14 14:12:38 +02:00
using System.Web.Mvc;
using System.Web.Services;
2020-09-28 08:26:21 +02:00
using Microsoft.Extensions.Logging;
2020-09-14 14:12:38 +02:00
using Umbraco.Core.Configuration.Models;
using Umbraco.Core.Logging;
2020-10-23 14:18:53 +11:00
using Umbraco.Core.Security;
using Umbraco.Core.Services;
using Umbraco.Web.Composing;
namespace Umbraco.Web
{
/// <summary>
/// An abstract web service class exposing common umbraco objects
/// </summary>
public abstract class UmbracoWebService : WebService
{
private UrlHelper _url;
protected UmbracoWebService(ILogger logger, IProfilingLogger profilingLogger, IUmbracoContextAccessor umbracoContextAccessor, IBackOfficeSecurityAccessor backOfficeSecurityAccessor, ServiceContext services, GlobalSettings globalSettings)
{
2020-09-15 15:14:44 +02:00
Logger = logger;
ProfilingLogger = profilingLogger;
UmbracoContextAccessor = umbracoContextAccessor;
BackOfficeSecurityAccessor = backOfficeSecurityAccessor;
Services = services;
GlobalSettings = globalSettings;
}
protected UmbracoWebService()
: this(Current.Logger, Current.ProfilingLogger, Current.UmbracoContextAccessor, Current.BackOfficeSecurityAccessor, Current.Services,new GlobalSettings())
{
}
/// <summary>
/// Gets the logger.
/// </summary>
public ILogger Logger { get; }
/// <summary>
/// Gets the ProfilingLogger.
/// </summary>
2018-11-27 10:37:33 +01:00
public IProfilingLogger ProfilingLogger { get; }
/// <summary>
/// Gets the Umbraco context.
/// </summary>
2020-02-09 18:53:37 +01:00
public IUmbracoContext UmbracoContext => UmbracoContextAccessor.UmbracoContext;
/// <summary>
/// Gets the Umbraco context accessor.
/// </summary>
public IUmbracoContextAccessor UmbracoContextAccessor { get; }
public IBackOfficeSecurityAccessor BackOfficeSecurityAccessor { get; }
/// <summary>
/// Gets the services context.
/// </summary>
public ServiceContext Services { get; }
/// <summary>
/// Gets the global settings.
/// </summary>
2020-09-14 14:12:38 +02:00
public GlobalSettings GlobalSettings { get; }
/// <summary>
/// Gets the web security helper.
/// </summary>
public IBackOfficeSecurity Security => BackOfficeSecurityAccessor.BackOfficeSecurity;
/// <summary>
2020-10-05 20:48:38 +02:00
/// Gets the URL helper.
/// </summary>
/// <remarks>This URL helper is created without any route data and an empty request context.</remarks>
public UrlHelper Url => _url ?? (_url = new UrlHelper(Context.Request.RequestContext));
}
}