microsoft/TypeAgent
Publicmirrored fromhttps://github.com/microsoft/TypeAgentAvailable
dotnet/autoShell/Handlers/SystemCommandHandler.cs
45lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. |
| 2 | // Licensed under the MIT License. |
| 3 | |
| 4 | using System.Collections.Generic; |
| 5 | using autoShell.Services; |
| 6 | using Newtonsoft.Json.Linq; |
| 7 | |
| 8 | namespace autoShell.Handlers; |
| 9 | |
| 10 | /// <summary> |
| 11 | /// Handles system/utility commands: Debug and ToggleNotifications. |
| 12 | /// </summary> |
| 13 | internal class SystemCommandHandler : ICommandHandler |
| 14 | { |
| 15 | private readonly IProcessService _process; |
| 16 | private readonly IDebuggerService _debugger; |
| 17 | |
| 18 | public SystemCommandHandler(IProcessService process, IDebuggerService debugger) |
| 19 | { |
| 20 | _process = process; |
| 21 | _debugger = debugger; |
| 22 | } |
| 23 | |
| 24 | /// <inheritdoc/> |
| 25 | public IEnumerable<string> SupportedCommands { get; } = |
| 26 | [ |
| 27 | "Debug", |
| 28 | "ToggleNotifications", |
| 29 | ]; |
| 30 | |
| 31 | /// <inheritdoc/> |
| 32 | public void Handle(string key, string value, JToken rawValue) |
| 33 | { |
| 34 | switch (key) |
| 35 | { |
| 36 | case "Debug": |
| 37 | _debugger.Launch(); |
| 38 | break; |
| 39 | |
| 40 | case "ToggleNotifications": |
| 41 | _process.StartShellExecute("ms-actioncenter:"); |
| 42 | break; |
| 43 | } |
| 44 | } |
| 45 | } |
| 46 | |