本文整理汇总了C#中System.Reflection.MethodInfo.GetAttributes方法的典型用法代码示例。如果您正苦于以下问题:C# MethodInfo.GetAttributes方法的具体用法?C# MethodInfo.GetAttributes怎么用?C# MethodInfo.GetAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.MethodInfo
的用法示例。
在下文中一共展示了MethodInfo.GetAttributes方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MethodSpec
public MethodSpec(MethodInfo methodInfo)
{
MethodInfo = methodInfo;
var methodName = methodInfo.Name.Replace("_", "(.*)");
MethodPatternName = methodName.RemoveAccents().SplitCamelCase();
ParameterCollection = methodInfo.GetParameters().ToList();
ConvertAttributeCollection = methodInfo.GetAttributes<ParameterConvertAttribute>();
}
示例2: ScriptAction
/// <summary>
/// Initializes a new instance of the <see cref="ScriptAction"/> class.
/// </summary>
/// <param name="method">The method.</param>
public ScriptAction(MethodInfo method, Type type)
{
this.Method = method;
this.ActionClass = type;
this.Title = method.GetAttribute<ActionTitle>();
this.Config = method.GetAttribute<ActionConfig>();
this.Examples = method.GetAttribute<ActionExamples>();
this.Params = method.GetAttributes<ActionParameter>();
if (this.Params != null) { this.Params = (from pr in this.Params orderby pr.Index ascending select pr).ToArray(); }
}
示例3: DefineOverrideMethod
private static MethodBuilder DefineOverrideMethod(this TypeBuilder typeBuilder, MethodInfo method)
{
var builder = typeBuilder.DefineMethod(method.Name, method.GetAttributes(), method.CallingConvention, method.ReturnType, method.GetParameterTypes().ToArray());
if (method.IsGenericMethod)
{
return builder.DefineGeneric(method);
}
return builder;
}
示例4: OperationDescriptor
internal OperationDescriptor(MethodInfo method, string operationName, IServiceDescriptor serviceDescriptor)
{
Extensions = new Dictionary<string, object>(StringComparer.InvariantCultureIgnoreCase);
Method = method;
ParameterNames = method.GetParameters().Select(p => p.Name).ToArray();
OperationName = operationName;
ServiceDescriptor = serviceDescriptor;
Executor = method.GetFunc();
NameSelector = method.GetAttribute<OperationNameSelectorAttribute>(true);
MethodSelector = method.GetAttribute<OperationSelectorAttribute>(true);
Filters = method.GetAttributes<OperationFilterAttribute>(true).Distinct().ToArray();
Bindings = method.GetParameters().Select(p => new BindingInfo( p)).ToArray();
var descAttr = Method.GetAttribute<DescriptionAttribute>(true);
if (descAttr != null)
Description = descAttr.Description;
}
示例5: CreateAction
/// <summary>
/// Creates the action.
/// </summary>
/// <param name="targetType">Type of the target.</param>
/// <param name="targetFilters">The target filters.</param>
/// <param name="methodInfo">The method info.</param>
/// <returns>The action.</returns>
protected virtual IAction CreateAction(Type targetType, IFilterManager targetFilters, MethodInfo methodInfo)
{
var builder = methodInfo.GetAttributes<IActionFactory>(true)
.FirstOrDefault() ?? new ActionAttribute();
return builder.Create(
new ActionCreationContext(
serviceLocator,
methodFactory,
messageBinder,
conventionManager,
targetType,
targetFilters,
methodInfo
)
);
}