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