1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
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
7 // http://www.apache.org/licenses/LICENSE-2.0
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
;
24 public class ActionMethodExecutor
: BaseExecutableAction
29 protected readonly MethodInfo actionMethod
;
32 /// Initializes a new instance of the <see cref="ActionMethodExecutor"/> class.
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
;
42 /// Executes the action this instance represents.
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);
56 public class ActionMethodExecutorCompatible
: ActionMethodExecutor
58 private readonly InvokeOnController invoke
;
63 public delegate object InvokeOnController(MethodInfo method
, IRequest request
, IDictionary
<string, object> methodArgs
);
66 /// Initializes a new instance of the <see cref="ActionMethodExecutorCompatible"/> class.
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
)
78 /// Executes the action this instance represents.
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
);