public MethodSpec(MethodInfo methodInfo) { MethodInfo = methodInfo; var methodName = methodInfo.Name.Replace("_", "(.*)"); MethodPatternName = methodName.RemoveAccents().SplitCamelCase(); ParameterCollection = methodInfo.GetParameters().ToList(); ConvertAttributeCollection = methodInfo.GetAttributes<ParameterConvertAttribute>(); }
/// <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(); } }
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; }
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; }
/// <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 ) ); }