mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 19:57:57 +01:00
31 lines
1.0 KiB
C#
31 lines
1.0 KiB
C#
// Copyright (c) Microsoft Corporation
|
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
using Microsoft.CmdPal.Core.ViewModels;
|
|
using Microsoft.CommandPalette.Extensions;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace Microsoft.CmdPal.UI.ViewModels;
|
|
|
|
public class CommandPalettePageViewModelFactory
|
|
: IPageViewModelFactoryService
|
|
{
|
|
private readonly TaskScheduler _scheduler;
|
|
|
|
public CommandPalettePageViewModelFactory(TaskScheduler scheduler)
|
|
{
|
|
_scheduler = scheduler;
|
|
}
|
|
|
|
public PageViewModel? TryCreatePageViewModel(IPage page, bool nested, AppExtensionHost host, ILogger logger)
|
|
{
|
|
return page switch
|
|
{
|
|
IListPage listPage => new ListViewModel(listPage, _scheduler, host, logger) { IsNested = nested },
|
|
IContentPage contentPage => new CommandPaletteContentPageViewModel(contentPage, _scheduler, host, logger),
|
|
_ => null,
|
|
};
|
|
}
|
|
}
|