using System; using System.Web; using System.Web.Mvc; using System.Web.Routing; using System.Web.Services; using Umbraco.Core; using Umbraco.Core.Cache; using Umbraco.Core.Configuration; using Umbraco.Core.Logging; using Umbraco.Core.Persistence; using Umbraco.Core.Services; using Umbraco.Web.Composing; using Umbraco.Web.Security; namespace Umbraco.Web { /// /// An abstract web service class exposing common umbraco objects /// public abstract class UmbracoWebService : WebService { private UrlHelper _url; protected UmbracoWebService(IProfilingLogger profilingLogger, IUmbracoContextAccessor umbracoContextAccessor, UmbracoHelper umbraco, ServiceContext services, IGlobalSettings globalSettings) { Logger = profilingLogger; ProfilingLogger = profilingLogger; UmbracoContextAccessor = umbracoContextAccessor; Umbraco = umbraco; Services = services; GlobalSettings = globalSettings; } protected UmbracoWebService() : this(Current.ProfilingLogger, Current.UmbracoContextAccessor, Current.UmbracoHelper, Current.Services, Current.Configs.Global()) { } /// /// Gets the logger. /// public ILogger Logger { get; } /// /// Gets the ProfilingLogger. /// public IProfilingLogger ProfilingLogger { get; } /// /// Gets the Umbraco context. /// public UmbracoContext UmbracoContext => UmbracoContextAccessor.UmbracoContext; /// /// Gets the Umbraco context accessor. /// public IUmbracoContextAccessor UmbracoContextAccessor { get; } /// /// Gets the Umbraco helper. /// public UmbracoHelper Umbraco { get; } /// /// Gets the services context. /// public ServiceContext Services { get; } /// /// Gets the global settings. /// public IGlobalSettings GlobalSettings { get; } /// /// Gets the web security helper. /// public WebSecurity Security => UmbracoContext.Security; /// /// Gets the Url helper. /// /// This URL helper is created without any route data and an empty request context. public UrlHelper Url => _url ?? (_url = new UrlHelper(Context.Request.RequestContext)); } }