using System; using System.Collections.Generic; using StrixMusic.Sdk.ViewModels; using StrixMusic.Sdk.WinUI.Controls.Shells; namespace StrixMusic.Sdk.WinUI.Services.ShellManagement { /// /// Manages registered shells that the SDK can consume and display to the user. /// public static class ShellRegistry { private static readonly List _metadataRegistry = new(); private static readonly Dictionary> _coreFactories = new(); /// /// Holds all registered core metadata. /// public static IReadOnlyList MetadataRegistry => _metadataRegistry; /// /// Registers a shell with the Strix SDK. /// /// A that, given an instance ID, returns an instance of a core. /// The metadata to register for this core. public static void Register(ShellMetadata metadata, Func coreFactory) { _metadataRegistry.Add(metadata); _coreFactories.Add(metadata, coreFactory); ShellRegistered?.Invoke(null, metadata); } /// /// Raised when a new shell is registered. /// public static event EventHandler? ShellRegistered; /// /// Creates a shell instance using a registered factory. /// /// The metadata for the core to create an instance of. /// The application model root to use when constructing this shell. /// An new instance of . public static Shell CreateShell(ShellMetadata metadata, StrixDataRootViewModel dataRoot) { return _coreFactories[metadata](dataRoot); } } }