-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
handle deleted semantic domains and part of speech in CreateSenseChange
- Loading branch information
Showing
2 changed files
with
30 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using SIL.Harmony.Changes; | ||
|
||
namespace LcmCrdt.Utils; | ||
|
||
public static class ChangeContextHelpers | ||
{ | ||
public static async ValueTask<bool> IsObjectDeleted(this ChangeContext context, Guid? entityId) | ||
{ | ||
return entityId is null || await context.IsObjectDeleted(entityId.Value); | ||
} | ||
|
||
public static async ValueTask<Guid?> DeletedAsNull(this ChangeContext context, Guid? entityId) | ||
{ | ||
if (entityId is null) return null; | ||
return await context.IsObjectDeleted(entityId.Value) ? null : entityId; | ||
} | ||
|
||
public static async IAsyncEnumerable<T> FilterDeleted<T>(this ChangeContext context, IEnumerable<T> entities) | ||
where T : IObjectWithId | ||
{ | ||
foreach (var objectWithId in entities) | ||
{ | ||
if (await context.IsObjectDeleted(objectWithId.Id)) continue; | ||
yield return objectWithId; | ||
} | ||
} | ||
} |