diff options
Diffstat (limited to 'MediaBrowser.Common')
| -rw-r--r-- | MediaBrowser.Common/Json/Converters/JsonGuidConverter.cs | 11 | ||||
| -rw-r--r-- | MediaBrowser.Common/Json/Converters/JsonVersionConverter.cs | 20 | ||||
| -rw-r--r-- | MediaBrowser.Common/Json/JsonDefaults.cs | 1 | ||||
| -rw-r--r-- | MediaBrowser.Common/Net/INetworkManager.cs | 12 |
4 files changed, 37 insertions, 7 deletions
diff --git a/MediaBrowser.Common/Json/Converters/JsonGuidConverter.cs b/MediaBrowser.Common/Json/Converters/JsonGuidConverter.cs index d35a761f35..54325a02b0 100644 --- a/MediaBrowser.Common/Json/Converters/JsonGuidConverter.cs +++ b/MediaBrowser.Common/Json/Converters/JsonGuidConverter.cs @@ -15,6 +15,15 @@ namespace MediaBrowser.Common.Json.Converters /// <inheritdoc /> public override void Write(Utf8JsonWriter writer, Guid value, JsonSerializerOptions options) - => writer.WriteStringValue(value); + { + if (value == Guid.Empty) + { + writer.WriteNullValue(); + } + else + { + writer.WriteStringValue(value); + } + } } } diff --git a/MediaBrowser.Common/Json/Converters/JsonVersionConverter.cs b/MediaBrowser.Common/Json/Converters/JsonVersionConverter.cs new file mode 100644 index 0000000000..37e6f64e34 --- /dev/null +++ b/MediaBrowser.Common/Json/Converters/JsonVersionConverter.cs @@ -0,0 +1,20 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace MediaBrowser.Common.Json.Converters +{ + /// <summary> + /// Converts a Version object or value to/from JSON. + /// </summary> + public class JsonVersionConverter : JsonConverter<Version> + { + /// <inheritdoc /> + public override Version Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + => new Version(reader.GetString()); + + /// <inheritdoc /> + public override void Write(Utf8JsonWriter writer, Version value, JsonSerializerOptions options) + => writer.WriteStringValue(value.ToString()); + } +} diff --git a/MediaBrowser.Common/Json/JsonDefaults.cs b/MediaBrowser.Common/Json/JsonDefaults.cs index 9a94664acc..1aaf4a43bb 100644 --- a/MediaBrowser.Common/Json/JsonDefaults.cs +++ b/MediaBrowser.Common/Json/JsonDefaults.cs @@ -40,6 +40,7 @@ namespace MediaBrowser.Common.Json }; options.Converters.Add(new JsonGuidConverter()); + options.Converters.Add(new JsonVersionConverter()); options.Converters.Add(new JsonStringEnumConverter()); options.Converters.Add(new JsonNullableStructConverterFactory()); options.Converters.Add(new JsonDateTimeIso8601Converter()); diff --git a/MediaBrowser.Common/Net/INetworkManager.cs b/MediaBrowser.Common/Net/INetworkManager.cs index 43562afe38..b6c390d239 100644 --- a/MediaBrowser.Common/Net/INetworkManager.cs +++ b/MediaBrowser.Common/Net/INetworkManager.cs @@ -149,7 +149,7 @@ namespace MediaBrowser.Common.Net /// <summary> /// Returns true if the address is a private address. - /// The config option TrustIP6Interfaces overrides this functions behaviour. + /// The configuration option TrustIP6Interfaces overrides this functions behaviour. /// </summary> /// <param name="address">Address to check.</param> /// <returns>True or False.</returns> @@ -157,7 +157,7 @@ namespace MediaBrowser.Common.Net /// <summary> /// Returns true if the address is part of the user defined LAN. - /// The config option TrustIP6Interfaces overrides this functions behaviour. + /// The configuration option TrustIP6Interfaces overrides this functions behaviour. /// </summary> /// <param name="address">IP to check.</param> /// <returns>True if endpoint is within the LAN range.</returns> @@ -165,7 +165,7 @@ namespace MediaBrowser.Common.Net /// <summary> /// Returns true if the address is part of the user defined LAN. - /// The config option TrustIP6Interfaces overrides this functions behaviour. + /// The configuration option TrustIP6Interfaces overrides this functions behaviour. /// </summary> /// <param name="address">IP to check.</param> /// <returns>True if endpoint is within the LAN range.</returns> @@ -173,7 +173,7 @@ namespace MediaBrowser.Common.Net /// <summary> /// Returns true if the address is part of the user defined LAN. - /// The config option TrustIP6Interfaces overrides this functions behaviour. + /// The configuration option TrustIP6Interfaces overrides this functions behaviour. /// </summary> /// <param name="address">IP to check.</param> /// <returns>True if endpoint is within the LAN range.</returns> @@ -192,9 +192,9 @@ namespace MediaBrowser.Common.Net /// Parses an array of strings into a Collection{IPObject}. /// </summary> /// <param name="values">Values to parse.</param> - /// <param name="bracketed">When true, only include values in []. When false, ignore bracketed values.</param> + /// <param name="negated">When true, only include values beginning with !. When false, ignore ! values.</param> /// <returns>IPCollection object containing the value strings.</returns> - Collection<IPObject> CreateIPCollection(string[] values, bool bracketed = false); + Collection<IPObject> CreateIPCollection(string[] values, bool negated = false); /// <summary> /// Returns all the internal Bind interface addresses. |
