Welcome to mirror list, hosted at ThFree Co, Russian Federation.

StringWriter.cs « System.IO « corlib « class « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: bb1d7cbceedd72d4ef95c8429f0e0d2b037896cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//
// System.IO.StringWriter
//
// Author: Marcin Szczepanski (marcins@zipworld.com.au)
//

using System.Text;

namespace System.IO {
		[Serializable]
        public class StringWriter : TextWriter {
                
                private StringBuilder internalString;

                public StringWriter() {
                        internalString = new StringBuilder();
                }

                public StringWriter( IFormatProvider formatProvider ) {
                        internalFormatProvider = formatProvider;
                }

                public StringWriter( StringBuilder sb ) {
                        internalString = sb;
                }

                public StringWriter( StringBuilder sb, IFormatProvider formatProvider ) {
                        internalString = sb;
                        internalFormatProvider = formatProvider;
                }

                public override System.Text.Encoding Encoding {
                        get {
                                // TODO: Implement
                                return null;
                        }
                }

                public override void Close() {
                        Dispose( true );
                }

                protected override void Dispose( bool disposing ) { }

                public virtual StringBuilder GetStringBuilder() {
                        return internalString;
                }

                public override string ToString() {
                        return internalString.ToString();
                }

                public override void Write( char value ) {
                        internalString.Append( value );
                }

                public override void Write( string value ) {
                        internalString.Append( value );
                }

                public override void Write( char[] buffer, int index, int count ) {
                        if( buffer == null ) {
                                throw new ArgumentNullException();
                        } else if( index < 0 || count < 0 ) {
                                throw new ArgumentOutOfRangeException();
                        } else if( index > buffer.Length || index + count > buffer.Length ) {
                                throw new ArgumentException();
                        }
                        
                        char[] writeBuffer = new char[ count ];

                        Array.Copy( buffer, index, writeBuffer, 0, count );

                        internalString.Append( writeBuffer );
                }
                          
        }
}