#nullable enable using System; using System.Collections.Generic; using Cysharp.Threading.Tasks; using ShrinkApp; namespace ShrinkContext.AppAdapter; public sealed class ShrinkContextAppHost { private readonly ShrinkContextRuntime _runtime = new(); private readonly ShrinkComponentCatalog _catalog = new(); private readonly ShrinkContextLoader _loader; public ShrinkContextAppHost(ShrinkAppServices? services = null) { Services = services ?? new ShrinkAppServices(); _loader = new ShrinkContextLoader(_runtime, _catalog); } public ShrinkAppServices Services { get; } public ShrinkContextRuntime Runtime => _runtime; public ShrinkLoaderTransactionDiagnostic? LastTransaction => _loader.LastTransaction; public void Register(string name, Func factory) => _catalog.Register(name, factory); public void Register(string name) where TComponent : IShrinkComponent, new() => _catalog.Register(name); public UniTask ApplyAsync(IReadOnlyList entries) => _loader.ApplyAsync(entries); public UniTask ShutdownAsync() => _runtime.ShutdownAsync(); }