2020-09-14 14:12:38 +02:00
|
|
|
|
using System.Web.Mvc;
|
2018-06-10 20:00:07 +01:00
|
|
|
|
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;
|
2018-06-10 20:00:07 +01:00
|
|
|
|
using Umbraco.Core.Logging;
|
2020-10-23 14:18:53 +11:00
|
|
|
|
using Umbraco.Core.Security;
|
2018-06-10 20:00:07 +01:00
|
|
|
|
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;
|
|
|
|
|
|
|
2020-11-24 12:52:48 +01:00
|
|
|
|
protected UmbracoWebService(ILogger logger, IProfilingLogger profilingLogger, IUmbracoContextAccessor umbracoContextAccessor, IBackOfficeSecurityAccessor backOfficeSecurityAccessor, ServiceContext services, GlobalSettings globalSettings)
|
2018-06-10 20:00:07 +01:00
|
|
|
|
{
|
2020-09-15 15:14:44 +02:00
|
|
|
|
Logger = logger;
|
2019-01-31 15:09:31 +11:00
|
|
|
|
ProfilingLogger = profilingLogger;
|
2019-02-15 10:10:20 +01:00
|
|
|
|
UmbracoContextAccessor = umbracoContextAccessor;
|
2020-11-24 12:52:48 +01:00
|
|
|
|
BackOfficeSecurityAccessor = backOfficeSecurityAccessor;
|
2019-01-31 15:09:31 +11:00
|
|
|
|
Services = services;
|
|
|
|
|
|
GlobalSettings = globalSettings;
|
|
|
|
|
|
}
|
2018-06-10 20:00:07 +01:00
|
|
|
|
|
2019-01-31 15:09:31 +11:00
|
|
|
|
protected UmbracoWebService()
|
2020-11-24 12:52:48 +01:00
|
|
|
|
: this(Current.Logger, Current.ProfilingLogger, Current.UmbracoContextAccessor, Current.BackOfficeSecurityAccessor, Current.Services,new GlobalSettings())
|
2019-01-31 15:09:31 +11:00
|
|
|
|
{
|
2018-06-10 20:00:07 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <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; }
|
2018-06-10 20:00:07 +01:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets the Umbraco context.
|
|
|
|
|
|
/// </summary>
|
2020-02-09 18:53:37 +01:00
|
|
|
|
public IUmbracoContext UmbracoContext => UmbracoContextAccessor.UmbracoContext;
|
2019-02-15 10:10:20 +01:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets the Umbraco context accessor.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public IUmbracoContextAccessor UmbracoContextAccessor { get; }
|
2018-06-10 20:00:07 +01:00
|
|
|
|
|
2020-11-24 12:52:48 +01:00
|
|
|
|
public IBackOfficeSecurityAccessor BackOfficeSecurityAccessor { get; }
|
|
|
|
|
|
|
2018-06-10 20:00:07 +01:00
|
|
|
|
/// <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; }
|
2018-06-10 20:00:07 +01:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets the web security helper.
|
|
|
|
|
|
/// </summary>
|
2020-11-24 12:52:48 +01:00
|
|
|
|
public IBackOfficeSecurity Security => BackOfficeSecurityAccessor.BackOfficeSecurity;
|
2018-06-10 20:00:07 +01:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2020-10-05 20:48:38 +02:00
|
|
|
|
/// Gets the URL helper.
|
2018-06-10 20:00:07 +01:00
|
|
|
|
/// </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));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|