aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.Common/Console/DefaultConsoleEngineService.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common/Console/DefaultConsoleEngineService.cs')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/Console/DefaultConsoleEngineService.cs45
1 files changed, 45 insertions, 0 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Console/DefaultConsoleEngineService.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Console/DefaultConsoleEngineService.cs
new file mode 100644
index 000000000..431545c33
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Console/DefaultConsoleEngineService.cs
@@ -0,0 +1,45 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.Console;
+using Tango.Core.DI;
+using Tango.Integration.ExternalBridge;
+using Tango.PPC.Common.ExternalBridge;
+using Tango.Transport;
+
+namespace Tango.PPC.Common.Console
+{
+ [TangoCreateWhenRegistered]
+ public class DefaultConsoleEngineService : IConsoleEngineService, IExternalBridgeRequestHandler
+ {
+ public bool Enabled { get; set; } = true;
+
+ public DefaultConsoleEngineService(IPPCExternalBridgeService externalBridge)
+ {
+ externalBridge.RegisterRequestHandler(this);
+ }
+
+ [ExternalBridgeRequestHandlerMethod(typeof(ConsoleCommandDTO))]
+ public async void OnConsoleCommandReceived(ConsoleCommandDTO command, String token, ITransporter transporter)
+ {
+ if (Enabled)
+ {
+ try
+ {
+ ConsoleExecutionEngine engine = new ConsoleExecutionEngine();
+ var result = await engine.Execute(command);
+ await transporter.SendGenericResponse<ConsoleCommandExecutionResult>(result, token, new TransportResponseConfig()
+ {
+ Immediate = true,
+ });
+ }
+ catch (Exception ex)
+ {
+ await transporter.SendErrorResponse(ex, token);
+ }
+ }
+ }
+ }
+}