本文整理汇总了C#中ICustomAttributeProvider.SelectMany方法的典型用法代码示例。如果您正苦于以下问题:C# ICustomAttributeProvider.SelectMany方法的具体用法?C# ICustomAttributeProvider.SelectMany怎么用?C# ICustomAttributeProvider.SelectMany使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICustomAttributeProvider
的用法示例。
在下文中一共展示了ICustomAttributeProvider.SelectMany方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindResultFilters
/// <summary>
/// When implemented in a derived class, finds all pre and post <see cref="IResultFilter">result filters</see> that apply to the given action.
/// </summary>
/// <param name="action">The action.</param>
/// <param name="controllerContext">The controller context.</param>
/// <param name="actionName">Name of the action.</param>
/// <returns></returns>
protected override IEnumerable<IResultFilter> FindResultFilters(IActionDescriptor action, ControllerContext controllerContext, string actionName)
{
Guard.ArgumentNotNull(action, "action");
Guard.ArgumentNotNull(controllerContext, "controllerContext");
Guard.ArgumentNotNullOrEmpty(actionName, "actionName");
Guard.ArgumentIsOfType(action, typeof(DelegateActionDescriptor), "action");
var delegateDescriptor = (DelegateActionDescriptor)action;
var attributeSources = new ICustomAttributeProvider[] { delegateDescriptor.Method, controllerContext.Controller.GetType() };
var filters = attributeSources.SelectMany(x => x.GetCustomAttributes(true)).Select(x => x as IResultFilter).Where(x => x != null).ToList();
TraceSources.MagellanSource.TraceVerbose("DefaultActionInvoker found the following result filters for action '{0}': '{1}'.", actionName,
string.Join(", ", filters.Select(x => x.GetType().Name).ToArray())
);
return filters;
}