diff options
| author | Mirta <mirta@twine-s.com> | 2020-12-30 16:39:52 +0200 |
|---|---|---|
| committer | Mirta <mirta@twine-s.com> | 2020-12-30 16:39:52 +0200 |
| commit | 00a491d93733d4625ad329b2ba8237f445364b3f (patch) | |
| tree | 4b24c6fa78d7648f4bb7cefafa464bb0b063fec4 /Software/Visual_Studio/PPC/Tango.PPC.Common/Console/DefaultConsoleEngineService.cs | |
| parent | 124ad4150f80c6846fdee41dbbda9848c105f6e5 (diff) | |
| download | Tango-00a491d9.tar.gz Tango-00a491d9.zip | |
merge
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.cs | 92 |
1 files changed, 0 insertions, 92 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 deleted file mode 100644 index 94b677b18..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Console/DefaultConsoleEngineService.cs +++ /dev/null @@ -1,92 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.Console; -using Tango.Console.Network; -using Tango.Core; -using Tango.Core.DI; -using Tango.Integration.ExternalBridge; -using Tango.PPC.Common.ExternalBridge; -using Tango.Transport; - -namespace Tango.PPC.Common.Console -{ - /// <summary> - /// Represents the <see cref="IConsoleEngineService"/> default implementation - /// which listens to incoming console request by registering as a external bridge request handler. - /// </summary> - /// <seealso cref="Tango.PPC.Common.Console.IConsoleEngineService" /> - /// <seealso cref="Tango.Integration.ExternalBridge.IExternalBridgeRequestHandler" /> - [TangoCreateWhenRegistered] - public class DefaultConsoleEngineService : ExtendedObject, IConsoleEngineService, IExternalBridgeRequestHandler - { - /// <summary> - /// Gets or sets a value indicating whether this <see cref="IConsoleEngineService" /> is enabled. - /// </summary> - public bool Enabled { get; set; } = true; - - /// <summary> - /// Initializes a new instance of the <see cref="DefaultConsoleEngineService"/> class. - /// </summary> - /// <param name="externalBridge">The external bridge service instance.</param> - public DefaultConsoleEngineService(IPPCExternalBridgeService externalBridge) - { - externalBridge.RegisterRequestHandler(this); - } - - /// <summary> - /// Handles <see cref="GetCurrentDirectoryRequest"/> requests. - /// </summary> - /// <param name="request">The request.</param> - /// <param name="token">The token.</param> - /// <param name="transporter">The transporter.</param> - [ExternalBridgeRequestHandlerMethod(typeof(GetCurrentDirectoryRequest), RequestHandlerLoggingMode.LogRequestName)] - public async Task OnGetCurrentDirectoryRequest(GetCurrentDirectoryRequest request, String token, ITransporter transporter) - { - this.ThrowIfDisabled(); - - await transporter.SendGenericResponse(new GetCurrentDirectoryResponse() - { - CurrentDirectory = Environment.CurrentDirectory, - Suggestions = ConsoleExecutionEngine.GetSuggestions(Environment.CurrentDirectory) - }, token); - } - - /// <summary> - /// Handles <see cref="ConsoleCommandRequest"/> requests. - /// </summary> - /// <param name="request">The request.</param> - /// <param name="token">The token.</param> - /// <param name="transporter">The transporter.</param> - [ExternalBridgeRequestHandlerMethod(typeof(ConsoleCommandRequest), RequestHandlerLoggingMode.LogRequestNameAndContent)] - public async Task OnConsoleCommandRequest(ConsoleCommandRequest request, String token, ITransporter transporter) - { - this.ThrowIfDisabled(); - - LogManager.Log($"{nameof(ConsoleCommandRequest)} received with command '{request.Command}'. Executing..."); - - ConsoleExecutionEngine engine = new ConsoleExecutionEngine(); - var result = await engine.Execute(request); - - LogManager.Log("Console command executed successfully."); - - await transporter.SendGenericResponse<ConsoleCommandResponse>(new ConsoleCommandResponse() - { - Output = result.Output, - Suggestions = result.Suggestions, - WorkingFolder = result.WorkingFolder - }, token); - } - - /// <summary> - /// Called when any of the external bridge clients (receivers) has disconnected. - /// </summary> - /// <param name="receiver">The receiver.</param> - public void OnReceiverDisconnected(ExternalBridgeReceiver receiver) - { - //Do nothing. - } - } -} |
