using System; using System.Web; using System.Web.Mvc; using System.Web.Routing; using Umbraco.Core; using Umbraco.Core.Cache; using Umbraco.Core.Logging; using Umbraco.Core.Persistence; 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.UmbracoContext, Current.Services) { } protected UmbracoHttpHandler(UmbracoContext umbracoContext, ServiceContext services) { if (umbracoContext == null) throw new ArgumentNullException(nameof(umbracoContext)); UmbracoContext = umbracoContext; Umbraco = new UmbracoHelper(umbracoContext, services); // fixme inject somehow Logger = Current.Logger; ProfilingLogger = Current.ProfilingLogger; Services = Current.Services; } public abstract void ProcessRequest(HttpContext context); public abstract bool IsReusable { get; } /// /// Gets the logger. /// public ILogger Logger { get; } /// /// Gets the ProfilingLogger. /// public ProfilingLogger ProfilingLogger { get; } /// /// Gets the Umbraco context. /// public UmbracoContext UmbracoContext { 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 => 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)); } }