Refactored the Kernel registration fluent interface to be more readable, better suppo...
[castle.git] / MonoRail / Castle.MonoRail.Framework / DelegateDynamicAction.cs
blob8ff81f927090d805027d9abfa04822b411dc638c
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 /// <summary>
18 /// Delegate to create dynamic actions without the need for a separated class.
19 /// </summary>
20 public delegate object ActionDelegate(IEngineContext engineContext, IController controller, IControllerContext controllerContext);
22 /// <summary>
23 /// Represents a dynamic action that forwards the
24 /// call to an <see cref="ActionDelegate"/>
25 /// </summary>
26 public class DelegateDynamicAction : IDynamicAction
28 private readonly ActionDelegate actionDelegate;
30 /// <summary>
31 /// Initializes a new instance of the <see cref="DelegateDynamicAction"/> class.
32 /// </summary>
33 /// <param name="actionDelegate">The action delegate.</param>
34 public DelegateDynamicAction(ActionDelegate actionDelegate)
36 this.actionDelegate = actionDelegate;
39 /// <summary>
40 /// Implementors should perform the action
41 /// upon this invocation
42 /// </summary>
43 /// <param name="engineContext">The engine context.</param>
44 /// <param name="controller">The controller.</param>
45 /// <param name="controllerContext">The controller context.</param>
46 public object Execute(IEngineContext engineContext, IController controller, IControllerContext controllerContext)
48 return actionDelegate(engineContext, controller, controllerContext);