Fixing an issue with output parameters that are of type IntPtr
[castle.git] / Experiments / IronPythonViewEngine / Castle.MonoRail.Views.IronView / DefaultContext.cs
blob158d826882bf4aec6761760c617b86531a66a404
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.IronView
17 using System;
18 using System.Text;
19 using System.Xml;
21 class DefaultContext : ITemplateContext
23 private readonly string rootViewName;
24 private readonly XmlReader reader;
25 private readonly IServiceProvider serviceProvider;
26 private readonly ITemplateEngine engine;
27 private int currentElementDepth;
28 private int indentation;
29 private StringBuilder script = new StringBuilder();
31 /// <summary>
32 /// Initializes a new instance of the <see cref="DefaultContext"/> class.
33 /// </summary>
34 /// <param name="rootViewName">Name of the root view.</param>
35 /// <param name="reader">The reader.</param>
36 /// <param name="serviceProvider">The service provider.</param>
37 public DefaultContext(String rootViewName, XmlReader reader,
38 IServiceProvider serviceProvider, ITemplateEngine engine)
40 this.rootViewName = rootViewName;
41 this.reader = reader;
42 this.serviceProvider = serviceProvider;
43 this.engine = engine;
46 public XmlReader Reader
48 get { return reader; }
51 public IServiceProvider ServiceProvider
53 get { return serviceProvider; }
56 public ITemplateEngine Engine
58 get { return engine; }
61 public string RootViewName
63 get { return rootViewName; }
66 public StringBuilder Script
68 get { return script; }
71 public int Indentation
73 get { return indentation; }
76 public int CurrentElementDepth
78 get { return currentElementDepth; }
81 public void IncreaseIndentation()
83 indentation++;
86 public void DecreaseIndentation()
88 indentation--;
91 public void IncreaseDepth()
93 currentElementDepth++;
96 public void DecreaseDepth()
98 currentElementDepth--;
101 public void AppendIndented(string content)
103 Indent();
105 script.Append(content);
108 public void AppendLineIndented(string content)
110 Indent();
112 script.AppendLine(content);
115 private void Indent()
117 for(int i = 0; i < indentation; i++)
119 script.Append('\t');