3f10f86307
git-svn-id: https://triangle.svn.codeplex.com/svn@79411 0e2699bc-83d4-4a8f-98e7-55e24ab8c7a5
74 lines
2.5 KiB
C#
74 lines
2.5 KiB
C#
|
|
namespace TriangleNet.Rendering.Text
|
|
{
|
|
using System;
|
|
using System.Globalization;
|
|
using System.IO;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// From http://stackoverflow.com/questions/12011789/streamwriter-and-iformatprovider
|
|
/// </remarks>
|
|
public class FormattingStreamWriter : StreamWriter
|
|
{
|
|
private readonly IFormatProvider formatProvider;
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the StreamWriter class for the specified file
|
|
/// by using the default encoding and buffer size.
|
|
/// </summary>
|
|
/// <param name="path">The complete file path to write to.</param>
|
|
public FormattingStreamWriter(string path)
|
|
: this(path, CultureInfo.InvariantCulture)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the StreamWriter class for the specified stream
|
|
/// by using UTF-8 encoding and the default buffer size.
|
|
/// </summary>
|
|
/// <param name="stream">The stream to write to.</param>
|
|
public FormattingStreamWriter(Stream stream)
|
|
: this(stream, CultureInfo.InvariantCulture)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the StreamWriter class for the specified file
|
|
/// by using the default encoding and buffer size.
|
|
/// </summary>
|
|
/// <param name="path">The complete file path to write to.</param>
|
|
/// <param name="formatProvider">The format provider.</param>
|
|
public FormattingStreamWriter(string path, IFormatProvider formatProvider)
|
|
: base(path)
|
|
{
|
|
this.formatProvider = formatProvider;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the StreamWriter class for the specified stream
|
|
/// by using UTF-8 encoding and the default buffer size.
|
|
/// </summary>
|
|
/// <param name="stream">The stream to write to.</param>
|
|
/// <param name="formatProvider">The format provider.</param>
|
|
public FormattingStreamWriter(Stream stream, IFormatProvider formatProvider)
|
|
: base(stream)
|
|
{
|
|
this.formatProvider = formatProvider;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets an object that controls formatting.
|
|
/// </summary>
|
|
public override IFormatProvider FormatProvider
|
|
{
|
|
get
|
|
{
|
|
return this.formatProvider;
|
|
}
|
|
}
|
|
}
|
|
}
|