Removed untyped contructor from ComponentRegistration and add a protected setter.
[castle.git] / MonoRail / Castle.MonoRail.Framework / ControllerContext.cs
blobc2645a9f40bc252e040c32f7da59f587c950ca37
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 System.Collections;
19 using System.Collections.Generic;
20 using System.Collections.Specialized;
21 using Descriptors;
22 using Resources;
23 using Routing;
25 /// <summary>
26 /// Pendent
27 /// </summary>
28 public class ControllerContext : IControllerContext
30 private string name;
31 private string areaName;
32 private string action;
33 private string selectedViewName;
34 private string viewFolder;
35 private string[] layoutNames;
36 private ControllerMetaDescriptor metaDescriptor;
37 private IDictionary<string, object> customActionParameters = new Dictionary<string, object>(StringComparer.InvariantCultureIgnoreCase);
38 private IDictionary propertyBag = new HybridDictionary(true);
39 private HelperDictionary helpers = new HelperDictionary();
40 private readonly IDictionary<string, IDynamicAction> dynamicActions = new Dictionary<string, IDynamicAction>(StringComparer.InvariantCultureIgnoreCase);
41 private readonly IDictionary<string, IResource> resources = new Dictionary<string, IResource>(StringComparer.InvariantCultureIgnoreCase);
42 private RouteMatch routeMatch;
44 /// <summary>
45 /// Initializes a new instance of the <see cref="ControllerContext"/> class.
46 /// </summary>
47 public ControllerContext()
51 /// <summary>
52 /// Initializes a new instance of the <see cref="ControllerContext"/> class.
53 /// </summary>
54 /// <param name="name">The controller name.</param>
55 /// <param name="action">The action name.</param>
56 /// <param name="metaDescriptor">The meta descriptor.</param>
57 public ControllerContext(string name, string action, ControllerMetaDescriptor metaDescriptor) :
58 this(name, string.Empty, action, metaDescriptor)
62 /// <summary>
63 /// Initializes a new instance of the <see cref="ControllerContext"/> class.
64 /// </summary>
65 /// <param name="name">The controller name.</param>
66 /// <param name="areaName">The area name.</param>
67 /// <param name="action">The action name.</param>
68 /// <param name="metaDescriptor">The meta descriptor.</param>
69 public ControllerContext(string name, string areaName, string action, ControllerMetaDescriptor metaDescriptor)
71 this.name = name;
72 this.areaName = areaName;
73 this.action = action;
74 this.metaDescriptor = metaDescriptor;
77 /// <summary>
78 /// Gets or sets the custom action parameters.
79 /// </summary>
80 /// <value>The custom action parameters.</value>
81 public IDictionary<string, object> CustomActionParameters
83 get { return customActionParameters; }
84 set { customActionParameters = value; }
87 /// <summary>
88 /// Gets the property bag, which is used
89 /// to pass variables to the view.
90 /// </summary>
91 /// <value></value>
92 public IDictionary PropertyBag
94 get { return propertyBag; }
95 set { propertyBag = value; }
98 /// <summary>
99 /// Gets a dictionary of name/helper instance
100 /// </summary>
101 /// <value>The helpers.</value>
102 public HelperDictionary Helpers
104 get { return helpers; }
105 set { helpers = value; }
108 /// <summary>
109 /// Gets the controller's name.
110 /// </summary>
111 /// <value></value>
112 public string Name
114 get { return name; }
115 set { name = value; }
118 /// <summary>
119 /// Gets the controller's area name.
120 /// </summary>
121 /// <value></value>
122 public string AreaName
124 get { return areaName; }
125 set { areaName = value; }
128 /// <summary>
129 /// Gets or set the layout being used.
130 /// </summary>
131 /// <value></value>
132 public string[] LayoutNames
134 get { return layoutNames; }
135 set { layoutNames = value; }
138 /// <summary>
139 /// Gets the name of the action being processed.
140 /// </summary>
141 /// <value></value>
142 public string Action
144 get { return action; }
145 set { action = value; }
148 /// <summary>
149 /// Gets or sets the view which will be rendered after this action executes.
150 /// </summary>
151 /// <value></value>
152 public string SelectedViewName
154 get { return selectedViewName; }
155 set { selectedViewName = value; }
158 /// <summary>
159 /// Gets the view folder -- (areaname +
160 /// controllername) or just controller name -- that this controller
161 /// will use by default.
162 /// </summary>
163 /// <value></value>
164 public string ViewFolder
166 get { return viewFolder; }
167 set { viewFolder = value; }
170 /// <summary>
171 /// Gets a dicitionary of name/<see cref="IResource"/>
172 /// </summary>
173 /// <value>The resources.</value>
174 /// <remarks>It is supposed to be used by MonoRail infrastructure only</remarks>
175 public IDictionary<string, IResource> Resources
177 get { return resources; }
180 /// <summary>
181 /// Gets the dynamic actions.
182 /// </summary>
183 /// <value>The dynamic actions.</value>
184 public IDictionary<string, IDynamicAction> DynamicActions
186 get { return dynamicActions; }
189 /// <summary>
190 /// Gets or sets the controller descriptor.
191 /// </summary>
192 /// <value>The controller descriptor.</value>
193 public ControllerMetaDescriptor ControllerDescriptor
195 get { return metaDescriptor; }
196 set { metaDescriptor = value; }
199 /// <summary>
200 /// Gets or sets the route match.
201 /// </summary>
202 /// <value>The route match.</value>
203 public RouteMatch RouteMatch
205 get { return routeMatch; }
206 set { routeMatch = value; }