public MethodBuilder BuildMethodContext(MethodBuilder builder, ServiceActionBuildContext context, Action <ServiceActionBuildContext, ILGenerator> action) { var il = builder.GetILGenerator(); action.Invoke(context, il); return(builder); }
public void Build(TypeBuilder builder, ServiceActionBuildContext context) { var paramTypes = context.ActionModel.Parameters.OrderBy(f => f.Position).Select(f => f.ParameterType).ToArray(); var methodBuilder = builder.DefineMethod(context.ActionModel.ActionName, MethodAttributes.Public, context.ActionModel.ReturnType, paramTypes); this.BuildAction(methodBuilder, context); }
public void BuildAction(MethodBuilder builder, ServiceActionBuildContext context) { var actionModel = context.ActionModel; this.BuildParameter(builder, actionModel); this.BuildAttribute(builder, actionModel.Attributes); this.BuildMethodContext(builder, context, actionModel.GeneratActionIL); }