mirror of https://github.com/Squidex/squidex.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.6 KiB
46 lines
1.6 KiB
// ==========================================================================
|
|
// 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<T>(ISet<T> oldValue, [NotNullWhen(true)] ISet<T>? newValue)
|
|
{
|
|
return newValue != null && !newValue.SetEquals(oldValue);
|
|
}
|
|
|
|
public static bool OptionalChange<TKey, TValue>(IReadOnlyDictionary<TKey, TValue> oldValue, [NotNullWhen(true)] IReadOnlyDictionary<TKey, TValue>? newValue) where TKey : notnull
|
|
{
|
|
return newValue != null && !newValue.EqualsDictionary(oldValue);
|
|
}
|
|
}
|
|
}
|