Added non-generic registration interface to IKernel and IWindsor to accommodate dynam...
[castle.git] / MonoRail / Castle.MonoRail.Framework / Filter.cs
blobdccb8d078cbdee6e8fb6f2e5a8bcc18baded9ebc
1 // Copyright 2004-2007 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 /// Base class for filters which dispatches to virtual methods
19 /// based on the <see cref="ExecuteEnum"/> value.
20 /// </summary>
21 public abstract class Filter : IFilter
23 /// <summary>
24 /// Implementors should perform they filter logic and
25 /// return <c>true</c> if the action should be processed.
26 /// </summary>
27 /// <param name="exec">When this filter is being invoked</param>
28 /// <param name="context">Current context</param>
29 /// <param name="controller">The controller instance</param>
30 /// <param name="controllerContext">The controller context.</param>
31 /// <returns>
32 /// <c>true</c> if the action
33 /// should be invoked, otherwise <c>false</c>
34 /// </returns>
35 public bool Perform(ExecuteEnum exec, IEngineContext context, IController controller, IControllerContext controllerContext)
37 if (exec == ExecuteEnum.AfterAction)
39 OnAfterAction(context, controller, controllerContext);
40 return true;
42 else if (exec == ExecuteEnum.AfterRendering)
44 OnAfterRendering(context, controller, controllerContext);
45 return true;
47 else // if (exec == ExecuteEnum.BeforeAction)
49 return OnBeforeAction(context, controller, controllerContext);
53 /// <summary>
54 /// Override this method if the filter was set to
55 /// handle <see cref="ExecuteEnum.AfterAction"/>
56 /// </summary>
57 /// <param name="context">The MonoRail request context</param>
58 /// <param name="controller">The controller instance</param>
59 /// <param name="controllerContext">The controller context.</param>
60 protected virtual void OnAfterAction(IEngineContext context, IController controller, IControllerContext controllerContext)
64 /// <summary>
65 /// Override this method if the filter was set to
66 /// handle <see cref="ExecuteEnum.AfterRendering"/>
67 /// </summary>
68 /// <param name="context">The MonoRail request context</param>
69 /// <param name="controller">The controller instance</param>
70 /// <param name="controllerContext">The controller context.</param>
71 protected virtual void OnAfterRendering(IEngineContext context, IController controller, IControllerContext controllerContext)
75 /// <summary>
76 /// Override this method if the filter was set to
77 /// handle <see cref="ExecuteEnum.BeforeAction"/>
78 /// </summary>
79 /// <param name="context">The MonoRail request context</param>
80 /// <param name="controller">The controller instance</param>
81 /// <param name="controllerContext">The controller context.</param>
82 /// <returns>
83 /// <c>true</c> if the request should proceed, otherwise <c>false</c>
84 /// </returns>
85 protected virtual bool OnBeforeAction(IEngineContext context, IController controller, IControllerContext controllerContext)
87 return true;