PalacePal/Pal.Client/Commands/PalTestConnectionCommand.cs

30 lines
745 B
C#
Raw Normal View History

2023-02-24 23:55:48 +00:00
using System;
using System.Collections.Generic;
using ECommons.Schedulers;
using Pal.Client.Windows;
2023-03-30 20:01:43 +00:00
namespace Pal.Client.Commands;
internal sealed class PalTestConnectionCommand : ISubCommand
{
2023-03-30 20:01:43 +00:00
private readonly ConfigWindow _configWindow;
public PalTestConnectionCommand(ConfigWindow configWindow)
{
2023-03-30 20:01:43 +00:00
_configWindow = configWindow;
}
2023-03-30 20:01:43 +00:00
public IReadOnlyDictionary<string, Action<string>> GetHandlers()
=> new Dictionary<string, Action<string>>
{
2023-03-30 20:01:43 +00:00
{ "test-connection", _ => Execute() },
{ "tc", _ => Execute() },
};
2023-03-30 20:01:43 +00:00
private void Execute()
{
_configWindow.IsOpen = true;
var _ = new TickScheduler(() => _configWindow.TestConnection());
}
}