Imports System.IO
Imports System.Text

Namespace IO

    ''' <summary>
    ''' Represents an <c>StringWriter</c> for which a <c>System.Text.Encoding</c> can be specified.
    ''' </summary>
    ''' <remarks></remarks>
    Public Class EncodableStringWriter
        Inherits StringWriter

        ' Attributes
        Private _encoding As Encoding

#Region "Constructors"

        ''' <summary>
        ''' Initializes a default instance of the <c>EncodableStringWriter</c> 
        ''' class utilizing the specified <c>System.Text.Encoding</c>.
        ''' </summary>
        ''' <param name="encoding">The <c>System.Text.Encoding</c> 
        ''' in which the output is written.</param>
        Public Sub New(ByVal encoding As Encoding)
            Me.New(New StringBuilder(), encoding)
        End Sub

        ''' <summary>
        ''' Initializes a default instance of the <c>EncodableStringWriter</c> class 
        ''' with the specified <c>StringBuilder</c> and <c>System.Text.Encoding</c>.
        ''' </summary>
        ''' <param name="builder">The <c>StringBuilder</c> on which to write.</param>
        ''' <param name="encoding">The <c>System.Text.Encoding</c> 
        ''' in which the output is written.</param>
        Public Sub New(ByVal builder As StringBuilder, ByVal encoding As Encoding)
            MyBase.New(builder)
            Me._encoding = encoding
        End Sub

#End Region

        ''' <summary>
        ''' Gets the <c>System.Text.Encoding</c> in which the output is written.
        ''' </summary>
        ''' <returns>The <c>System.Text.Encoding</c> in which the output is written.</returns>
        Public Overrides ReadOnly Property Encoding() As System.Text.Encoding
            Get
                Return Me._encoding
            End Get
        End Property

    End Class

End Namespace