aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Common/Extensions/StreamExtensions.cs
diff options
context:
space:
mode:
authorBaronGreenback <jimcartlidge@yahoo.co.uk>2021-05-08 12:22:09 +0100
committerBaronGreenback <jimcartlidge@yahoo.co.uk>2021-05-08 12:22:09 +0100
commit7185de970c2abef0255ca1ce5321c5d841ddefb8 (patch)
tree1f84882205d234a00057c9542c50bd1fab0cb4bf /MediaBrowser.Common/Extensions/StreamExtensions.cs
parentdca02987106d0433ee4139fb380dd78d92921dae (diff)
parentd4a50be22c3c4b9bb0adfb957ee558287fd219d9 (diff)
Merge remote-tracking branch 'upstream/master' into UrlDecoding
Diffstat (limited to 'MediaBrowser.Common/Extensions/StreamExtensions.cs')
-rw-r--r--MediaBrowser.Common/Extensions/StreamExtensions.cs22
1 files changed, 17 insertions, 5 deletions
diff --git a/MediaBrowser.Common/Extensions/StreamExtensions.cs b/MediaBrowser.Common/Extensions/StreamExtensions.cs
index cd77be7b2..5cbf57d98 100644
--- a/MediaBrowser.Common/Extensions/StreamExtensions.cs
+++ b/MediaBrowser.Common/Extensions/StreamExtensions.cs
@@ -1,5 +1,3 @@
-#nullable enable
-
using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -35,11 +33,11 @@ namespace MediaBrowser.Common.Extensions
}
/// <summary>
- /// Reads all lines in the <see cref="StreamReader" />.
+ /// Reads all lines in the <see cref="TextReader" />.
/// </summary>
- /// <param name="reader">The <see cref="StreamReader" /> to read from.</param>
+ /// <param name="reader">The <see cref="TextReader" /> to read from.</param>
/// <returns>All lines in the stream.</returns>
- public static IEnumerable<string> ReadAllLines(this StreamReader reader)
+ public static IEnumerable<string> ReadAllLines(this TextReader reader)
{
string? line;
while ((line = reader.ReadLine()) != null)
@@ -47,5 +45,19 @@ namespace MediaBrowser.Common.Extensions
yield return line;
}
}
+
+ /// <summary>
+ /// Reads all lines in the <see cref="TextReader" />.
+ /// </summary>
+ /// <param name="reader">The <see cref="TextReader" /> to read from.</param>
+ /// <returns>All lines in the stream.</returns>
+ public static async IAsyncEnumerable<string> ReadAllLinesAsync(this TextReader reader)
+ {
+ string? line;
+ while ((line = await reader.ReadLineAsync().ConfigureAwait(false)) != null)
+ {
+ yield return line;
+ }
+ }
}
}