microsoft/TypeAgent
Publicmirrored fromhttps://github.com/microsoft/TypeAgentAvailable
dotnet/uiAutomationHelper/src/Program.cs
32lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. |
| 2 | // Licensed under the MIT License. |
| 3 | |
| 4 | using System.Text; |
| 5 | using UiAutomationHelper.Methods; |
| 6 | using UiAutomationHelper.Rpc; |
| 7 | |
| 8 | namespace UiAutomationHelper; |
| 9 | |
| 10 | internal static class Program |
| 11 | { |
| 12 | public static async Task<int> Main(string[] args) |
| 13 | { |
| 14 | Console.InputEncoding = Encoding.UTF8; |
| 15 | Console.OutputEncoding = Encoding.UTF8; |
| 16 | |
| 17 | using var cts = new CancellationTokenSource(); |
| 18 | Console.CancelKeyPress += (_, e) => |
| 19 | { |
| 20 | e.Cancel = true; |
| 21 | cts.Cancel(); |
| 22 | }; |
| 23 | |
| 24 | var dispatch = new Dispatch(); |
| 25 | Methods.Register.All(dispatch); |
| 26 | |
| 27 | var server = new JsonRpcServer(Console.In, Console.Out, dispatch); |
| 28 | Notifier.Init(server); |
| 29 | await server.RunAsync(cts.Token).ConfigureAwait(false); |
| 30 | return 0; |
| 31 | } |
| 32 | } |
| 33 | |