Headless CMS and Content Managment Hub
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.
 
 
 
 
 

39 lines
1.2 KiB

// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschraenkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System;
using System.Collections.Generic;
using Squidex.Infrastructure.Json.Objects;
namespace Squidex.Domain.Apps.Core.ExtractReferenceIds
{
public static class ReferencesExtensions
{
public static void AddIds(this IJsonValue? value, HashSet<Guid> result, int take)
{
var added = 0;
if (value is JsonArray array)
{
foreach (var id in array)
{
if (id.Type == JsonValueType.String && Guid.TryParse(id.ToString(), out var guid))
{
result.Add(guid);
added++;
if (added >= take)
{
break;
}
}
}
}
}
}
}