2 // System.CodeDom.Compiler IndentedTextWriter class
5 // Daniel Stodden (stodden@in.tum.de)
7 // (C) 2002 Ximian, Inc.
8 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 using System
.Security
.Permissions
;
34 namespace System
.CodeDom
.Compiler
{
36 [PermissionSet (SecurityAction
.LinkDemand
, Unrestricted
= true)]
37 [PermissionSet (SecurityAction
.InheritanceDemand
, Unrestricted
= true)]
38 public class IndentedTextWriter
41 private TextWriter writer
;
42 private string tabString
;
49 public IndentedTextWriter( TextWriter writer
)
52 this.tabString
= DefaultTabString
;
56 public IndentedTextWriter( TextWriter writer
, string tabString
)
59 this.tabString
= tabString
;
67 public const string DefaultTabString
= " ";
72 public override Encoding Encoding
{
74 return writer
.Encoding
;
90 public TextWriter InnerWriter
{
96 public override string NewLine
{
98 return writer
.NewLine
;
101 writer
.NewLine
= value;
108 public override void Close()
113 public override void Flush()
118 public override void Write( bool value )
121 writer
.Write( value );
124 public override void Write( char value )
127 writer
.Write( value );
130 public override void Write( char[] value )
133 writer
.Write( value );
136 public override void Write( double value )
139 writer
.Write( value );
142 public override void Write( int value )
145 writer
.Write( value );
148 public override void Write( long value )
151 writer
.Write( value );
154 public override void Write( object value )
157 writer
.Write( value );
160 public override void Write( float value )
163 writer
.Write( value );
166 public override void Write( string value )
169 writer
.Write( value );
172 public override void Write( string format
, object arg
)
175 writer
.Write( format
, arg
);
178 public override void Write( string format
, params object[] args
)
181 writer
.Write( format
, args
);
184 public override void Write( char[] buffer
, int index
, int count
)
187 writer
.Write( buffer
, index
, count
);
190 public override void Write( string format
, object arg0
, object arg1
)
193 writer
.Write( format
, arg0
, arg1
);
197 public override void WriteLine()
204 public override void WriteLine( bool value )
207 writer
.WriteLine( value );
211 public override void WriteLine( char value )
214 writer
.WriteLine( value );
218 public override void WriteLine( char[] value )
221 writer
.WriteLine( value );
225 public override void WriteLine( double value )
228 writer
.WriteLine( value );
232 public override void WriteLine( int value )
235 writer
.WriteLine( value );
239 public override void WriteLine( long value )
242 writer
.WriteLine( value );
246 public override void WriteLine( object value )
249 writer
.WriteLine( value );
253 public override void WriteLine( float value )
256 writer
.WriteLine( value );
260 public override void WriteLine( string value )
263 writer
.WriteLine( value );
267 [CLSCompliant(false)]
268 public override void WriteLine( uint value )
271 writer
.WriteLine( value );
275 public override void WriteLine( string format
, object arg
)
278 writer
.WriteLine( format
, arg
);
282 public override void WriteLine( string format
, params object[] args
)
285 writer
.WriteLine( format
, args
);
289 public override void WriteLine( char[] buffer
, int index
, int count
)
292 writer
.WriteLine( buffer
, index
, count
);
296 public override void WriteLine( string format
, object arg0
, object arg1
)
299 writer
.WriteLine( format
, arg0
, arg1
);
304 public void WriteLineNoTabs( string value )
306 writer
.WriteLine( value );
311 protected virtual void OutputTabs()
314 for ( int i
= 0; i
< indent
; ++i
)
315 writer
.Write( tabString
);