Removed untyped contructor from ComponentRegistration and add a protected setter.
[castle.git] / MonoRail / Castle.MonoRail.Framework / BaseExecutableAction.cs
blob03d0a1e47b11682a8a1621f0f465e93de42ba09b
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 using System;
18 using Descriptors;
19 using Internal;
21 /// <summary>
22 ///
23 /// </summary>
24 public abstract class BaseExecutableAction : IExecutableAction
26 private readonly ActionMetaDescriptor actionMetaDescriptor;
28 /// <summary>
29 /// Initializes a new instance of the <see cref="BaseExecutableAction"/> class.
30 /// </summary>
31 /// <param name="actionMetaDescriptor">The action meta descriptor.</param>
32 protected BaseExecutableAction(ActionMetaDescriptor actionMetaDescriptor)
34 if (actionMetaDescriptor == null)
36 throw new ArgumentNullException("actionMetaDescriptor");
39 this.actionMetaDescriptor = actionMetaDescriptor;
42 /// <summary>
43 /// Gets the action meta descriptor.
44 /// </summary>
45 /// <value>The action meta descriptor.</value>
46 public ActionMetaDescriptor ActionMetaDescriptor
48 get { return actionMetaDescriptor; }
51 #region IExecutableAction
53 /// <summary>
54 /// Indicates that no rescues whatsoever should be applied to this action.
55 /// </summary>
56 /// <value></value>
57 /// <returns></returns>
58 public bool ShouldSkipRescues
60 get { return actionMetaDescriptor.SkipRescue != null; }
63 /// <summary>
64 /// Gets a value indicating whether no filter should run before execute the action.
65 /// </summary>
66 /// <value><c>true</c> if they should be skipped; otherwise, <c>false</c>.</value>
67 public bool ShouldSkipAllFilters
69 get
71 foreach(SkipFilterAttribute skip in actionMetaDescriptor.SkipFilters)
73 if (skip.BlanketSkip)
75 return true;
79 return false;
83 /// <summary>
84 /// Pendent
85 /// </summary>
86 /// <param name="filterType">Type of the filter.</param>
87 /// <returns></returns>
88 public bool ShouldSkipFilter(Type filterType)
90 foreach(SkipFilterAttribute skip in actionMetaDescriptor.SkipFilters)
92 if (skip.FilterType == filterType)
94 return true;
98 return false;
101 /// <summary>
102 /// Gets the layout override.
103 /// </summary>
104 /// <value>The layout override.</value>
105 public string[] LayoutOverride
109 if (actionMetaDescriptor.Layout == null)
111 return null;
113 return actionMetaDescriptor.Layout.LayoutNames;
117 /// <summary>
118 /// Gets the http method that the action requires before being executed.
119 /// </summary>
120 /// <value>The accessible through verb.</value>
121 public Verb AccessibleThroughVerb
125 if (actionMetaDescriptor.AccessibleThrough == null)
127 return Verb.Undefined;
130 return actionMetaDescriptor.AccessibleThrough.Verb;
134 /// <summary>
135 /// Gets a rescue descriptor for the exception type.
136 /// </summary>
137 /// <param name="exceptionType">Type of the exception.</param>
138 /// <returns></returns>
139 public RescueDescriptor GetRescueFor(Type exceptionType)
141 return RescueUtils.SelectBest(actionMetaDescriptor.Rescues, exceptionType);
144 /// <summary>
145 /// Gets the i18n related resource descriptors.
146 /// </summary>
147 /// <value>The resources.</value>
148 public ResourceDescriptor[] Resources
150 get { return actionMetaDescriptor.Resources; }
153 /// <summary>
154 /// Gets the return binder descriptor.
155 /// </summary>
156 /// <value>The return binder descriptor.</value>
157 public ReturnBinderDescriptor ReturnBinderDescriptor
159 get { return actionMetaDescriptor.ReturnDescriptor; }
162 /// <summary>
163 /// Gets the cache policy configurer.
164 /// </summary>
165 /// <value>The cache policy configurer.</value>
166 public ICachePolicyConfigurer CachePolicyConfigurer
168 get { return actionMetaDescriptor.CacheConfigurer; }
171 /// <summary>
172 /// Executes the action this instance represents.
173 /// </summary>
174 /// <param name="engineContext">The engine context.</param>
175 /// <param name="controller">The controller.</param>
176 /// <param name="context">The context.</param>
177 /// <returns></returns>
178 public abstract object Execute(IEngineContext engineContext, Controller controller, IControllerContext context);
180 #endregion