Fix the build.
[castle.git] / MonoRail / Castle.MonoRail.Framework / IFilter.cs
blob5588c987986e6e2a8058206daf6a8b467d24b0b6
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 using System;
19 /// <summary>
20 /// Enum (flag) to indicate when the filter should
21 /// or is invoked.
22 /// </summary>
23 [Flags]
24 public enum ExecuteEnum
26 /// <summary>
27 /// The filter is invoked before the action.
28 /// </summary>
29 [Obsolete("Use ExecuteEnum.BeforeAction")]
30 Before = BeforeAction,
31 /// <summary>
32 /// The filter is invoked after the action.
33 /// </summary>
34 [Obsolete("Use ExecuteEnum.AfterRendering or ExecuteEnum.AfterAction")]
35 After = AfterRendering,
36 /// <summary>
37 /// The filter is invoked before and after the action.
38 /// </summary>
39 [Obsolete("Use ExecuteEnum.Always or combine the ExecuteEnum values you want")]
40 Around = BeforeAction | AfterAction,
42 /// <summary>
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
47 /// not be available.
48 /// </summary>
49 StartRequest = 0x01,
50 /// <summary>
51 /// The filter is invoked before the action.
52 /// </summary>
53 BeforeAction = 0x02,
54 /// <summary>
55 /// The filter is invoked after the action.
56 /// </summary>
57 AfterAction = 0x04,
58 /// <summary>
59 /// The filter is invoked after the rendering.
60 /// </summary>
61 AfterRendering = 0x08,
62 /// <summary>
63 /// The filter is invoked around all steps.
64 /// </summary>
65 Always = StartRequest | BeforeAction | AfterAction | AfterRendering
68 /// <summary>
69 /// Dictates the contract for filters. Implementors
70 /// should use filter to perform any logic before and/or
71 /// after the action invocation.
72 /// </summary>
73 public interface IFilter
75 /// <summary>
76 /// Implementors should perform they filter logic and
77 /// return <c>true</c> if the action should be processed.
78 /// </summary>
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 );
87 /// <summary>
88 /// Dictates a contract that the defining
89 /// FilterAttribute can be set
90 /// </summary>
91 public interface IFilterAttributeAware
93 /// <summary>
94 /// Sets the filter.
95 /// </summary>
96 /// <value>The filter.</value>
97 FilterAttribute Filter { set; }