using System;
using System.Runtime.InteropServices;
using System.Text;
namespace System.IO
{
/// Implements a for writing information to a string. The information is stored in an underlying .
/// 2
// Token: 0x020001D2 RID: 466
[MonoTODO("Serialization format not compatible with .NET")]
[ComVisible(true)]
[Serializable]
public class StringWriter : TextWriter
{
/// Initializes a new instance of the class.
// Token: 0x060017E4 RID: 6116 RVA: 0x0005C1C0 File Offset: 0x0005A3C0
public StringWriter()
: this(new StringBuilder())
{
}
/// Initializes a new instance of the class with the specified format control.
/// An object that controls formatting.
// Token: 0x060017E5 RID: 6117 RVA: 0x0005C1D0 File Offset: 0x0005A3D0
public StringWriter(IFormatProvider formatProvider)
: this(new StringBuilder(), formatProvider)
{
}
/// Initializes a new instance of the class that writes to the specified .
/// The StringBuilder to write to.
///
/// is null.
// Token: 0x060017E6 RID: 6118 RVA: 0x0005C1E0 File Offset: 0x0005A3E0
public StringWriter(StringBuilder sb)
: this(sb, null)
{
}
/// Initializes a new instance of the class that writes to the specified and has the specified format provider.
/// The StringBuilder to write to.
/// An object that controls formatting.
///
/// is null.
// Token: 0x060017E7 RID: 6119 RVA: 0x0005C1EC File Offset: 0x0005A3EC
public StringWriter(StringBuilder sb, IFormatProvider formatProvider)
{
if (sb == null)
{
throw new ArgumentNullException("sb");
}
this.internalString = sb;
this.internalFormatProvider = formatProvider;
}
/// Gets the in which the output is written.
/// The Encoding in which the output is written.
/// 1
// Token: 0x1700043B RID: 1083
// (get) Token: 0x060017E8 RID: 6120 RVA: 0x0005C214 File Offset: 0x0005A414
public override Encoding Encoding
{
get
{
return Encoding.Unicode;
}
}
/// Closes the current and the underlying stream.
/// 1
// Token: 0x060017E9 RID: 6121 RVA: 0x0005C21C File Offset: 0x0005A41C
public override void Close()
{
this.Dispose(true);
this.disposed = true;
}
/// Releases the unmanaged resources used by the and optionally releases the managed resources.
/// true to release both managed and unmanaged resources; false to release only unmanaged resources.
// Token: 0x060017EA RID: 6122 RVA: 0x0005C22C File Offset: 0x0005A42C
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
this.disposed = true;
}
/// Returns the underlying .
/// The underlying StringBuilder.
/// 2
// Token: 0x060017EB RID: 6123 RVA: 0x0005C23C File Offset: 0x0005A43C
public virtual StringBuilder GetStringBuilder()
{
return this.internalString;
}
/// Returns a string containing the characters written to the current StringWriter so far.
/// The string containing the characters written to the current StringWriter.
/// 2
// Token: 0x060017EC RID: 6124 RVA: 0x0005C244 File Offset: 0x0005A444
public override string ToString()
{
return this.internalString.ToString();
}
/// Writes a character to this instance of the StringWriter.
/// The character to write.
/// The writer is closed.
/// 2
// Token: 0x060017ED RID: 6125 RVA: 0x0005C254 File Offset: 0x0005A454
public override void Write(char value)
{
if (this.disposed)
{
throw new ObjectDisposedException("StringReader", Locale.GetText("Cannot write to a closed StringWriter"));
}
this.internalString.Append(value);
}
/// Writes a string to this instance of the StringWriter.
/// The string to write.
/// The writer is closed.
/// 2
// Token: 0x060017EE RID: 6126 RVA: 0x0005C284 File Offset: 0x0005A484
public override void Write(string value)
{
if (this.disposed)
{
throw new ObjectDisposedException("StringReader", Locale.GetText("Cannot write to a closed StringWriter"));
}
this.internalString.Append(value);
}
/// Writes the specified region of a character array to this instance of the StringWriter.
/// The character array to read data from.
/// The index at which to begin reading from .
/// The maximum number of characters to write.
///
/// is null.
///
/// or is negative.
/// ( + )> . Length.
/// The writer is closed.
/// 2
// Token: 0x060017EF RID: 6127 RVA: 0x0005C2B4 File Offset: 0x0005A4B4
public override void Write(char[] buffer, int index, int count)
{
if (this.disposed)
{
throw new ObjectDisposedException("StringReader", Locale.GetText("Cannot write to a closed StringWriter"));
}
if (buffer == null)
{
throw new ArgumentNullException("buffer");
}
if (index < 0)
{
throw new ArgumentOutOfRangeException("index", "< 0");
}
if (count < 0)
{
throw new ArgumentOutOfRangeException("count", "< 0");
}
if (index > buffer.Length - count)
{
throw new ArgumentException("index + count > buffer.Length");
}
this.internalString.Append(buffer, index, count);
}
// Token: 0x04000721 RID: 1825
private StringBuilder internalString;
// Token: 0x04000722 RID: 1826
private bool disposed;
}
}