aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Common
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Common')
-rw-r--r--MediaBrowser.Common/Extensions/StreamExtensions.cs51
-rw-r--r--MediaBrowser.Common/Extensions/StringExtensions.cs37
-rw-r--r--MediaBrowser.Common/Json/JsonDefaults.cs1
-rw-r--r--MediaBrowser.Common/Net/NetworkExtensions.cs5
-rw-r--r--MediaBrowser.Common/Plugins/BasePlugin.cs3
5 files changed, 51 insertions, 46 deletions
diff --git a/MediaBrowser.Common/Extensions/StreamExtensions.cs b/MediaBrowser.Common/Extensions/StreamExtensions.cs
new file mode 100644
index 000000000..cd77be7b2
--- /dev/null
+++ b/MediaBrowser.Common/Extensions/StreamExtensions.cs
@@ -0,0 +1,51 @@
+#nullable enable
+
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+
+namespace MediaBrowser.Common.Extensions
+{
+ /// <summary>
+ /// Class BaseExtensions.
+ /// </summary>
+ public static class StreamExtensions
+ {
+ /// <summary>
+ /// Reads all lines in the <see cref="Stream" />.
+ /// </summary>
+ /// <param name="stream">The <see cref="Stream" /> to read from.</param>
+ /// <returns>All lines in the stream.</returns>
+ public static string[] ReadAllLines(this Stream stream)
+ => ReadAllLines(stream, Encoding.UTF8);
+
+ /// <summary>
+ /// Reads all lines in the <see cref="Stream" />.
+ /// </summary>
+ /// <param name="stream">The <see cref="Stream" /> to read from.</param>
+ /// <param name="encoding">The character encoding to use.</param>
+ /// <returns>All lines in the stream.</returns>
+ public static string[] ReadAllLines(this Stream stream, Encoding encoding)
+ {
+ using (StreamReader reader = new StreamReader(stream, encoding))
+ {
+ return ReadAllLines(reader).ToArray();
+ }
+ }
+
+ /// <summary>
+ /// Reads all lines in the <see cref="StreamReader" />.
+ /// </summary>
+ /// <param name="reader">The <see cref="StreamReader" /> to read from.</param>
+ /// <returns>All lines in the stream.</returns>
+ public static IEnumerable<string> ReadAllLines(this StreamReader reader)
+ {
+ string? line;
+ while ((line = reader.ReadLine()) != null)
+ {
+ yield return line;
+ }
+ }
+ }
+}
diff --git a/MediaBrowser.Common/Extensions/StringExtensions.cs b/MediaBrowser.Common/Extensions/StringExtensions.cs
deleted file mode 100644
index 764301741..000000000
--- a/MediaBrowser.Common/Extensions/StringExtensions.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-#nullable enable
-
-using System;
-
-namespace MediaBrowser.Common.Extensions
-{
- /// <summary>
- /// Extensions methods to simplify string operations.
- /// </summary>
- public static class StringExtensions
- {
- /// <summary>
- /// Returns the part on the left of the <c>needle</c>.
- /// </summary>
- /// <param name="haystack">The string to seek.</param>
- /// <param name="needle">The needle to find.</param>
- /// <returns>The part left of the <paramref name="needle" />.</returns>
- public static ReadOnlySpan<char> LeftPart(this ReadOnlySpan<char> haystack, char needle)
- {
- var pos = haystack.IndexOf(needle);
- return pos == -1 ? haystack : haystack[..pos];
- }
-
- /// <summary>
- /// Returns the part on the left of the <c>needle</c>.
- /// </summary>
- /// <param name="haystack">The string to seek.</param>
- /// <param name="needle">The needle to find.</param>
- /// <param name="stringComparison">One of the enumeration values that specifies the rules for the search.</param>
- /// <returns>The part left of the <c>needle</c>.</returns>
- public static ReadOnlySpan<char> LeftPart(this ReadOnlySpan<char> haystack, ReadOnlySpan<char> needle, StringComparison stringComparison = default)
- {
- var pos = haystack.IndexOf(needle, stringComparison);
- return pos == -1 ? haystack : haystack[..pos];
- }
- }
-}
diff --git a/MediaBrowser.Common/Json/JsonDefaults.cs b/MediaBrowser.Common/Json/JsonDefaults.cs
index 9a2ea6875..2ef24a884 100644
--- a/MediaBrowser.Common/Json/JsonDefaults.cs
+++ b/MediaBrowser.Common/Json/JsonDefaults.cs
@@ -31,7 +31,6 @@ namespace MediaBrowser.Common.Json
WriteIndented = false,
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
NumberHandling = JsonNumberHandling.AllowReadingFromString,
- PropertyNameCaseInsensitive = true,
Converters =
{
new JsonGuidConverter(),
diff --git a/MediaBrowser.Common/Net/NetworkExtensions.cs b/MediaBrowser.Common/Net/NetworkExtensions.cs
index d07bba249..9c1a0cf49 100644
--- a/MediaBrowser.Common/Net/NetworkExtensions.cs
+++ b/MediaBrowser.Common/Net/NetworkExtensions.cs
@@ -1,11 +1,6 @@
-#pragma warning disable CA1062 // Validate arguments of public methods
using System;
-using System.Collections;
-using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Net;
-using System.Runtime.CompilerServices;
-using System.Text;
namespace MediaBrowser.Common.Net
{
diff --git a/MediaBrowser.Common/Plugins/BasePlugin.cs b/MediaBrowser.Common/Plugins/BasePlugin.cs
index e228ae7ec..7b162c0e1 100644
--- a/MediaBrowser.Common/Plugins/BasePlugin.cs
+++ b/MediaBrowser.Common/Plugins/BasePlugin.cs
@@ -1,10 +1,7 @@
using System;
using System.IO;
using System.Reflection;
-using System.Runtime.InteropServices;
-using MediaBrowser.Common.Configuration;
using MediaBrowser.Model.Plugins;
-using MediaBrowser.Model.Serialization;
namespace MediaBrowser.Common.Plugins
{