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
;
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
;
45 /// Initializes a new instance of the <see cref="ControllerContext"/> class.
47 public ControllerContext()
52 /// Initializes a new instance of the <see cref="ControllerContext"/> class.
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
)
63 /// Initializes a new instance of the <see cref="ControllerContext"/> class.
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
)
72 this.areaName
= areaName
;
74 this.metaDescriptor
= metaDescriptor
;
78 /// Gets or sets the custom action parameters.
80 /// <value>The custom action parameters.</value>
81 public IDictionary
<string, object> CustomActionParameters
83 get { return customActionParameters; }
84 set { customActionParameters = value; }
88 /// Gets the property bag, which is used
89 /// to pass variables to the view.
92 public IDictionary PropertyBag
94 get { return propertyBag; }
95 set { propertyBag = value; }
99 /// Gets a dictionary of name/helper instance
101 /// <value>The helpers.</value>
102 public HelperDictionary Helpers
104 get { return helpers; }
105 set { helpers = value; }
109 /// Gets the controller's name.
115 set { name = value; }
119 /// Gets the controller's area name.
122 public string AreaName
124 get { return areaName; }
125 set { areaName = value; }
129 /// Gets or set the layout being used.
132 public string[] LayoutNames
134 get { return layoutNames; }
135 set { layoutNames = value; }
139 /// Gets the name of the action being processed.
144 get { return action; }
145 set { action = value; }
149 /// Gets or sets the view which will be rendered after this action executes.
152 public string SelectedViewName
154 get { return selectedViewName; }
155 set { selectedViewName = value; }
159 /// Gets the view folder -- (areaname +
160 /// controllername) or just controller name -- that this controller
161 /// will use by default.
164 public string ViewFolder
166 get { return viewFolder; }
167 set { viewFolder = value; }
171 /// Gets a dicitionary of name/<see cref="IResource"/>
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; }
181 /// Gets the dynamic actions.
183 /// <value>The dynamic actions.</value>
184 public IDictionary
<string, IDynamicAction
> DynamicActions
186 get { return dynamicActions; }
190 /// Gets or sets the controller descriptor.
192 /// <value>The controller descriptor.</value>
193 public ControllerMetaDescriptor ControllerDescriptor
195 get { return metaDescriptor; }
196 set { metaDescriptor = value; }
200 /// Gets or sets the route match.
202 /// <value>The route match.</value>
203 public RouteMatch RouteMatch
205 get { return routeMatch; }
206 set { routeMatch = value; }