blob: 40e3c5a68f69921287b31477f2b851e642cee94d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
using System;
using System.IO;
namespace Jellyfin.Extensions;
/// <summary>
/// A custom StreamWriter which supports setting a IFormatProvider.
/// </summary>
public class FormattingStreamWriter : StreamWriter
{
private readonly IFormatProvider _formatProvider;
/// <summary>
/// Initializes a new instance of the <see cref="FormattingStreamWriter"/> class.
/// </summary>
/// <param name="stream">The stream to write to.</param>
/// <param name="formatProvider">The format provider to use.</param>
public FormattingStreamWriter(Stream stream, IFormatProvider formatProvider)
: base(stream)
{
_formatProvider = formatProvider;
}
/// <summary>
/// Initializes a new instance of the <see cref="FormattingStreamWriter"/> class.
/// </summary>
/// <param name="path">The complete file path to write to.</param>
/// <param name="formatProvider">The format provider to use.</param>
public FormattingStreamWriter(string path, IFormatProvider formatProvider)
: base(path)
{
_formatProvider = formatProvider;
}
/// <inheritdoc />
public override IFormatProvider FormatProvider
=> _formatProvider;
}
|