add abstract create plugin pair method to handle each plugin type

This commit is contained in:
Jeremy 2022-11-30 21:06:54 +11:00
parent 07bc2a70b6
commit 680ed77daa
4 changed files with 24 additions and 11 deletions

View file

@ -112,6 +112,8 @@ namespace Flow.Launcher.Core.ExternalPlugins.Environments
}
internal abstract PluginPair CreatePluginPair(string filePath, PluginMetadata metadata);
private IEnumerable<PluginPair> SetPathForPluginPairs(string filePath, string languageToSet)
{
var pluginPairs = new List<PluginPair>();
@ -119,13 +121,7 @@ namespace Flow.Launcher.Core.ExternalPlugins.Environments
foreach (var metadata in PluginMetadataList)
{
if (metadata.Language.Equals(languageToSet, StringComparison.OrdinalIgnoreCase))
{
pluginPairs.Add(new PluginPair
{
Plugin = new PythonPlugin(filePath),
Metadata = metadata
});
}
pluginPairs.Add(CreatePluginPair(filePath, metadata));
}
return pluginPairs;

View file

@ -1,4 +1,5 @@
using Droplex;
using Flow.Launcher.Core.Plugin;
using Flow.Launcher.Infrastructure.UserSettings;
using Flow.Launcher.Plugin;
using Flow.Launcher.Plugin.SharedCommands;
@ -34,5 +35,14 @@ namespace Flow.Launcher.Core.ExternalPlugins.Environments
PluginsSettingsFilePath = ExecutablePath;
}
internal override PluginPair CreatePluginPair(string filePath, PluginMetadata metadata)
{
return new PluginPair
{
Plugin = new PythonPlugin(filePath),
Metadata = metadata
};
}
}
}

View file

@ -4,6 +4,7 @@ using Flow.Launcher.Infrastructure.UserSettings;
using Flow.Launcher.Plugin.SharedCommands;
using Flow.Launcher.Plugin;
using System.IO;
using Flow.Launcher.Core.Plugin;
namespace Flow.Launcher.Core.ExternalPlugins.Environments
{
@ -30,5 +31,14 @@ namespace Flow.Launcher.Core.ExternalPlugins.Environments
PluginsSettingsFilePath = ExecutablePath;
}
internal override PluginPair CreatePluginPair(string filePath, PluginMetadata metadata)
{
return new PluginPair
{
Plugin = new NodePlugin(filePath),
Metadata = metadata
};
}
}
}

View file

@ -17,7 +17,6 @@ namespace Flow.Launcher.Core.Plugin
{
private readonly ProcessStartInfo _startInfo;
// TODO: Remove all, not used
public override string SupportedLanguage { get; set; } = AllowedLanguage.Executable;
public NodePlugin(string filename)
@ -39,9 +38,7 @@ namespace Flow.Launcher.Core.Plugin
}
protected override string Request(JsonRPCRequestModel rpcRequest, CancellationToken token = default)
{
// CONTEXT MENU NOT WORKING ??
{
// since this is not static, request strings will build up in ArgumentList if index is not specified
_startInfo.ArgumentList[1] = rpcRequest.ToString();
return Execute(_startInfo);