Flow.Launcher/Flow.Launcher.Core/Plugin/ExecutablePlugin.cs

39 lines
1.2 KiB
C#
Raw Normal View History

2016-05-07 15:56:29 +00:00
using System;
using System.Diagnostics;
2021-02-14 05:56:27 +00:00
using System.IO;
2021-02-08 06:37:37 +00:00
using System.Threading;
using System.Threading.Tasks;
2020-04-21 09:12:17 +00:00
using Flow.Launcher.Plugin;
2016-05-07 15:56:29 +00:00
2020-04-21 09:12:17 +00:00
namespace Flow.Launcher.Core.Plugin
2016-05-07 15:56:29 +00:00
{
internal class ExecutablePlugin : JsonRPCPlugin
{
private readonly ProcessStartInfo _startInfo;
public override string SupportedLanguage { get; set; } = AllowedLanguage.Executable;
public ExecutablePlugin(string filename)
{
_startInfo = new ProcessStartInfo
{
FileName = filename,
UseShellExecute = false,
CreateNoWindow = true,
RedirectStandardOutput = true,
RedirectStandardError = true
};
}
2021-08-13 05:55:07 +00:00
protected override Task<Stream> RequestAsync(JsonRPCRequestModel request, CancellationToken token = default)
2016-05-07 15:56:29 +00:00
{
_startInfo.Arguments = $"\"{request}\"";
2021-02-08 06:37:37 +00:00
return ExecuteAsync(_startInfo, token);
2016-05-07 15:56:29 +00:00
}
2021-08-13 05:55:07 +00:00
protected override string Request(JsonRPCRequestModel rpcRequest, CancellationToken token = default)
2016-05-07 15:56:29 +00:00
{
_startInfo.Arguments = $"\"{rpcRequest}\"";
return Execute(_startInfo);
2016-05-07 15:56:29 +00:00
}
}
}