More working tests.
[castle.git] / MonoRail / Castle.MonoRail.Framework / ActionMethodExecutor.cs
blob5de4df73b161fe0cdeff11532ec9b00e0b01820f
1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle.MonoRail.Framework
17 using System.Collections.Generic;
18 using System.Reflection;
19 using Castle.MonoRail.Framework.Descriptors;
21 /// <summary>
22 /// Pendent
23 /// </summary>
24 public class ActionMethodExecutor : BaseExecutableAction
26 /// <summary>
27 /// Pendent
28 /// </summary>
29 protected readonly MethodInfo actionMethod;
31 /// <summary>
32 /// Initializes a new instance of the <see cref="ActionMethodExecutor"/> class.
33 /// </summary>
34 /// <param name="actionMethod">The action method.</param>
35 /// <param name="metaDescriptor">The meta descriptor.</param>
36 public ActionMethodExecutor(MethodInfo actionMethod, ActionMetaDescriptor metaDescriptor) : base(metaDescriptor)
38 this.actionMethod = actionMethod;
41 /// <summary>
42 /// Executes the action this instance represents.
43 /// </summary>
44 /// <param name="engineContext">The engine context.</param>
45 /// <param name="controller">The controller.</param>
46 /// <param name="context">The context.</param>
47 public override object Execute(IEngineContext engineContext, Controller controller, IControllerContext context)
49 return actionMethod.Invoke(controller, null);
53 /// <summary>
54 /// Pendent
55 /// </summary>
56 public class ActionMethodExecutorCompatible : ActionMethodExecutor
58 private readonly InvokeOnController invoke;
60 /// <summary>
61 /// Pendent
62 /// </summary>
63 public delegate object InvokeOnController(MethodInfo method, IRequest request, IDictionary<string, object> methodArgs);
65 /// <summary>
66 /// Initializes a new instance of the <see cref="ActionMethodExecutorCompatible"/> class.
67 /// </summary>
68 /// <param name="actionMethod">The action method.</param>
69 /// <param name="metaDescriptor">The meta descriptor.</param>
70 /// <param name="invoke">The invoke.</param>
71 public ActionMethodExecutorCompatible(MethodInfo actionMethod, ActionMetaDescriptor metaDescriptor, InvokeOnController invoke) :
72 base(actionMethod, metaDescriptor)
74 this.invoke = invoke;
77 /// <summary>
78 /// Executes the action this instance represents.
79 /// </summary>
80 /// <param name="engineContext">The engine context.</param>
81 /// <param name="controller">The controller.</param>
82 /// <param name="context">The context.</param>
83 public override object Execute(IEngineContext engineContext, Controller controller, IControllerContext context)
85 return invoke(actionMethod, engineContext.Request, context.CustomActionParameters);