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
18 /// Delegate to create dynamic actions without the need for a separated class.
20 public delegate object ActionDelegate(IEngineContext engineContext
, IController controller
, IControllerContext controllerContext
);
23 /// Represents a dynamic action that forwards the
24 /// call to an <see cref="ActionDelegate"/>
26 public class DelegateDynamicAction
: IDynamicAction
28 private readonly ActionDelegate actionDelegate
;
31 /// Initializes a new instance of the <see cref="DelegateDynamicAction"/> class.
33 /// <param name="actionDelegate">The action delegate.</param>
34 public DelegateDynamicAction(ActionDelegate actionDelegate
)
36 this.actionDelegate
= actionDelegate
;
40 /// Implementors should perform the action
41 /// upon this invocation
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
);