- Implemented support for view component caching. Just use the attribute
[castle.git] / MonoRail / Castle.MonoRail.Framework / Internal / Descriptors / ControllerMetaDescriptor.cs
blob15a53a08f36a5fce027b486aea86ccf88e169dbd
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.Internal
17 using System;
18 using System.Collections;
19 using System.Collections.Generic;
20 using System.Collections.Specialized;
21 using System.Reflection;
23 /// <summary>
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.
27 /// </summary>
28 [Serializable]
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);
41 /// <summary>
42 /// Initializes a new instance of the <see cref="ControllerMetaDescriptor"/> class.
43 /// </summary>
44 public ControllerMetaDescriptor()
48 /// <summary>
49 /// Gets an action descriptor with information about an action.
50 /// </summary>
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;
63 return desc;
66 /// <summary>
67 /// Gets the actions.
68 /// </summary>
69 /// <value>The actions.</value>
70 public IDictionary Actions
72 get { return actions; }
75 /// <summary>
76 /// Gets the ajax actions.
77 /// </summary>
78 /// <value>The ajax actions.</value>
79 public IList<MethodInfo> AjaxActions
81 get { return ajaxActions; }
84 /// <summary>
85 /// Gets or sets the default action.
86 /// </summary>
87 /// <value>The default action.</value>
88 public DefaultActionAttribute DefaultAction
90 get { return defaultAction; }
91 set { defaultAction = value; }
94 /// <summary>
95 /// Gets or sets the helpers.
96 /// </summary>
97 /// <value>The helpers.</value>
98 public HelperDescriptor[] Helpers
100 get { return helpers; }
101 set { helpers = value; }
104 /// <summary>
105 /// Gets or sets the filters.
106 /// </summary>
107 /// <value>The filters.</value>
108 public FilterDescriptor[] Filters
110 get { return filters; }
111 set { filters = value; }
114 /// <summary>
115 /// Gets the scaffoldings.
116 /// </summary>
117 /// <value>The scaffoldings.</value>
118 public IList Scaffoldings
120 get { return scaffoldings; }
123 /// <summary>
124 /// Gets the action providers.
125 /// </summary>
126 /// <value>The action providers.</value>
127 public IList<Type> ActionProviders
129 get { return actionProviders; }
132 /// <summary>
133 /// Gets or sets the transform filters.
134 /// </summary>
135 /// <value>The transform filters.</value>
136 public TransformFilterDescriptor[] TransformFilters
138 get { return transformFilters; }
139 set { transformFilters = value; }