Use observable collections for solution model

This commit is contained in:
Matt Parker
2025-10-19 21:48:12 +10:00
parent b180f82b1f
commit 45df81afe6
6 changed files with 190 additions and 89 deletions

View File

@@ -0,0 +1,24 @@
using System.Collections.Specialized;
using Godot;
using ObservableCollections;
using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence;
namespace SharpIDE.Godot.Features.Common;
public class TreeItemContainer
{
public TreeItem? Value { get; set; }
}
public static class ObservableTreeExtensions
{
public static ObservableHashSet<T> WithInitialPopulation<T>(this ObservableHashSet<T> hashSet, Action<ViewChangedEvent<T, TreeItemContainer>> func) where T : class
{
foreach (var existing in hashSet)
{
var viewChangedEvent = new ViewChangedEvent<T, TreeItemContainer>(NotifyCollectionChangedAction.Add, (existing, new TreeItemContainer()), (null!, null!), 0, 0, new SortOperation<T>());
func(viewChangedEvent);
}
return hashSet;
}
}