1 // Copyright 2004-2007 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
20 /// Enum (flag) to indicate when the filter should
24 public enum ExecuteEnum
27 /// The filter is invoked before the action.
29 [Obsolete("Use ExecuteEnum.BeforeAction")]
30 Before
= BeforeAction
,
32 /// The filter is invoked after the action.
34 [Obsolete("Use ExecuteEnum.AfterRendering or ExecuteEnum.AfterAction")]
35 After
= AfterRendering
,
37 /// The filter is invoked before and after the action.
39 [Obsolete("Use ExecuteEnum.Always or combine the ExecuteEnum values you want")]
40 Around
= BeforeAction
| AfterAction
,
43 /// The filter is invoked
44 /// when the MonoRail request is started.
45 /// It is the best place to run authentication check
46 /// if you are using caching. However, the Session will
51 /// The filter is invoked before the action.
55 /// The filter is invoked after the action.
59 /// The filter is invoked after the rendering.
61 AfterRendering
= 0x08,
63 /// The filter is invoked around all steps.
65 Always
= StartRequest
| BeforeAction
| AfterAction
| AfterRendering
69 /// Dictates the contract for filters. Implementors
70 /// should use filter to perform any logic before and/or
71 /// after the action invocation.
73 public interface IFilter
76 /// Implementors should perform they filter logic and
77 /// return <c>true</c> if the action should be processed.
79 /// <param name="exec">When this filter is being invoked</param>
80 /// <param name="context">Current context</param>
81 /// <param name="controller">The controller instance</param>
82 /// <returns><c>true</c> if the action
83 /// should be invoked, otherwise <c>false</c></returns>
84 bool Perform( ExecuteEnum exec
, IRailsEngineContext context
, IController controller
);
88 /// Dictates a contract that the defining
89 /// FilterAttribute can be set
91 public interface IFilterAttributeAware
96 /// <value>The filter.</value>
97 FilterAttribute Filter { set; }