1 // Copyright 2004-2007 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
.WindsorExtension
18 using Castle
.MonoRail
.Framework
;
19 using Castle
.MonoRail
.Framework
.Services
;
22 /// Bridge between the windsor controlled controller tree and
23 /// the monorail service provider.
25 public class ControllerTreeAccessor
: IControllerTree
27 private IControllerTree tree
;
30 /// Construct the controller tree accessor
32 public ControllerTreeAccessor()
34 tree
= WindsorContainerAccessorUtil
.ObtainContainer().Resolve(typeof(IControllerTree
)) as IControllerTree
;
37 #region IControllerTree Members
40 /// Register a controller on the tree. If the specified
41 /// area name matches the current node, the controller is
42 /// register on the node itself, otherwise on the right or
46 /// Note that the controller is an <c>object</c>. That allows
47 /// different implementation of a controller factory to register
48 /// different representation of what a controller is (a name, a descriptor etc)
50 /// <param name="areaName">The area name, or <c>String.Empty</c></param>
51 /// <param name="controllerName">The controller name</param>
52 /// <param name="controller">The controller representation</param>
53 public void AddController(string areaName
, string controllerName
, Type controller
)
55 tree
.AddController(areaName
, controllerName
, controller
);
59 /// Returns a controller previously registered.
61 /// <param name="areaName">The area name, or <c>String.Empty</c></param>
62 /// <param name="controllerName">The controller name</param>
63 /// <returns>The controller representation or null</returns>
64 public Type
GetController(string areaName
, string controllerName
)
66 return tree
.GetController(areaName
, controllerName
);
70 public event EventHandler
<ControllerAddedEventArgs
> ControllerAdded
{
72 tree
.ControllerAdded
+= value;
75 tree
.ControllerAdded
-= value;