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
.Views
.Brail
.TestSite
.Controllers
17 using Castle
.MonoRail
.Framework
;
18 using Castle
.MonoRail
.Views
.Brail
;
20 using System
.Collections
;
22 using System
.Reflection
;
25 public class SubViewController
: Controller
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.ServiceProvider
.GetService(typeof(IViewEngineManager
));
50 IViewEngine engine1
= (IViewEngine
)viewEngineManager
.GetType().GetMethod("ResolveEngine", BindingFlags
.NonPublic
| BindingFlags
.Instance
).Invoke(viewEngineManager
, new object[] { "dummy.brail" }
);
51 Hashtable hashtable1
= (Hashtable
) typeof(BooViewEngine
).GetField("compilations", BindingFlags
.NonPublic
| BindingFlags
.Instance
).GetValue(engine1
);
52 Hashtable hashtable2
= (Hashtable
) typeof(BooViewEngine
).GetField("constructors", BindingFlags
.NonPublic
| BindingFlags
.Instance
).GetValue(engine1
);
53 if (this.Context
.Request
.QueryString
["replaceSubView"] == "reset")
55 hashtable1
[@"subview\listItem.brail"] = null;
57 else if (this.Context
.Request
.QueryString
["replaceSubView"] == "true")
59 hashtable1
[@"subview\listItem.brail"] = typeof(DummySubView
);
60 Type
[] typeArray1
= new Type
[] { typeof(BooViewEngine), typeof(TextWriter), typeof(IRailsEngineContext), typeof(Controller) }
;
61 hashtable2
[typeof(DummySubView
)] = typeof(DummySubView
).GetConstructor(typeArray1
);