diff options
| author | Bond-009 <bond.009@outlook.com> | 2021-05-06 17:10:41 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-05-06 17:10:41 +0200 |
| commit | 4b31c007e3afea329d41b6bda7a5de1f53db2a95 (patch) | |
| tree | 85df78a91653216062cdd9cf52963baa141242fb /MediaBrowser.Common/Extensions/StreamExtensions.cs | |
| parent | 95b1cf532b577aa744d5301af4eeb78d08da3ba8 (diff) | |
| parent | ddb04dc12b8bdf33c2020cb1c539664463e61bc3 (diff) | |
Merge pull request #4986 from Bond-009/readalllines
Use new ReadAllLines extensions
Diffstat (limited to 'MediaBrowser.Common/Extensions/StreamExtensions.cs')
| -rw-r--r-- | MediaBrowser.Common/Extensions/StreamExtensions.cs | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/MediaBrowser.Common/Extensions/StreamExtensions.cs b/MediaBrowser.Common/Extensions/StreamExtensions.cs index cd77be7b2..d49bf1d46 100644 --- a/MediaBrowser.Common/Extensions/StreamExtensions.cs +++ b/MediaBrowser.Common/Extensions/StreamExtensions.cs @@ -35,11 +35,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 +47,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; + } + } } } |
