#region Copyright & License
//
// Copyright 2001-2005 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#endregion
using System;
using System.Text;
using System.IO;
using System.Globalization;
namespace log4net.Util
{
///
/// Adapter that extends and forwards all
/// messages to an instance of .
///
///
///
/// Adapter that extends and forwards all
/// messages to an instance of .
///
///
/// Nicko Cadell
public abstract class TextWriterAdapter : TextWriter
{
#region Private Member Variables
///
/// The writer to forward messages to
///
private TextWriter m_writer;
#endregion
#region Constructors
///
/// Create an instance of that forwards all
/// messages to a .
///
/// The to forward to
///
///
/// Create an instance of that forwards all
/// messages to a .
///
///
protected TextWriterAdapter(TextWriter writer) : base(CultureInfo.InvariantCulture)
{
m_writer = writer;
}
#endregion
#region Protected Instance Properties
///
/// Gets or sets the underlying .
///
///
/// The underlying .
///
///
///
/// Gets or sets the underlying .
///
///
protected TextWriter Writer
{
get { return m_writer; }
set { m_writer = value; }
}
#endregion Protected Instance Properties
#region Public Properties
///
/// The Encoding in which the output is written
///
///
/// The
///
///
///
/// The Encoding in which the output is written
///
///
override public Encoding Encoding
{
get { return m_writer.Encoding; }
}
///
/// Gets an object that controls formatting
///
///
/// The format provider
///
///
///
/// Gets an object that controls formatting
///
///
override public IFormatProvider FormatProvider
{
get { return m_writer.FormatProvider; }
}
///
/// Gets or sets the line terminator string used by the TextWriter
///
///
/// The line terminator to use
///
///
///
/// Gets or sets the line terminator string used by the TextWriter
///
///
override public String NewLine
{
get { return m_writer.NewLine; }
set { m_writer.NewLine = value; }
}
#endregion
#region Public Methods
///
/// Closes the writer and releases any system resources associated with the writer
///
///
///
///
///
override public void Close()
{
m_writer.Close();
}
///
/// Dispose this writer
///
/// flag indicating if we are being disposed
///
///
/// Dispose this writer
///
///
override protected void Dispose(bool disposing)
{
if (disposing)
{
((IDisposable)m_writer).Dispose();
}
}
///
/// Flushes any buffered output
///
///
///
/// Clears all buffers for the writer and causes any buffered data to be written
/// to the underlying device
///
///
override public void Flush()
{
m_writer.Flush();
}
///
/// Writes a character to the wrapped TextWriter
///
/// the value to write to the TextWriter
///
///
/// Writes a character to the wrapped TextWriter
///
///
override public void Write(char value)
{
m_writer.Write(value);
}
///
/// Writes a character buffer to the wrapped TextWriter
///
/// the data buffer
/// the start index
/// the number of characters to write
///
///
/// Writes a character buffer to the wrapped TextWriter
///
///
override public void Write(char[] buffer, int index, int count)
{
m_writer.Write(buffer, index, count);
}
///
/// Writes a string to the wrapped TextWriter
///
/// the value to write to the TextWriter
///
///
/// Writes a string to the wrapped TextWriter
///
///
override public void Write(String value)
{
m_writer.Write(value);
}
#endregion
}
}