mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-05-25 18:16:56 +01:00
Use helper function to compare guid (#10825)
This commit is contained in:
26
src/Jellyfin.Extensions/GuidExtensions.cs
Normal file
26
src/Jellyfin.Extensions/GuidExtensions.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Jellyfin.Extensions;
|
||||
|
||||
/// <summary>
|
||||
/// Guid specific extensions.
|
||||
/// </summary>
|
||||
public static class GuidExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Determine whether the guid is default.
|
||||
/// </summary>
|
||||
/// <param name="guid">The guid.</param>
|
||||
/// <returns>Whether the guid is the default value.</returns>
|
||||
public static bool IsEmpty(this Guid guid)
|
||||
=> guid.Equals(default);
|
||||
|
||||
/// <summary>
|
||||
/// Determine whether the guid is null or default.
|
||||
/// </summary>
|
||||
/// <param name="guid">The guid.</param>
|
||||
/// <returns>Whether the guid is null or the default valueF.</returns>
|
||||
public static bool IsNullOrEmpty([NotNullWhen(false)] this Guid? guid)
|
||||
=> guid is null || guid.Value.IsEmpty();
|
||||
}
|
||||
@@ -18,7 +18,7 @@ namespace Jellyfin.Extensions.Json.Converters
|
||||
{
|
||||
// null got handled higher up the call stack
|
||||
var val = value!.Value;
|
||||
if (val.Equals(default))
|
||||
if (val.IsEmpty())
|
||||
{
|
||||
writer.WriteNullValue();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user