Add Newtonsoft.Json to the references of TestSiteBrail
[castle.git] / MonoRail / Castle.MonoRail.Framework / ControllerContext.cs
blob3dbc4d124d9741fee79e6748045f0fc8c7b9cb81
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;
38 private IDictionary<string, object> customActionParameters =
39 new Dictionary<string, object>(StringComparer.InvariantCultureIgnoreCase);
41 private IDictionary propertyBag = new HybridDictionary(true);
42 private HelperDictionary helpers = new HelperDictionary();
44 private readonly IDictionary<string, IDynamicAction> dynamicActions =
45 new Dictionary<string, IDynamicAction>(StringComparer.InvariantCultureIgnoreCase);
47 private readonly IDictionary<string, IResource> resources =
48 new Dictionary<string, IResource>(StringComparer.InvariantCultureIgnoreCase);
50 private RouteMatch routeMatch;
51 private AsyncInvocationInformation asyncInformation = new AsyncInvocationInformation();
53 /// <summary>
54 /// Initializes a new instance of the <see cref="ControllerContext"/> class.
55 /// </summary>
56 public ControllerContext()
60 /// <summary>
61 /// Initializes a new instance of the <see cref="ControllerContext"/> class.
62 /// </summary>
63 /// <param name="name">The controller name.</param>
64 /// <param name="action">The action name.</param>
65 /// <param name="metaDescriptor">The meta descriptor.</param>
66 public ControllerContext(string name, string action, ControllerMetaDescriptor metaDescriptor) :
67 this(name, string.Empty, action, metaDescriptor)
71 /// <summary>
72 /// Initializes a new instance of the <see cref="ControllerContext"/> class.
73 /// </summary>
74 /// <param name="name">The controller name.</param>
75 /// <param name="areaName">The area name.</param>
76 /// <param name="action">The action name.</param>
77 /// <param name="metaDescriptor">The meta descriptor.</param>
78 public ControllerContext(string name, string areaName, string action, ControllerMetaDescriptor metaDescriptor)
80 this.name = name;
81 this.areaName = areaName;
82 this.action = action;
83 this.metaDescriptor = metaDescriptor;
86 /// <summary>
87 /// Gets or sets the custom action parameters.
88 /// </summary>
89 /// <value>The custom action parameters.</value>
90 public IDictionary<string, object> CustomActionParameters
92 get { return customActionParameters; }
93 set { customActionParameters = value; }
96 /// <summary>
97 /// Gets the property bag, which is used
98 /// to pass variables to the view.
99 /// </summary>
100 /// <value></value>
101 public IDictionary PropertyBag
103 get { return propertyBag; }
104 set { propertyBag = value; }
107 /// <summary>
108 /// Gets a dictionary of name/helper instance
109 /// </summary>
110 /// <value>The helpers.</value>
111 public HelperDictionary Helpers
113 get { return helpers; }
114 set { helpers = value; }
117 /// <summary>
118 /// Gets the controller's name.
119 /// </summary>
120 /// <value></value>
121 public string Name
123 get { return name; }
124 set { name = value; }
127 /// <summary>
128 /// Gets the controller's area name.
129 /// </summary>
130 /// <value></value>
131 public string AreaName
133 get { return areaName; }
134 set { areaName = value; }
137 /// <summary>
138 /// Gets or set the layout being used.
139 /// </summary>
140 /// <value></value>
141 public string[] LayoutNames
143 get { return layoutNames; }
144 set { layoutNames = value; }
147 /// <summary>
148 /// Gets the name of the action being processed.
149 /// </summary>
150 /// <value></value>
151 public string Action
153 get { return action; }
154 set { action = value; }
157 /// <summary>
158 /// Gets or sets the view which will be rendered after this action executes.
159 /// </summary>
160 /// <value></value>
161 public string SelectedViewName
163 get { return selectedViewName; }
164 set { selectedViewName = value; }
167 /// <summary>
168 /// Gets the view folder -- (areaname +
169 /// controllername) or just controller name -- that this controller
170 /// will use by default.
171 /// </summary>
172 /// <value></value>
173 public string ViewFolder
175 get { return viewFolder; }
176 set { viewFolder = value; }
179 /// <summary>
180 /// Gets a dicitionary of name/<see cref="IResource"/>
181 /// </summary>
182 /// <value>The resources.</value>
183 /// <remarks>It is supposed to be used by MonoRail infrastructure only</remarks>
184 public IDictionary<string, IResource> Resources
186 get { return resources; }
189 /// <summary>
190 /// Gets the dynamic actions.
191 /// </summary>
192 /// <value>The dynamic actions.</value>
193 public IDictionary<string, IDynamicAction> DynamicActions
195 get { return dynamicActions; }
198 /// <summary>
199 /// Gets or sets the controller descriptor.
200 /// </summary>
201 /// <value>The controller descriptor.</value>
202 public ControllerMetaDescriptor ControllerDescriptor
204 get { return metaDescriptor; }
205 set { metaDescriptor = value; }
208 /// <summary>
209 /// Gets or sets the route match.
210 /// </summary>
211 /// <value>The route match.</value>
212 public RouteMatch RouteMatch
214 get { return routeMatch; }
215 set { routeMatch = value; }
218 /// <summary>
219 /// Get or set the information used to manage async invocations
220 /// </summary>
221 public AsyncInvocationInformation Async
223 get { return asyncInformation; }
224 set { asyncInformation = value; }