/
githubmirror
/
PowerToys
Обзор
Документация
Войти
/
githubmirror
/
PowerToys
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/CommandAlias.cs
38 строк
1 KB
Michael Jolley
CmdPal: Make settings and app state immutable (#46451)
27 мар 2026, 20:54
Не верифицирован
27 мар 2026, 20:54
4337f8e
Код
Авторство
О чём код?
// 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 System.Text.Json.Serialization; namespace Microsoft.CmdPal.UI.ViewModels; public record CommandAlias { public string CommandId { get; init; } public string Alias { get; init; } public bool IsDirect { get; init; } [JsonIgnore] public string SearchPrefix => Alias + (IsDirect ? string.Empty : " "); public CommandAlias(string shortcut, string commandId, bool direct = false) { CommandId = commandId; Alias = shortcut; IsDirect = direct; } public CommandAlias() : this(string.Empty, string.Empty, false) { } public static CommandAlias FromSearchText(string text, string commandId) { var trailingSpace = text.EndsWith(' '); var realAlias = trailingSpace ? text.Substring(0, text.Length - 1) : text; return new CommandAlias(realAlias, commandId, !trailingSpace); } }