aboutsummaryrefslogtreecommitdiff
path: root/src/Jellyfin.Extensions
diff options
context:
space:
mode:
authorBond-009 <bond.009@outlook.com>2024-09-07 18:09:52 -0400
committerJoshua M. Boniface <joshua@boniface.me>2024-09-07 18:09:52 -0400
commit7631956451af5927c1c9850eb4e106dc4d0cdde1 (patch)
treec80d3cc48f88f3ed60e5c43de6955e02ee9aeeee /src/Jellyfin.Extensions
parentc7bb2fe137aea5b819a86eb50bd51f094135c546 (diff)
Backport pull request #12550 from jellyfin/release-10.9.z
Create and use FormattingStreamWriter Original-merge: cd2f2ca17800f71c8d94a6e043b49b7c4200e254 Merged-by: Bond-009 <bond.009@outlook.com> Backported-by: Joshua M. Boniface <joshua@boniface.me>
Diffstat (limited to 'src/Jellyfin.Extensions')
-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;
+}