// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.AspNet.Http;
using Microsoft.AspNet.Mvc.ModelBinding;
using Microsoft.AspNet.Routing;
using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc
{
///
/// Context object for execution of action which has been selected as part of an HTTP request.
///
public class ActionContext
{
///
/// Creates a empty .
///
///
/// The default constructor is provided for unit test purposes only.
///
public ActionContext()
{
ModelState = new ModelStateDictionary();
}
///
/// Creates a new .
///
/// The to copy.
public ActionContext([NotNull] ActionContext actionContext)
: this(actionContext.HttpContext, actionContext.RouteData, actionContext.ActionDescriptor)
{
ModelState = actionContext.ModelState;
}
///
/// Creates a new .
///
/// The for the current request.
/// The for the current request.
/// The for the selected action.
public ActionContext(
[NotNull] HttpContext httpContext,
[NotNull] RouteData routeData,
[NotNull] ActionDescriptor actionDescriptor)
: this(httpContext, routeData, actionDescriptor, new ModelStateDictionary())
{
}
///
/// Creates a new .
///
/// The for the current request.
/// The for the current request.
/// The for the selected action.
/// The .
public ActionContext(
[NotNull] HttpContext httpContext,
[NotNull] RouteData routeData,
[NotNull] ActionDescriptor actionDescriptor,
[NotNull] ModelStateDictionary modelState)
{
HttpContext = httpContext;
RouteData = routeData;
ActionDescriptor = actionDescriptor;
ModelState = modelState;
}
///
/// Gets or sets the for the selected action.
///
///
/// The property setter is provided for unit test purposes only.
///
public ActionDescriptor ActionDescriptor
{
get; set;
}
///
/// Gets or sets the for the current request.
///
///
/// The property setter is provided for unit test purposes only.
///
public HttpContext HttpContext
{
get; set;
}
///
/// Gets the .
///
public ModelStateDictionary ModelState
{
get;
}
///
/// Gets or sets the for the current request.
///
///
/// The property setter is provided for unit test purposes only.
///
public RouteData RouteData
{
get; set;
}
}
}