Added general purpose Pair class
[castle.git] / MonoRail / Castle.MonoRail.WindsorExtension / ControllerTreeAccessor.cs
blob94f685d8f4d5dc0151695adf4c5ebf80da93c7a1
1 // Copyright 2004-2007 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.WindsorExtension
17 using System;
18 using Castle.MonoRail.Framework;
20 /// <summary>
21 /// Bridge between the windsor controlled controller tree and
22 /// the monorail service provider.
23 /// </summary>
24 public class ControllerTreeAccessor : IControllerTree
26 private IControllerTree tree;
28 /// <summary>
29 /// Construct the controller tree accessor
30 /// </summary>
31 public ControllerTreeAccessor()
33 tree = ContainerAccessorUtil.ObtainContainer().Resolve(typeof(IControllerTree)) as IControllerTree;
36 #region IControllerTree Members
38 /// <summary>
39 /// Register a controller on the tree. If the specified
40 /// area name matches the current node, the controller is
41 /// register on the node itself, otherwise on the right or
42 /// on the left node.
43 /// </summary>
44 /// <remarks>
45 /// Note that the controller is an <c>object</c>. That allows
46 /// different implementation of a controller factory to register
47 /// different representation of what a controller is (a name, a descriptor etc)
48 /// </remarks>
49 /// <param name="areaName">The area name, or <c>String.Empty</c></param>
50 /// <param name="controllerName">The controller name</param>
51 /// <param name="controller">The controller representation</param>
52 public void AddController(string areaName, string controllerName, Type controller)
54 tree.AddController(areaName, controllerName, controller);
57 /// <summary>
58 /// Returns a controller previously registered.
59 /// </summary>
60 /// <param name="areaName">The area name, or <c>String.Empty</c></param>
61 /// <param name="controllerName">The controller name</param>
62 /// <returns>The controller representation or null</returns>
63 public Type GetController(string areaName, string controllerName)
65 return tree.GetController(areaName, controllerName);
68 #endregion