Files
linux-packaging-mono/external/aspnetwebstack/src/System.Web.Http.WebHost/HttpControllerRouteHandler.cs
Jo Shields a575963da9 Imported Upstream version 3.6.0
Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
2014-08-13 10:39:27 +01:00

56 lines
2.0 KiB
C#

// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
using System.Web.Routing;
namespace System.Web.Http.WebHost
{
/// <summary>
/// A <see cref="IRouteHandler"/> that returns instances of <see cref="HttpControllerHandler"/> that
/// can pass requests to a given <see cref="HttpServer"/> instance.
/// </summary>
public class HttpControllerRouteHandler : IRouteHandler
{
private static readonly Lazy<HttpControllerRouteHandler> _instance =
new Lazy<HttpControllerRouteHandler>(() => new HttpControllerRouteHandler(), isThreadSafe: true);
/// <summary>
/// Initializes a new instance of the <see cref="HttpControllerRouteHandler"/> class.
/// </summary>
protected HttpControllerRouteHandler()
{
}
/// <summary>
/// Gets the singleton <see cref="HttpControllerRouteHandler"/> instance.
/// </summary>
public static HttpControllerRouteHandler Instance
{
get { return _instance.Value; }
}
/// <summary>
/// Provides the object that processes the request.
/// </summary>
/// <param name="requestContext">An object that encapsulates information about the request.</param>
/// <returns>
/// An object that processes the request.
/// </returns>
IHttpHandler IRouteHandler.GetHttpHandler(RequestContext requestContext)
{
return GetHttpHandler(requestContext);
}
/// <summary>
/// Provides the object that processes the request.
/// </summary>
/// <param name="requestContext">An object that encapsulates information about the request.</param>
/// <returns>
/// An object that processes the request.
/// </returns>
protected virtual IHttpHandler GetHttpHandler(RequestContext requestContext)
{
return new HttpControllerHandler(requestContext.RouteData);
}
}
}