本文整理汇总了C#中System.Web.Mvc.ActionDescriptor类的典型用法代码示例。如果您正苦于以下问题:C# ActionDescriptor类的具体用法?C# ActionDescriptor怎么用?C# ActionDescriptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ActionDescriptor类属于System.Web.Mvc命名空间,在下文中一共展示了ActionDescriptor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: InvokeActionMethod
protected override ActionResult InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary<string, object> parameters)
{
var uowParam = actionDescriptor.GetParameters().FirstOrDefault(x => x.ParameterType == typeof(IUnitOfWork));
if (uowParam != null)
{
var connectionKey = controllerContext.Controller.GetType().GetCustomAttribute<ConnectionKeyAttribute>();
if (connectionKey == null)
throw new ArgumentNullException("connectionKey");
using (var connection = SqlConnections.NewByKey(connectionKey.Value))
using (var uow = new UnitOfWork(connection))
{
parameters[uowParam.ParameterName] = uow;
var result = base.InvokeActionMethod(controllerContext, actionDescriptor, parameters);
uow.Commit();
return result;
}
}
var cnnParam = actionDescriptor.GetParameters().FirstOrDefault(x => x.ParameterType == typeof(IDbConnection));
if (cnnParam != null)
{
var connectionKey = controllerContext.Controller.GetType().GetCustomAttribute<ConnectionKeyAttribute>();
if (connectionKey == null)
throw new ArgumentNullException("connectionKey");
using (var cnn = SqlConnections.NewByKey(connectionKey.Value))
{
parameters[cnnParam.ParameterName] = cnn;
return base.InvokeActionMethod(controllerContext, actionDescriptor, parameters);
}
}
return base.InvokeActionMethod(controllerContext, actionDescriptor, parameters);
}
开发者ID:CodeFork,项目名称:Serenity,代码行数:35,代码来源:ServiceEndpoint.cs
示例2: GetParameters
public static ParameterDescriptor[] GetParameters(ActionDescriptor actionDescriptor, MethodInfo methodInfo, ref ParameterDescriptor[] parametersCache)
{
ParameterDescriptor[] parameters = LazilyFetchParametersCollection(actionDescriptor, methodInfo, ref parametersCache);
// need to clone array so that user modifications aren't accidentally stored
return (ParameterDescriptor[])parameters.Clone();
}
开发者ID:huangw-t,项目名称:aspnetwebstack,代码行数:7,代码来源:ActionDescriptorHelper.cs
示例3: GetFilters
public IEnumerable<Filter> GetFilters(ControllerContext controllerContext, ActionDescriptor actionDescriptor)
{
return filterRegistry.Items.Where(item => item.IsMatching(controllerContext, actionDescriptor))
.SelectMany(item => item.BuildFilters())
.OrderBy(x => x.Order)
.ToArray();
}
开发者ID:rootzhou,项目名称:Core,代码行数:7,代码来源:FilterProvider.cs
示例4: CreateRouteEntry_IfDirectRouteProviderReturnsRouteWithEmptyActionDescriptors_Throws
public void CreateRouteEntry_IfDirectRouteProviderReturnsRouteWithEmptyActionDescriptors_Throws()
{
// Arrange
string areaPrefix = null;
string controllerPrefix = null;
Route route = new Route(url: null, routeHandler: null);
route.DataTokens = new RouteValueDictionary();
route.DataTokens.Add(RouteDataTokenKeys.Actions, new ActionDescriptor[0]);
ActionDescriptor[] originalActions = route.GetTargetActionDescriptors();
Assert.NotNull(originalActions); // Guard
Assert.Equal(0, originalActions.Length); // Guard
RouteEntry entry = new RouteEntry(name: null, route: route);
IDirectRouteFactory factory = CreateStubRouteFactory(entry);
ControllerDescriptor controllerDescriptor = CreateStubControllerDescriptor("IgnoreController");
ActionDescriptor actionDescriptor = CreateStubActionDescriptor(controllerDescriptor, "IgnoreAction");
IReadOnlyCollection<ActionDescriptor> actions = new ActionDescriptor[] { actionDescriptor };
IInlineConstraintResolver constraintResolver =
new Mock<IInlineConstraintResolver>(MockBehavior.Strict).Object;
// Act & Assert
string expectedMessage = "The route does not have any associated action descriptors. Routing requires " +
"that each direct route map to a non-empty set of actions.";
Assert.Throws<InvalidOperationException>(() => DefaultDirectRouteProvider.CreateRouteEntry(areaPrefix,
controllerPrefix, factory, actions, constraintResolver, targetIsAction: false), expectedMessage);
}
开发者ID:ahmetgoktas,项目名称:aspnetwebstack,代码行数:25,代码来源:DefaultDirectRouteProviderTest.cs
示例5: LazilyFetchParametersCollection
private static ParameterDescriptor[] LazilyFetchParametersCollection(ActionDescriptor actionDescriptor, MethodInfo methodInfo, ref ParameterDescriptor[] parametersCache)
{
return DescriptorUtil.LazilyFetchOrCreateDescriptors<ParameterInfo, ParameterDescriptor>(
cacheLocation: ref parametersCache,
initializer: methodInfo.GetParameters,
converter: parameterInfo => new ReflectedParameterDescriptor(parameterInfo, actionDescriptor));
}
开发者ID:haoduotnt,项目名称:aspnetwebstack,代码行数:7,代码来源:ActionDescriptorHelper.cs
示例6: GetFilters
protected override FilterInfo GetFilters(ControllerContext controllerContext, ActionDescriptor actionDescriptor)
{
var filterList = base.GetFilters(controllerContext, actionDescriptor);
filterList.ResultFilters.Add(new ViewProviderFilter(actionDescriptor.ActionName));
return filterList;
}
开发者ID:jrmitch120,项目名称:NerdDinner,代码行数:7,代码来源:DinnerActionInvoker.cs
示例7: ExecutedAttributesOf
private static IEnumerable<FilterAttribute> ExecutedAttributesOf(ActionDescriptor actionDescriptor)
{
var actionCustomAttributes = actionDescriptor.GetCustomAttributes(inherit: true).OfType<FilterAttribute>().OrderByDescending(attribute => attribute.Order);
var controllerCustomAttributes = actionDescriptor.ControllerDescriptor.GetCustomAttributes(inherit: true).OfType<FilterAttribute>().OrderByDescending(attribute => attribute.Order);
return actionCustomAttributes.Concat(controllerCustomAttributes);
}
开发者ID:TrangHoang,项目名称:Scratchpad,代码行数:7,代码来源:ActionFilterDispatcher.cs
示例8:
CachePolicy IMvcCachePolicyProvider.CreateCachePolicy( ControllerContext context, ActionDescriptor action, IDictionary<string, object> parameters )
{
if ( context.IsChildAction )
return null;
return _provider.CreateCachePolicy( context.HttpContext );
}
开发者ID:ajayumi,项目名称:Jumony,代码行数:7,代码来源:MvcCachePolicyProviderWrapper.cs
示例9: Get
public ControllerAction Get(ActionDescriptor actionDescriptor)
{
string httpVerb = actionDescriptor.GetHttpVerb();
return DB.ControllerActions.SingleOrDefault(r => r.Controller == actionDescriptor.ControllerDescriptor.ControllerName
&& r.Action == actionDescriptor.ActionName
&& r.HttpVerb == httpVerb);
}
开发者ID:ghostnguyen,项目名称:oams,代码行数:7,代码来源:ControllerActionRepository.cs
示例10: GetParamSignatureString
private string GetParamSignatureString(ActionDescriptor action)
{
var res = "(";
ReflectedActionDescriptor aD = action as ReflectedActionDescriptor;
foreach (var parameterDescriptor in aD.GetParameters())
{
res += parameterDescriptor.ParameterType.Name + " " + parameterDescriptor.ParameterName + ", ";
}
if (res == "(")
{
res += ")";
return res;
}
if (res.Substring(res.Length - 2) == ", ")
{
res = res.Substring(0, res.Length - 2);
res += ")";
}
return res;
}
开发者ID:Excepti0n,项目名称:radacode.com,代码行数:25,代码来源:PermissionsBasedAuthorizationFilter.cs
示例11: GetFilters
/// <summary>
/// Gets the filters for the specified request and action.
/// </summary>
/// <param name="controllerContext">The controller context.</param>
/// <param name="actionDescriptor">The action descriptor.</param>
/// <returns>The filters.</returns>
protected override FilterInfo GetFilters(ControllerContext controllerContext, ActionDescriptor actionDescriptor)
{
FilterInfo filterInfo = base.GetFilters(controllerContext, actionDescriptor);
foreach (IActionFilter filter in filterInfo.ActionFilters.Where(f => f != null))
{
this.Kernel.Inject(filter);
}
foreach (IAuthorizationFilter filter in filterInfo.AuthorizationFilters.Where(f => f != null))
{
this.Kernel.Inject(filter);
}
foreach (IExceptionFilter filter in filterInfo.ExceptionFilters.Where(f => f != null))
{
this.Kernel.Inject(filter);
}
foreach (IResultFilter filter in filterInfo.ResultFilters.Where(f => f != null))
{
this.Kernel.Inject(filter);
}
return filterInfo;
}
开发者ID:mrjavaguy,项目名称:Ninject.Web.Mvc,代码行数:31,代码来源:NinjectActionInvoker.cs
示例12: GetFilters
public IEnumerable<Filter> GetFilters(ControllerContext controllerContext,
ActionDescriptor actionDescriptor)
{
if ((actionDescriptor.ControllerDescriptor.ControllerType ==
typeof(ProductController) &&
(actionDescriptor.ActionName.Equals("Create",
StringComparison.InvariantCultureIgnoreCase) ||
actionDescriptor.ActionName.Equals("Edit",
StringComparison.InvariantCultureIgnoreCase)) &&
controllerContext.HttpContext.Request.HttpMethod == "POST") ||
(actionDescriptor.ControllerDescriptor.ControllerType ==
typeof(ProductVariantController) &&
(actionDescriptor.ActionName.Equals("Create",
StringComparison.InvariantCultureIgnoreCase) ||
actionDescriptor.ActionName.Equals("Edit",
StringComparison.InvariantCultureIgnoreCase)) &&
controllerContext.HttpContext.Request.HttpMethod == "POST"))
{
return new Filter[]
{
new Filter(_actionFilter, FilterScope.Action, null)
};
};
return new Filter[] { };
}
开发者ID:ventil8,项目名称:Nop.Plugin.Widgets.FloorPack,代码行数:26,代码来源:FloorPackFilterProvider.cs
示例13: GetFilters
public IEnumerable<Filter> GetFilters(ControllerContext controllerContext, ActionDescriptor actionDescriptor)
{
#if !DEBUG
yield return new Filter(new RedirectToHttpsAttribute(), FilterScope.Global, App.HttpsRedirectOrder);
#endif
yield return new Filter(new RequiresAllRoles("staff"), FilterScope.Global, App.ActiveAuthenticationOrder);
}
开发者ID:SharePointSusan,项目名称:Research-Data-Manager,代码行数:7,代码来源:FilterProvider.cs
示例14: CreateActionResult
protected override ActionResult CreateActionResult(ControllerContext controllerContext, ActionDescriptor actionDescriptor, object actionReturnValue)
{
if(!(actionReturnValue is ActionResult))
{
var controller = controllerContext.Controller;
if(actionReturnValue is Result)
{
if(actionReturnValue == Result.Successfully)
{
actionReturnValue = controller.Success();
}
else
{
var result = actionReturnValue as IValueResult;
if(result.IsSucceed)
{
actionReturnValue = controller.Success(result.GetValue());
}
else actionReturnValue = controller.Faild(result.Message, result.Status);
}
}
else
{
actionReturnValue = controller.Success(actionReturnValue);
}
}
return base.CreateActionResult(controllerContext, actionDescriptor, actionReturnValue);
}
开发者ID:supuy-ruby,项目名称:Aoite,代码行数:28,代码来源:AoiteAsyncActionInvoker.cs
示例15: GetFilters
/// <summary>
/// Retrieves information about the action filters.
/// </summary>
/// <param name="controllerContext">The controller context.</param>
/// <param name="actionDescriptor">The action descriptor.</param>
/// <returns>Information about the action filters.</returns>
protected override FilterInfo GetFilters(ControllerContext controllerContext, ActionDescriptor actionDescriptor)
{
//let the base class do the actual work as usual
var filterInfo = base.GetFilters(controllerContext, actionDescriptor);
//configure each collection of filters using the IApplicationContext
foreach (IActionFilter filter in filterInfo.ActionFilters.Where(f => f != null))
{
_context.ConfigureObject(filter, filter.GetType().FullName);
}
foreach (IAuthorizationFilter filter in filterInfo.AuthorizationFilters.Where(f => f != null))
{
_context.ConfigureObject(filter, filter.GetType().FullName);
}
foreach (IExceptionFilter filter in filterInfo.ExceptionFilters.Where(f => f != null))
{
_context.ConfigureObject(filter, filter.GetType().FullName);
}
foreach (IResultFilter filter in filterInfo.ResultFilters.Where(f => f != null))
{
_context.ConfigureObject(filter, filter.GetType().FullName);
}
return filterInfo;
}
开发者ID:khaliyo,项目名称:Spring.net-NHibernate.net-Asp.net-MVC-DWZ-,代码行数:34,代码来源:SpringActionInvoker.cs
示例16: CreateActionResult
protected override ActionResult CreateActionResult(ControllerContext controllerContext, ActionDescriptor actionDescriptor, object actionReturnValue)
{
var actionResult = (actionReturnValue as ActionResult)
?? _typedResultFactory.Build(controllerContext, actionReturnValue, actionDescriptor.ActionName);
return actionResult;
}
开发者ID:bnathyuw,项目名称:Restful-Simple-MVC,代码行数:7,代码来源:RestfulActionInvoker.cs
示例17: CreateCachePolicy
/// <summary>
/// 获取缓存策略
/// </summary>
/// <param name="context">MVC 请求上下文</param>
/// <param name="action">Action 信息</param>
/// <param name="parameters">Action 参数</param>
/// <returns>缓存策略</returns>
protected override CachePolicy CreateCachePolicy( ControllerContext context, ActionDescriptor action, IDictionary<string, object> parameters )
{
if ( CachePolicyProvider != null )
return CachePolicyProvider.CreateCachePolicy( context, action, parameters );
var httpMethod = context.HttpContext.Request.HttpMethod;
if ( !httpMethod.EqualsIgnoreCase( "get" ) && !httpMethod.EqualsIgnoreCase( "header" ) )//如果不是GET或Header请求,都不予缓存。
return null;
var provider = context.Controller as IMvcCachePolicyProvider;
if ( provider == null )
{
var _provider = context.Controller as ICachePolicyProvider;
if ( _provider != null )
provider = new MvcCachePolicyProviderWrapper( _provider );
}
var policy = provider.CreateCachePolicy( context, action, parameters );
if ( policy != null )
return policy;
return MvcEnvironment.CreateCachePolicy( context, action, parameters );
}
开发者ID:ajayumi,项目名称:Jumony,代码行数:38,代码来源:CachableAttribute.cs
示例18: GetFilters
/// <summary>
/// Gets all the filters that were registered with the <see cref="IFilterRegistry"/> instances.
/// </summary>
/// <param name="controllerContext"></param>
/// <param name="actionDescriptor"></param>
/// <returns></returns>
public IEnumerable<System.Web.Mvc.Filter> GetFilters(ControllerContext controllerContext, ActionDescriptor actionDescriptor) {
var globalList = GetGlobalFilters();
var controllerList = GetControllerFilters(controllerContext);
var actionList = GetActionFilters(actionDescriptor);
return globalList.Concat(controllerList).Concat(actionList);
}
开发者ID:calebjenkins,项目名称:mvcturbine,代码行数:13,代码来源:FilterRegistryProvider.cs
示例19: ShouldBeAbleToBuildWithFactoryUsingActionDescriptor
public void ShouldBeAbleToBuildWithFactoryUsingActionDescriptor(ActionDescriptor descriptor)
{
var testMessage = new TestMessage().AsActionMessage(descriptor);
Assert.Equal(descriptor.ActionName, testMessage.ActionName);
Assert.Equal(descriptor.ControllerDescriptor.ControllerName, testMessage.ControllerName);
}
开发者ID:GitObjects,项目名称:Glimpse,代码行数:7,代码来源:ActionMessageShould.cs
示例20: DynamicParameterDescriptor
/// <summary>
/// Create new descriptor
/// </summary>
/// <param name="actionDescriptor">Instance of the action descriptor</param>
/// <param name="parameterName">Name of the parameter</param>
/// <param name="parameterType">Type, mostly object</param>
/// <param name="defaultValue">Default value, by default null</param>
public DynamicParameterDescriptor(ActionDescriptor actionDescriptor, string parameterName, Type parameterType, object defaultValue)
{
this.actionDescriptor = actionDescriptor;
this.parameterName = parameterName;
this.parameterType = parameterType;
this.defaultValue = defaultValue;
}
开发者ID:simplic-systems,项目名称:ironpython-aspnet-mvc,代码行数:14,代码来源:DynamicParameterDescriptor.cs
注:本文中的System.Web.Mvc.ActionDescriptor类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论