| 1 | using CascadeIDE.Contracts; |
| 2 | using CascadeIDE.Models; |
| 3 | |
| 4 | namespace CascadeIDE.Features.Workspace.Application; |
| 5 | |
| 6 | /// <summary> |
| 7 | /// Применение успешной загрузки дерева решения к <see cref="SolutionWorkspaceViewModel"/> и хосту (документы, редактор, MFD). |
| 8 | /// </summary> |
| 9 | [PresentationProjection("solution load session apply")] |
| 10 | public static class SolutionLoadSessionApplyProjection |
| 11 | { |
| 12 | /// <summary>Мутации главного окна, которые нельзя держать в workspace VM.</summary> |
| 13 | public interface IHost |
| 14 | { |
| 15 | void ResetEditorSessionForNewSolution(); |
| 16 | |
| 17 | void AfterSolutionApplied(MfdShellPage initialMfdPage); |
| 18 | } |
| 19 | |
| 20 | public static void ApplySuccessfulLoad( |
| 21 | SolutionWorkspaceViewModel workspace, |
| 22 | SolutionItem root, |
| 23 | string originalPath, |
| 24 | string? normalizedSolutionPath, |
| 25 | bool isDockedMfdSolutionExplorerTree, |
| 26 | PresentationTierKind presentationTier, |
| 27 | IHost host) |
| 28 | { |
| 29 | var plan = SolutionLoadUiApplyProjection.Create( |
| 30 | originalPath, |
| 31 | normalizedSolutionPath, |
| 32 | isDockedMfdSolutionExplorerTree, |
| 33 | presentationTier); |
| 34 | |
| 35 | SolutionTreeExpansionPolicy.ApplyDefaultExpansion([root]); |
| 36 | host.ResetEditorSessionForNewSolution(); |
| 37 | workspace.SelectedSolutionItem = null; |
| 38 | workspace.SolutionPath = plan.NormalizedSolutionPath; |
| 39 | workspace.SolutionRoots.Clear(); |
| 40 | workspace.SolutionRoots.Add(root); |
| 41 | host.AfterSolutionApplied(plan.InitialMfdPage); |
| 42 | } |
| 43 | } |
| 44 | |