CommandContextItem 构造函数

CommandContextItem(ICommand) 构造函数

定义

命名空间: Microsoft.CommandPalette.Extensions.Toolkit

从基 CommandItem 类初始化 CommandContextItem 类的新实例,将其 Command 属性设置为 command

public CommandContextItem(ICommand command)
        : base(command)
    {
    }

参数

命令ICommand

要与命令项关联的命令。 此参数是必需的,不能为 null。

CommandContextItem(String, String, String, Action, ICommandResult) 构造函数

定义

命名空间: Microsoft.CommandPalette.Extensions.Toolkit

从基 CommandItem 类初始化 CommandContextItem 类的新实例,将其 Title 属性设置为 title,将其 Subtitle 设置为 subtitle,并创建一个具有名称结果的新 AnonymousCommand 对象。

public CommandContextItem(
        string title,
        string subtitle = "",
        string name = "",
        Action? action = null,
        ICommandResult? result = null)
    {
        var c = new AnonymousCommand(action);
        if (!string.IsNullOrEmpty(name))
        {
            c.Name = name;
        }

        if (result != null)
        {
            c.Result = result;
        }

        Command = c;

        Title = title;
        Subtitle = subtitle;
    }

参数

title字符串

命令项的标题。

subtitle字符串

命令项的副标题。

name字符串

命令项的名称。

action

执行命令项时要执行的作。

结果ICommandResult

命令项执行的结果。 此参数是可选的,可以是 null