Repository navigation
Expand file tree
/
Copy pathRunCommandDefinition.cs
More file actions
68 lines (57 loc) · 2.25 KB
/
Copy pathRunCommandDefinition.cs
File metadata and controls
68 lines (57 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using System;
using System.Collections.Generic;
using System.Linq;
namespace NETworkManager.Models.RunCommand;
/// <summary>
/// Command of the run command dialog (e.g. "dnslookup" with the alias "dns"), which opens an application or the
/// settings.
/// </summary>
public sealed class RunCommandDefinition
{
/// <summary>
/// Whether the command opens an application or the settings.
/// </summary>
public RunCommandType Type { get; init; }
/// <summary>
/// Application to open (<see cref="ApplicationName.None" /> for the settings).
/// </summary>
public ApplicationName Application { get; init; }
/// <summary>
/// Command (lowercase, e.g. "dnslookup").
/// </summary>
public string Command { get; init; }
/// <summary>
/// Short forms of the command (lowercase, e.g. "dns", "nslookup").
/// </summary>
public IReadOnlyList<string> Aliases { get; init; } = [];
/// <summary>
/// The command accepts a target (e.g. host, IP range, query).
/// </summary>
public bool SupportsTarget { get; init; }
/// <summary>
/// The command accepts a profile ("@name") instead of a target.
/// </summary>
public bool SupportsProfile { get; init; }
/// <summary>
/// Second argument after the target (e.g. ports or DNS server).
/// </summary>
public RunCommandArgument Argument { get; init; }
/// <summary>
/// Type keywords that can follow the target (lowercase, e.g. "a", "aaaa" for the DNS lookup).
/// </summary>
public IReadOnlyList<string> Types { get; init; } = [];
/// <summary>
/// Syntax of the arguments for the hint (e.g. "<hosts> [server] [type]"), empty if there are none.
/// </summary>
public string Syntax { get; init; } = string.Empty;
/// <summary>
/// Checks if the text is the command or one of its aliases (case-insensitive).
/// </summary>
/// <param name="text">Command text.</param>
/// <returns>True if the text matches.</returns>
public bool Matches(string text)
{
return string.Equals(Command, text, StringComparison.OrdinalIgnoreCase) ||
Aliases.Any(x => string.Equals(x, text, StringComparison.OrdinalIgnoreCase));
}
}