Fixing an issue with output parameters that are of type IntPtr
[castle.git] / MonoRail / Castle.MonoRail.Framework / Descriptors / ControllerMetaDescriptor.cs
blobd5b33b122bc4750bc4d7d38a521536e92ecdba1d
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.Descriptors
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 ControllerDescriptor controllerDescriptor;
32 private DefaultActionAttribute defaultAction;
33 private HelperDescriptor[] helpers = new HelperDescriptor[0];
34 private FilterDescriptor[] filters = new FilterDescriptor[0];
35 private TransformFilterDescriptor[] transformFilters = new TransformFilterDescriptor[0];
36 private Dictionary<object, ActionMetaDescriptor> actionMetaDescriptors = new Dictionary<object, ActionMetaDescriptor>();
37 private IList<ScaffoldingAttribute> scaffoldings = new List<ScaffoldingAttribute>();
38 private IList<Type> actionProviders = new List<Type>();
39 private IList<MethodInfo> ajaxActions = new List<MethodInfo>();
40 private IDictionary actions = new HybridDictionary(true);
42 /// <summary>
43 /// Initializes a new instance of the <see cref="ControllerMetaDescriptor"/> class.
44 /// </summary>
45 public ControllerMetaDescriptor()
49 /// <summary>
50 /// Gets an action descriptor with information about an action.
51 /// </summary>
52 /// <param name="actionMethod">The action method.</param>
53 /// <returns></returns>
54 public ActionMetaDescriptor GetAction(object actionMethod)
56 if (actionMethod == null) throw new ArgumentNullException("actionMethod");
58 ActionMetaDescriptor desc;
60 actionMetaDescriptors.TryGetValue(actionMethod, out desc);
62 return desc;
65 /// <summary>
66 /// Adds the action.
67 /// </summary>
68 /// <param name="action">The action.</param>
69 /// <param name="metaDescriptor">The meta descriptor.</param>
70 public void AddAction(object action, ActionMetaDescriptor metaDescriptor)
72 if (action == null) throw new ArgumentNullException("action");
73 if (metaDescriptor == null) throw new ArgumentNullException("metaDescriptor");
75 actionMetaDescriptors[action] = metaDescriptor;
78 /// <summary>
79 /// Gets or sets the controller descriptor.
80 /// </summary>
81 /// <value>The controller descriptor.</value>
82 public ControllerDescriptor ControllerDescriptor
84 get { return controllerDescriptor; }
85 set { controllerDescriptor = value; }
88 /// <summary>
89 /// Gets the actions.
90 /// </summary>
91 /// <value>The actions.</value>
92 public IDictionary Actions
94 get { return actions; }
97 /// <summary>
98 /// Gets the action descriptors dictionary.
99 /// They key is an action (might be a method or something else).
100 /// </summary>
101 /// <value>The action descriptors.</value>
102 public Dictionary<object, ActionMetaDescriptor> ActionDescriptors
104 get { return actionMetaDescriptors; }
107 /// <summary>
108 /// Gets the ajax actions.
109 /// </summary>
110 /// <value>The ajax actions.</value>
111 public IList<MethodInfo> AjaxActions
113 get { return ajaxActions; }
116 /// <summary>
117 /// Gets or sets the default action.
118 /// </summary>
119 /// <value>The default action.</value>
120 public DefaultActionAttribute DefaultAction
122 get { return defaultAction; }
123 set { defaultAction = value; }
126 /// <summary>
127 /// Gets or sets the helpers.
128 /// </summary>
129 /// <value>The helpers.</value>
130 public HelperDescriptor[] Helpers
132 get { return helpers; }
133 set { helpers = value; }
136 /// <summary>
137 /// Gets or sets the filters.
138 /// </summary>
139 /// <value>The filters.</value>
140 public FilterDescriptor[] Filters
142 get { return filters; }
143 set { filters = value; }
146 /// <summary>
147 /// Gets the scaffoldings.
148 /// </summary>
149 /// <value>The scaffoldings.</value>
150 public IList<ScaffoldingAttribute> Scaffoldings
152 get { return scaffoldings; }
155 /// <summary>
156 /// Gets the action providers.
157 /// </summary>
158 /// <value>The action providers.</value>
159 public IList<Type> ActionProviders
161 get { return actionProviders; }
164 /// <summary>
165 /// Gets or sets the transform filters.
166 /// </summary>
167 /// <value>The transform filters.</value>
168 public TransformFilterDescriptor[] TransformFilters
170 get { return transformFilters; }
171 set { transformFilters = value; }