-
Notifications
You must be signed in to change notification settings - Fork 444
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
96 changed files
with
1,224 additions
and
201 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
backend/src/Squidex.Domain.Apps.Core.Model/Contents/Updates.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// ========================================================================== | ||
// Squidex Headless CMS | ||
// ========================================================================== | ||
// Copyright (c) Squidex UG (haftungsbeschraenkt) | ||
// All rights reserved. Licensed under the MIT license. | ||
// ========================================================================== | ||
|
||
using Squidex.Infrastructure.Json.Objects; | ||
|
||
namespace Squidex.Domain.Apps.Core.Contents; | ||
|
||
public static class Updates | ||
{ | ||
public static bool IsUnset(object? value) | ||
{ | ||
if (value is JsonValue json) | ||
{ | ||
return IsUnset(json.Value); | ||
} | ||
|
||
return value is IReadOnlyDictionary<string, JsonValue> obj && IsUnset(obj); | ||
} | ||
|
||
public static bool IsUnset(IReadOnlyDictionary<string, JsonValue>? obj) | ||
{ | ||
return | ||
obj is { Count: 1 } && | ||
obj.TryGetValue("$unset", out var item) && | ||
Equals(item.Value, true); | ||
} | ||
|
||
public static bool IsUpdate(object? value, out string expression) | ||
{ | ||
expression = null!; | ||
|
||
if (value is JsonValue json) | ||
{ | ||
return IsUpdate(json.Value, out expression); | ||
} | ||
|
||
return value is IReadOnlyDictionary<string, JsonValue> obj && IsUpdate(obj, out expression); | ||
} | ||
|
||
public static bool IsUpdate(IReadOnlyDictionary<string, JsonValue>? obj, out string expression) | ||
{ | ||
expression = null!; | ||
|
||
if (obj is { Count: > 0 } && | ||
obj.TryGetValue("$update", out var item) && | ||
item.Value is string e && | ||
!string.IsNullOrWhiteSpace(e)) | ||
{ | ||
expression = e; | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.