// 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.UI.ViewModels.Models; using Microsoft.CommandPalette.Extensions; namespace Microsoft.CmdPal.UI.ViewModels.Messages; /// /// Used to do a command - navigate to a page or invoke it /// public record PerformCommandMessage { public ExtensionObject Command { get; } public object? Context { get; } public bool WithAnimation { get; set; } = true; public CommandPaletteHost? ExtensionHost { get; private set; } public PerformCommandMessage(ExtensionObject command) { Command = command; Context = null; } public PerformCommandMessage(TopLevelViewModel topLevelCommand) { Command = topLevelCommand.CommandViewModel.Model; Context = null; ExtensionHost = topLevelCommand.ExtensionHost; } public PerformCommandMessage(ExtensionObject command, ExtensionObject context) { Command = command; Context = context.Unsafe; } public PerformCommandMessage(ExtensionObject command, ExtensionObject context) { Command = command; Context = context.Unsafe; } public PerformCommandMessage(ExtensionObject command, ExtensionObject context) { Command = command; Context = context.Unsafe; } public PerformCommandMessage(CommandContextItemViewModel contextCommand) { Command = contextCommand.Command.Model; Context = contextCommand.Model.Unsafe; } public PerformCommandMessage(ConfirmResultViewModel vm) { Command = vm.PrimaryCommand.Model; Context = null; } }