using System; using System.Web; using System.Web.Mvc; using Umbraco.Core.Cache; using Umbraco.Core.Logging; using Umbraco.Core.Services; using Umbraco.Web.Composing; using Umbraco.Web.Security; namespace Umbraco.Web { public abstract class UmbracoHttpHandler : IHttpHandler { private UrlHelper _url; protected UmbracoHttpHandler() : this(Current.UmbracoContextAccessor, Current.UmbracoHelper, Current.Services, Current.ProfilingLogger) { } protected UmbracoHttpHandler(IUmbracoContextAccessor umbracoContextAccessor, UmbracoHelper umbracoHelper, ServiceContext service, IProfilingLogger plogger) { UmbracoContextAccessor = umbracoContextAccessor; Logger = plogger; ProfilingLogger = plogger; Services = service; Umbraco = umbracoHelper; } public abstract void ProcessRequest(HttpContext context); public abstract bool IsReusable { get; } /// /// Gets the logger. /// public ILogger Logger { get; } /// /// Gets the ProfilingLogger. /// public IProfilingLogger ProfilingLogger { get; } /// /// 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 web security helper. /// public WebSecurity Security => UmbracoContextAccessor.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(HttpContext.Current.Request.RequestContext)); } }