using System;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using Umbraco.Core;
using Umbraco.Core.Logging;
using Umbraco.Core.Services;
using Umbraco.Web.Security;
namespace Umbraco.Web.WebServices
{
public abstract class UmbracoHttpHandler : IHttpHandler
{
public abstract void ProcessRequest(HttpContext context);
public abstract bool IsReusable { get; }
protected UmbracoHttpHandler()
: this(UmbracoContext.Current)
{
}
protected UmbracoHttpHandler(UmbracoContext umbracoContext)
{
if (umbracoContext == null) throw new ArgumentNullException("umbracoContext");
UmbracoContext = umbracoContext;
Umbraco = new UmbracoHelper(umbracoContext);
}
///
/// Returns the current ApplicationContext
///
public ApplicationContext ApplicationContext
{
get { return UmbracoContext.Application; }
}
///
/// Returns an ILogger
///
public ILogger Logger
{
get { return ProfilingLogger.Logger; }
}
///
/// Returns a ProfilingLogger
///
public ProfilingLogger ProfilingLogger
{
get { return UmbracoContext.Application.ProfilingLogger; }
}
///
/// Returns the current UmbracoContext
///
public UmbracoContext UmbracoContext { get; private set; }
///
/// Returns an UmbracoHelper object
///
public UmbracoHelper Umbraco { get; private set; }
private UrlHelper _url;
///
/// Returns a UrlHelper
///
///
/// This URL helper is created without any route data and an empty request context
///
public UrlHelper Url
{
get { return _url ?? (_url = new UrlHelper(HttpContext.Current.Request.RequestContext)); }
}
///
/// Returns a ServiceContext
///
public ServiceContext Services
{
get { return ApplicationContext.Services; }
}
///
/// Returns a DatabaseContext
///
public DatabaseContext DatabaseContext
{
get { return ApplicationContext.DatabaseContext; }
}
///
/// Returns a WebSecurity instance
///
public WebSecurity Security
{
get { return UmbracoContext.Security; }
}
}
}