namespace TriangleNet.Rendering.Text
{
using System;
using System.Globalization;
using System.IO;
///
/// A class allowing to specify the .
///
///
/// From http://stackoverflow.com/questions/12011789/streamwriter-and-iformatprovider
///
public class FormattingStreamWriter : StreamWriter
{
private readonly IFormatProvider formatProvider;
///
/// Initializes a new instance of the StreamWriter class for the specified file
/// by using the default encoding and buffer size.
///
/// The complete file path to write to.
public FormattingStreamWriter(string path)
: this(path, CultureInfo.InvariantCulture)
{
}
///
/// Initializes a new instance of the StreamWriter class for the specified stream
/// by using UTF-8 encoding and the default buffer size.
///
/// The stream to write to.
public FormattingStreamWriter(Stream stream)
: this(stream, CultureInfo.InvariantCulture)
{
}
///
/// Initializes a new instance of the StreamWriter class for the specified file
/// by using the default encoding and buffer size.
///
/// The complete file path to write to.
/// The format provider.
public FormattingStreamWriter(string path, IFormatProvider formatProvider)
: base(path)
{
this.formatProvider = formatProvider;
}
///
/// Initializes a new instance of the StreamWriter class for the specified stream
/// by using UTF-8 encoding and the default buffer size.
///
/// The stream to write to.
/// The format provider.
public FormattingStreamWriter(Stream stream, IFormatProvider formatProvider)
: base(stream)
{
this.formatProvider = formatProvider;
}
///
/// Gets an object that controls formatting.
///
public override IFormatProvider FormatProvider => formatProvider;
}
}