1
// Copyright 2004-2008 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
18 using System
.Collections
;
19 using System
.Collections
.Generic
;
20 using System
.Collections
.Specialized
;
28 public class ControllerContext
: IControllerContext
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();
54 /// Initializes a new instance of the <see cref="ControllerContext"/> class.
56 public ControllerContext()
61 /// Initializes a new instance of the <see cref="ControllerContext"/> class.
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
)
72 /// Initializes a new instance of the <see cref="ControllerContext"/> class.
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
)
81 this.areaName
= areaName
;
83 this.metaDescriptor
= metaDescriptor
;
87 /// Gets or sets the custom action parameters.
89 /// <value>The custom action parameters.</value>
90 public IDictionary
<string, object> CustomActionParameters
92 get { return customActionParameters; }
93 set { customActionParameters = value; }
97 /// Gets the property bag, which is used
98 /// to pass variables to the view.
101 public IDictionary PropertyBag
103 get { return propertyBag; }
104 set { propertyBag = value; }
108 /// Gets a dictionary of name/helper instance
110 /// <value>The helpers.</value>
111 public HelperDictionary Helpers
113 get { return helpers; }
114 set { helpers = value; }
118 /// Gets the controller's name.
124 set { name = value; }
128 /// Gets the controller's area name.
131 public string AreaName
133 get { return areaName; }
134 set { areaName = value; }
138 /// Gets or set the layout being used.
141 public string[] LayoutNames
143 get { return layoutNames; }
144 set { layoutNames = value; }
148 /// Gets the name of the action being processed.
153 get { return action; }
154 set { action = value; }
158 /// Gets or sets the view which will be rendered after this action executes.
161 public string SelectedViewName
163 get { return selectedViewName; }
164 set { selectedViewName = value; }
168 /// Gets the view folder -- (areaname +
169 /// controllername) or just controller name -- that this controller
170 /// will use by default.
173 public string ViewFolder
175 get { return viewFolder; }
176 set { viewFolder = value; }
180 /// Gets a dicitionary of name/<see cref="IResource"/>
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; }
190 /// Gets the dynamic actions.
192 /// <value>The dynamic actions.</value>
193 public IDictionary
<string, IDynamicAction
> DynamicActions
195 get { return dynamicActions; }
199 /// Gets or sets the controller descriptor.
201 /// <value>The controller descriptor.</value>
202 public ControllerMetaDescriptor ControllerDescriptor
204 get { return metaDescriptor; }
205 set { metaDescriptor = value; }
209 /// Gets or sets the route match.
211 /// <value>The route match.</value>
212 public RouteMatch RouteMatch
214 get { return routeMatch; }
215 set { routeMatch = value; }
219 /// Get or set the information used to manage async invocations
221 public AsyncInvocationInformation Async
223 get { return asyncInformation; }
224 set { asyncInformation = value; }