mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-21 09:34:44 +01:00
Add TryReadInt to XmlReaderExtensions
This commit is contained in:
@@ -26,6 +26,19 @@ public static class XmlReaderExtensions
|
||||
return reader.ReadElementContentAsString().Trim();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads an int from the current node.
|
||||
/// </summary>
|
||||
/// <param name="reader">The <see cref="XmlReader"/>.</param>
|
||||
/// <param name="value">The parsed <c>int</c>.</param>
|
||||
/// <returns>A value indicating whether the parsing succeeded.</returns>
|
||||
public static bool TryReadInt(this XmlReader reader, out int value)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(reader);
|
||||
|
||||
return int.TryParse(reader.ReadElementContentAsString(), CultureInfo.InvariantCulture, out value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parses a <see cref="DateTime"/> from the current node.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user