A method to find all links for an assert UUID

This commit is contained in:
Mei Lin
2025-08-27 20:22:03 +02:00
parent 7e08c44344
commit ea3198e4f1

View File

@@ -190,6 +190,32 @@ namespace OpenMetaverse
Items = new ConcurrentDictionary<UUID, InventoryNode>();
}
/// <summary>
/// Returns all links of that link the specific <paramref name="assertId"/>.
/// </summary>
/// <param name="assertId">An inventory items assert UUID.</param>
/// <returns></returns>
public List<InventoryNode> FindAllLinks(UUID assertId)
{
List<InventoryNode> links = new List<InventoryNode>();
lock (RootNode.Nodes.SyncRoot)
{
links = Items.Values.Where(node => IsLinkOf(node, assertId)).ToList();
}
return links;
}
private static bool IsLinkOf(InventoryNode node, UUID assertId)
{
if (node.Data is InventoryItem item && item.AssetType == AssetType.Link)
{
return item.ActualUUID == assertId;
}
return false;
}
public List<InventoryBase> GetContents(InventoryFolder folder)
{
return GetContents(folder.UUID);