本文整理汇总了C#中ActionDescriptor类的典型用法代码示例。如果您正苦于以下问题:C# ActionDescriptor类的具体用法?C# ActionDescriptor怎么用?C# ActionDescriptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ActionDescriptor类属于命名空间,在下文中一共展示了ActionDescriptor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ActionContext
/// <summary>
/// Creates a new <see cref="ActionContext"/>.
/// </summary>
/// <param name="httpContext">The <see cref="Http.HttpContext"/> for the current request.</param>
/// <param name="routeData">The <see cref="AspNet.Routing.RouteData"/> for the current request.</param>
/// <param name="actionDescriptor">The <see cref="Abstractions.ActionDescriptor"/> for the selected action.</param>
public ActionContext(
HttpContext httpContext,
RouteData routeData,
ActionDescriptor actionDescriptor)
: this(httpContext, routeData, actionDescriptor, new ModelStateDictionary())
{
}
开发者ID:huoxudong125,项目名称:Mvc,代码行数:13,代码来源:ActionContext.cs
示例2: Accept_RejectsActionMatchWithMissingParameter
public void Accept_RejectsActionMatchWithMissingParameter()
{
// Arrange
var action = new ActionDescriptor();
action.Parameters = new List<ParameterDescriptor>()
{
new ParameterDescriptor()
{
BindingInfo = new BindingInfo()
{
BindingSource = (new FromUriAttribute()).BindingSource,
},
Name = "id",
ParameterType = typeof(int),
},
};
var constraint = new OverloadActionConstraint();
var context = new ActionConstraintContext();
context.Candidates = new List<ActionSelectorCandidate>()
{
new ActionSelectorCandidate(action, new [] { constraint }),
};
context.CurrentCandidate = context.Candidates[0];
context.RouteContext = CreateRouteContext();
// Act & Assert
Assert.False(constraint.Accept(context));
}
开发者ID:AndersBillLinden,项目名称:Mvc,代码行数:31,代码来源:OverloadActionConstraintTest.cs
示例3: InvokeAction
public IActionResult InvokeAction(Controller controller, ActionDescriptor actionDescriptor)
{
var methodWithIntParameter =
controller.GetType()
.GetMethods()
.FirstOrDefault(
x =>
x.Name.ToLower() == actionDescriptor.ActionName.ToLower() && x.GetParameters().Length == 1
&& x.GetParameters()[0].ParameterType == typeof(string)
&& x.ReturnType == typeof(IActionResult));
if (methodWithIntParameter == null)
{
throw new HttpNotFoundException(
string.Format(
"Expected method with signature IActionResult {0}(string) in class {1}",
actionDescriptor.ActionName,
actionDescriptor.ControllerName));
}
try
{
var actionResult =
(IActionResult)methodWithIntParameter.Invoke(controller, new object[] { actionDescriptor.Parameter });
return actionResult;
}
catch (TargetInvocationException ex)
{
throw ex.InnerException;
}
}
开发者ID:exploitx3,项目名称:HighQualityCode,代码行数:30,代码来源:ActionInvoker.cs
示例4: InvokeAction
public IActionResult InvokeAction(Controller controller, ActionDescriptor actionDescriptor)
{
/*
* Child processes that use such C run-time functions as printf() and fprintf() can behave poorly when redirected.
* The C run-time functions maintain separate IO buffers. When redirected, these buffers might not be flushed immediately after each IO call.
* As a result, the output to the redirection pipe of a printf() call or the input from a getch() call is not flushed immediately and delays, sometimes-infinite delays occur.
* This problem is avoided if the child process flushes the IO buffers after each call to a C run-time IO function.
* Only the child process can flush its C run-time IO buffers. A process can flush its C run-time IO buffers by calling the fflush() function.
*/
var methodWithIntParameter = controller.GetType()
.GetMethods()
.FirstOrDefault(x => x.Name.ToLower() == actionDescriptor.ActionName.ToLower() &&
x.GetParameters().Length == 1 &&
x.GetParameters()[0].ParameterType == typeof(string) &&
x.ReturnType == typeof(IActionResult));
if (methodWithIntParameter == null)
{
throw new HttpNotFoundException(
string.Format(
"Expected method with signature IActionResult {0}(string) in class {1}Controller",
actionDescriptor.ActionName,
actionDescriptor.ControllerName));
}
try
{
var actionResult = (IActionResult)
methodWithIntParameter.Invoke(controller, new object[] { actionDescriptor.Parameter });
return actionResult;
}
catch (TargetInvocationException ex)
{
throw ex.InnerException;
}
}
开发者ID:MichaelaIvanova,项目名称:Telerik-Software-Academy,代码行数:35,代码来源:ActionInvoker.cs
示例5: InvokingConstructorWithHomeControllerShouldReturnDefaultActionAndParameter
public void InvokingConstructorWithHomeControllerShouldReturnDefaultActionAndParameter()
{
var actionDescriptor = new ActionDescriptor("/Home");
Assert.AreEqual("Index", actionDescriptor.ActionName);
Assert.AreEqual(string.Empty, actionDescriptor.Parameter);
}
开发者ID:MichaelaIvanova,项目名称:Telerik-Software-Academy,代码行数:7,代码来源:ActionDescriptorConstructorTests.cs
示例6: InvokingConstructorWithNormalUriShouldReturnProperlyControllerActionAndParameter
public void InvokingConstructorWithNormalUriShouldReturnProperlyControllerActionAndParameter()
{
var actionDescriptor = new ActionDescriptor("/Api/ResponseMessage/someParam123");
Assert.AreEqual("Api", actionDescriptor.ControllerName);
Assert.AreEqual("ResponseMessage", actionDescriptor.ActionName);
Assert.AreEqual("someParam123", actionDescriptor.Parameter);
}
开发者ID:MichaelaIvanova,项目名称:Telerik-Software-Academy,代码行数:8,代码来源:ActionDescriptorConstructorTests.cs
示例7: GetFilters
protected override FilterInfo GetFilters(ControllerContext controllerContext, ActionDescriptor actionDescriptor)
{
var rubyType = ((RubyController) controllerContext.Controller).RubyType;
var controllerFilters = (Hash) RubyEngine.CallMethod(rubyType, "action_filters");
var info = controllerFilters.ToFilterInfo("controller").MergedWith(actionDescriptor.GetFilters());
return info;
}
开发者ID:jschementi,项目名称:ironrubymvc,代码行数:8,代码来源:RubyControllerActionInvoker.cs
示例8: ActionContext
protected ActionContext(ControllerContext context, ActionDescriptor action)
{
Precondition.Require(context, () => Error.ArgumentNull("context"));
Precondition.Require(action, () => Error.ArgumentNull("action"));
_action = action;
_context = context;
}
开发者ID:radischevo,项目名称:Radischevo.Wahha,代码行数:8,代码来源:ActionContext.cs
示例9: GetFilters
public IEnumerable<Filter> GetFilters(ControllerContext context, ActionDescriptor action)
{
Precondition.Require(context, () => Error.ArgumentNull("context"));
Precondition.Require(action, () => Error.ArgumentNull("action"));
if (context.Controller != null)
yield return new Filter(context.Controller, FilterScope.First, Int32.MinValue);
}
开发者ID:radischevo,项目名称:Radischevo.Wahha,代码行数:8,代码来源:ControllerFilterProvider.cs
示例10: ReflectedParameterDescriptor
public ReflectedParameterDescriptor(ParameterInfo parameter, ActionDescriptor action)
: base()
{
Precondition.Require(parameter, () => Error.ArgumentNull("parameter"));
Precondition.Require(action, () => Error.ArgumentNull("action"));
_parameter = parameter;
_action = action;
_binding = new ReflectedParameterBinding(parameter);
}
开发者ID:radischevo,项目名称:Radischevo.Wahha,代码行数:10,代码来源:ReflectedParameterDescriptor.cs
示例11: GetActionAttributes
protected override IEnumerable<FilterAttribute> GetActionAttributes(ControllerContext controllerContext, ActionDescriptor actionDescriptor)
{
var attributes = base.GetActionAttributes(controllerContext, actionDescriptor);
foreach (var attribute in attributes)
{
_container.BuildUp(attribute.GetType(), attribute);
}
return attributes;
}
开发者ID:rex-dennis,项目名称:Bonobo-Git-Server,代码行数:10,代码来源:UnityFilterAttributeFilterProvider.cs
示例12: AuthenticationContext
public AuthenticationContext(ControllerContext controllerContext, ActionDescriptor actionDescriptor)
: base(controllerContext)
{
if (actionDescriptor == null)
{
throw new ArgumentNullException("actionDescriptor");
}
_actionDescriptor = actionDescriptor;
}
开发者ID:brianly,项目名称:aspnetwebstack,代码行数:10,代码来源:AuthenticationContext.cs
示例13: GetControllerAttributes
protected override System.Collections.Generic.IEnumerable<FilterAttribute> GetControllerAttributes(ControllerContext controllerContext, ActionDescriptor actionDescriptor)
{
var attributes = base.GetControllerAttributes(controllerContext, actionDescriptor);
foreach (var attribute in attributes)
{
_container.BuildUp(attribute);
}
return attributes;
}
开发者ID:atosorigin,项目名称:AtosMvcStarterKit,代码行数:10,代码来源:StructureMapFilterAttributeFilterProvider.cs
示例14: OnBeforeAction
public void OnBeforeAction(ActionDescriptor actionDescriptor, HttpContext httpContext, RouteData routeData)
{
string name = this.GetNameFromRouteContext(routeData);
var telemetry = httpContext.RequestServices.GetService<RequestTelemetry>();
if (!string.IsNullOrEmpty(name) && telemetry != null && telemetry is RequestTelemetry)
{
name = httpContext.Request.Method + " " + name;
((RequestTelemetry)telemetry).Name = name;
}
}
开发者ID:jango2015,项目名称:ApplicationInsights-aspnet5,代码行数:11,代码来源:OperationNameTelemetryInitializer.cs
示例15: Bind
/// <summary>
/// Executes binding action to context
/// </summary>
/// <param name="action"> </param>
/// <param name="context"> </param>
public void Bind(ActionDescriptor action, IMvcContext context) {
lock (this) {
if (null == _binders) {
Setup(action.ActionType);
}
if (_binders != null) {
foreach (var binder in _binders) {
binder.Bind(action.Action, context);
}
}
}
}
开发者ID:Qorpent,项目名称:qorpent.sys,代码行数:17,代码来源:DefaultActionBinder.cs
示例16: GetApiDescription_IgnoresNonReflectedActionDescriptor
public void GetApiDescription_IgnoresNonReflectedActionDescriptor()
{
// Arrange
var action = new ActionDescriptor();
action.SetProperty(new ApiDescriptionActionData());
// Act
var descriptions = GetApiDescriptions(action);
// Assert
Assert.Empty(descriptions);
}
开发者ID:notami18,项目名称:Mvc,代码行数:12,代码来源:DefaultApiDescriptionProviderTest.cs
示例17: GetFilters
protected override FilterInfo GetFilters(
ControllerContext controllerContext,
ActionDescriptor actionDescriptor)
{
var filterInfo =
base.GetFilters(controllerContext,
actionDescriptor);
filterInfo.ExceptionFilters.Add(this.filter);
return filterInfo;
}
开发者ID:TwistedHighway,项目名称:AliceApi,代码行数:12,代码来源:ErrorHandlingActionInvoker.cs
示例18: HarvestableResourceDescriptor
public HarvestableResourceDescriptor(ItemDefinition itmDef, ActionDescriptor action, int quantity)
{
if (itmDef == null)
throw new ArgumentNullException("itmDef");
if (action == null)
throw new ArgumentNullException("action");
harvestedItem = itmDef;
performedAction = action;
quantityPerHarvest = quantity;
}
开发者ID:rauchc,项目名称:Calindor,代码行数:12,代码来源:Resources.cs
示例19: AuthenticationContext
/// <summary>Initializes a new instance of the <see cref="AuthenticationContext"/> class.</summary>
/// <param name="controllerContext">The controller context.</param>
/// <param name="actionDescriptor">The action descriptor.</param>
/// <param name="principal">The current principal.</param>
public AuthenticationContext(ControllerContext controllerContext, ActionDescriptor actionDescriptor,
IPrincipal principal)
: base(controllerContext)
{
if (actionDescriptor == null)
{
throw new ArgumentNullException("actionDescriptor");
}
ActionDescriptor = actionDescriptor;
Principal = principal;
}
开发者ID:KevMoore,项目名称:aspnetwebstack,代码行数:16,代码来源:AuthenticationContext.cs
示例20: IsValidForRequest
public override bool IsValidForRequest(RouteContext routeContext, ActionDescriptor action)
{
if (routeContext.RouteData.Values.ContainsKey(Name))
return false;
if (routeContext.RouteData.DataTokens.ContainsKey(Name))
return false;
if (routeContext.HttpContext.Request.Query.ContainsKey(Name))
return false;
return true;
}
开发者ID:qbikez,项目名称:Odachi,代码行数:13,代码来源:NoRequestValueAttribute.cs
注:本文中的ActionDescriptor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论