// ========================================================================== // Squidex Headless CMS // ========================================================================== // Copyright (c) Squidex UG (haftungsbeschraenkt) // All rights reserved. Licensed under the MIT license. // ========================================================================== using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; namespace Squidex.Infrastructure.Commands { public static class Is { public static bool Change(Guid oldValue, Guid newValue) { return !Equals(oldValue, newValue); } public static bool Change(string? oldValue, string? newValue) { return !Equals(oldValue, newValue); } public static bool OptionalChange(bool oldValue, [NotNullWhen(true)] bool? newValue) { return newValue.HasValue && oldValue != newValue.Value; } public static bool OptionalChange(string oldValue, [NotNullWhen(true)] string? newValue) { return !string.IsNullOrWhiteSpace(newValue) && !string.Equals(oldValue, newValue); } public static bool OptionalChange(ISet oldValue, [NotNullWhen(true)] ISet? newValue) { return newValue != null && !newValue.SetEquals(oldValue); } public static bool OptionalChange(IReadOnlyDictionary oldValue, [NotNullWhen(true)] IReadOnlyDictionary? newValue) where TKey : notnull { return newValue != null && !newValue.EqualsDictionary(oldValue); } } }