AyCode.Core/AyCode.Utils/Extensions/GuidExtensions.cs

17 lines
695 B
C#

using JetBrains.Annotations;
using System.Diagnostics.CodeAnalysis;
namespace AyCode.Utils.Extensions
{
public static class GuidExtensions
{
//[ContractAnnotation("=> true, result: notnull; => false, result: null")]
//[ContractAnnotation("true => null; false => notnull")]
public static bool IsNullOrEmpty([NotNullWhen(false)] this Guid guid) => guid == Guid.Empty;
//[ContractAnnotation("=> true, result: notnull; => false, result: null")]
//[ContractAnnotation("guid:null => true; guid:notnull <= false")]
public static bool IsNullOrEmpty([NotNullWhen(false)] this Guid? guid) => guid == null || guid == Guid.Empty;
}
}