CommandPaletteContentPageViewModel.cs
1 // Copyright (c) Microsoft Corporation 2 // The Microsoft Corporation licenses this file to you under the MIT license. 3 // See the LICENSE file in the project root for more information. 4 5 using Microsoft.CmdPal.Core.ViewModels; 6 using Microsoft.CommandPalette.Extensions; 7 8 namespace Microsoft.CmdPal.UI.ViewModels; 9 10 public partial class CommandPaletteContentPageViewModel : ContentPageViewModel 11 { 12 public CommandPaletteContentPageViewModel(IContentPage model, TaskScheduler scheduler, AppExtensionHost host) 13 : base(model, scheduler, host) 14 { 15 } 16 17 public override ContentViewModel? ViewModelFromContent(IContent content, WeakReference<IPageContext> context) 18 { 19 ContentViewModel? viewModel = content switch 20 { 21 IFormContent form => new ContentFormViewModel(form, context), 22 IMarkdownContent markdown => new ContentMarkdownViewModel(markdown, context), 23 ITreeContent tree => new ContentTreeViewModel(tree, context), 24 _ => null, 25 }; 26 return viewModel; 27 } 28 }