// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.AspNet.Mvc.Actions;
using Microsoft.AspNet.Routing;
namespace Microsoft.AspNet.Mvc.ActionConstraints
{
///
/// Base class for attributes which can implement conditional logic to enable or disable an action
/// for a given request. See .
///
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
public abstract class ActionMethodSelectorAttribute : Attribute, IActionConstraint
{
///
public int Order { get; set; }
///
public bool Accept(ActionConstraintContext context)
{
return IsValidForRequest(context.RouteContext, context.CurrentCandidate.Action);
}
///
/// Determines whether the action selection is valid for the specified route context.
///
/// The route context.
/// Information about the action.
///
/// if the action selection is valid for the specified context;
/// otherwise, .
///
public abstract bool IsValidForRequest(RouteContext routeContext, ActionDescriptor action);
}
}