Minor style changes
[castle.git] / MonoRail / Castle.MonoRail.Views.Brail / XmlExtension.cs
blobc6aa2d7e797dc28444a549599b45992bd13cf407
1 using System.Collections;
2 using System.IO;
3 using System.Xml;
4 using Boo.Lang;
6 namespace Castle.MonoRail.Views.Brail
8 public class XmlExtension : IDslLanguageExtension
10 readonly private TextWriter _output = null;
11 private readonly XmlWriter writer;
13 public XmlExtension(TextWriter output)
15 _output = output;
16 this.writer = XmlWriter.Create(_output);
19 public TextWriter Output
21 get { return _output; }
24 public void text(string text)
26 writer.WriteString(text);
29 private void BlockTag(string tag, IDictionary attributes, ICallable block)
31 writer.WriteStartElement(tag);
33 if (null != attributes)
35 foreach (DictionaryEntry entry in attributes)
37 writer.WriteAttributeString((string)entry.Key,(string)entry.Value);
41 if (block != null)
43 block.Call(null);
45 writer.WriteEndElement();
48 public void Tag(string name)
50 BlockTag(name, null, null);
53 public void Tag(string name, ICallable block)
55 BlockTag(name, null, block);
58 public void Tag(string name, IDictionary attributes, ICallable block)
60 BlockTag(name, attributes, block);
63 public void Flush()
65 writer.Flush();