Use new ReadAllLines extensions

This commit is contained in:
Bond_009
2021-01-08 23:57:27 +01:00
parent 95b1cf532b
commit ddb04dc12b
7 changed files with 48 additions and 51 deletions

View File

@@ -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;
}
}
}
}