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
24 public abstract class BaseExecutableAction
: IExecutableAction
26 private readonly ActionMetaDescriptor actionMetaDescriptor
;
29 /// Initializes a new instance of the <see cref="BaseExecutableAction"/> class.
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
;
43 /// Gets the action meta descriptor.
45 /// <value>The action meta descriptor.</value>
46 public ActionMetaDescriptor ActionMetaDescriptor
48 get { return actionMetaDescriptor; }
51 #region IExecutableAction
54 /// Indicates that no rescues whatsoever should be applied to this action.
57 /// <returns></returns>
58 public bool ShouldSkipRescues
60 get { return actionMetaDescriptor.SkipRescue != null; }
64 /// Gets a value indicating whether no filter should run before execute the action.
66 /// <value><c>true</c> if they should be skipped; otherwise, <c>false</c>.</value>
67 public bool ShouldSkipAllFilters
71 foreach(SkipFilterAttribute skip
in actionMetaDescriptor
.SkipFilters
)
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
)
102 /// Gets the layout override.
104 /// <value>The layout override.</value>
105 public string[] LayoutOverride
109 if (actionMetaDescriptor
.Layout
== null)
113 return actionMetaDescriptor
.Layout
.LayoutNames
;
118 /// Gets the http method that the action requires before being executed.
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
;
135 /// Gets a rescue descriptor for the exception type.
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
);
145 /// Gets the i18n related resource descriptors.
147 /// <value>The resources.</value>
148 public ResourceDescriptor
[] Resources
150 get { return actionMetaDescriptor.Resources; }
154 /// Gets the return binder descriptor.
156 /// <value>The return binder descriptor.</value>
157 public ReturnBinderDescriptor ReturnBinderDescriptor
159 get { return actionMetaDescriptor.ReturnDescriptor; }
163 /// Gets the cache policy configurer.
165 /// <value>The cache policy configurer.</value>
166 public ICachePolicyConfigurer CachePolicyConfigurer
168 get { return actionMetaDescriptor.CacheConfigurer; }
172 /// Executes the action this instance represents.
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
);