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
.Internal
18 using System
.Collections
;
19 using System
.Collections
.Generic
;
20 using System
.Collections
.Specialized
;
21 using System
.Reflection
;
24 /// Holds all meta information a controller might
25 /// expose, so the attributes are collected only once.
26 /// This approach translates into a huge performance boost.
29 public class ControllerMetaDescriptor
: BaseMetaDescriptor
31 private DefaultActionAttribute defaultAction
;
32 private HelperDescriptor
[] helpers
;
33 private FilterDescriptor
[] filters
;
34 private TransformFilterDescriptor
[] transformFilters
;
35 private Dictionary
<MethodInfo
, ActionMetaDescriptor
> actionMetaDescriptors
= new Dictionary
<MethodInfo
, ActionMetaDescriptor
>();
36 private IList scaffoldings
= new ArrayList();
37 private IList
<Type
> actionProviders
= new List
<Type
>();
38 private IList
<MethodInfo
> ajaxActions
= new List
<MethodInfo
>();
39 private IDictionary actions
= new HybridDictionary(true);
42 /// Initializes a new instance of the <see cref="ControllerMetaDescriptor"/> class.
44 public ControllerMetaDescriptor()
49 /// Gets an action descriptor with information about an action.
51 /// <param name="actionMethod">The action method.</param>
52 /// <returns></returns>
53 public ActionMetaDescriptor
GetAction(MethodInfo actionMethod
)
55 ActionMetaDescriptor desc
;
57 if (!actionMetaDescriptors
.TryGetValue(actionMethod
, out desc
))
59 desc
= new ActionMetaDescriptor();
60 actionMetaDescriptors
[actionMethod
] = desc
;
69 /// <value>The actions.</value>
70 public IDictionary Actions
72 get { return actions; }
76 /// Gets the ajax actions.
78 /// <value>The ajax actions.</value>
79 public IList
<MethodInfo
> AjaxActions
81 get { return ajaxActions; }
85 /// Gets or sets the default action.
87 /// <value>The default action.</value>
88 public DefaultActionAttribute DefaultAction
90 get { return defaultAction; }
91 set { defaultAction = value; }
95 /// Gets or sets the helpers.
97 /// <value>The helpers.</value>
98 public HelperDescriptor
[] Helpers
100 get { return helpers; }
101 set { helpers = value; }
105 /// Gets or sets the filters.
107 /// <value>The filters.</value>
108 public FilterDescriptor
[] Filters
110 get { return filters; }
111 set { filters = value; }
115 /// Gets the scaffoldings.
117 /// <value>The scaffoldings.</value>
118 public IList Scaffoldings
120 get { return scaffoldings; }
124 /// Gets the action providers.
126 /// <value>The action providers.</value>
127 public IList
<Type
> ActionProviders
129 get { return actionProviders; }
133 /// Gets or sets the transform filters.
135 /// <value>The transform filters.</value>
136 public TransformFilterDescriptor
[] TransformFilters
138 get { return transformFilters; }
139 set { transformFilters = value; }