aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Jellyfin.Extensions/FormattingStreamWriter.cs38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/Jellyfin.Extensions/FormattingStreamWriter.cs b/src/Jellyfin.Extensions/FormattingStreamWriter.cs
new file mode 100644
index 000000000..40e3c5a68
--- /dev/null
+++ b/src/Jellyfin.Extensions/FormattingStreamWriter.cs
@@ -0,0 +1,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;
+}