ファイル
YMM4-UndoTree/UndoTree/UndoTreeSelectionLink.cs
T

21 行
625 B
C#

namespace UndoTree;
internal static class UndoTreeSelectionLink
{
public static IReadOnlyList<object> ItemsOf(UndoTreeNodeViewModel node, UndoTreeOwners owners, Func<object, bool> isItem)
{
var items = new List<object>();
foreach (var command in node.Commands)
{
if (command.Target is not { } target)
continue;
var item = owners.OwnersOf(target).Append(target).LastOrDefault(isItem);
if (item is not null && !items.Any(existing => ReferenceEquals(existing, item)))
items.Add(item);
}
return items;
}
}