More passing tests.
[castle.git] / MonoRail / TestSiteBrail / Controllers / SubViewController.cs
blob0b3813914d2b34e16e82cdd28b07d5cb12e7af46
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.Views.Brail.TestSite.Controllers
17 using Castle.MonoRail.Framework;
18 using Castle.MonoRail.Views.Brail;
19 using System;
20 using System.Collections;
21 using System.IO;
22 using System.Reflection;
24 [Serializable]
25 public class SubViewController : Controller
27 public void Index()
31 public void SubViewWithLayout()
33 this.LayoutName = "master";
34 this.RenderView("index");
37 public void SubViewWithParameters()
39 this.RenderView("CallSubViewWithParameters");
42 public void SubViewWithPath()
46 public void useLotsOfSubViews()
48 //this is ugly, but the other way is to open up things that really shouldn't be opened...
49 IViewEngineManager viewEngineManager = (IViewEngineManager)this.Context.Services.ViewEngineManager;
50 MethodInfo method = viewEngineManager.GetType().GetMethod("ResolveEngine", BindingFlags.Instance|BindingFlags.NonPublic, null,new Type[] { typeof(string) },new ParameterModifier[0]);
51 IViewEngine engine1 = (IViewEngine)method.Invoke(viewEngineManager, new object[] { "dummy.brail" });
52 Hashtable hashtable1 = (Hashtable)typeof(BooViewEngine).GetField("compilations", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(engine1);
53 Hashtable hashtable2 = (Hashtable)typeof(BooViewEngine).GetField("constructors", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(engine1);
54 if (this.Context.Request.QueryString["replaceSubView"] == "reset")
56 hashtable1[@"subview\listItem.brail"] = null;
58 else if (this.Context.Request.QueryString["replaceSubView"] == "true")
60 hashtable1[@"subview\listItem.brail"] = typeof(DummySubView);
61 Type[] typeArray1 = new Type[] { typeof(BooViewEngine), typeof(TextWriter), typeof(IEngineContext), typeof(Controller), typeof(IControllerContext) };
62 hashtable2[typeof(DummySubView)] = typeof(DummySubView).GetConstructor(typeArray1);