mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 11:46:30 +02:00
regular update
This commit is contained in:
@@ -61,8 +61,9 @@ namespace WinAlfred.PluginLoader
|
||||
metadata.Language = ini.GetSetting("plugin", "Language");
|
||||
metadata.Version = ini.GetSetting("plugin", "Version");
|
||||
metadata.ActionKeyword = ini.GetSetting("plugin", "ActionKeyword");
|
||||
metadata.ExecuteFile = AppDomain.CurrentDomain.BaseDirectory + directory + "\\" + ini.GetSetting("plugin", "ExecuteFile");
|
||||
metadata.ExecuteFilePath = AppDomain.CurrentDomain.BaseDirectory + directory + "\\" + ini.GetSetting("plugin", "ExecuteFile");
|
||||
metadata.PluginDirecotry = AppDomain.CurrentDomain.BaseDirectory + directory + "\\";
|
||||
metadata.ExecuteFileName = ini.GetSetting("plugin", "ExecuteFile");
|
||||
|
||||
if (!AllowedLanguage.IsAllowed(metadata.Language))
|
||||
{
|
||||
@@ -76,10 +77,10 @@ namespace WinAlfred.PluginLoader
|
||||
#endif
|
||||
return null;
|
||||
}
|
||||
if (!File.Exists(metadata.ExecuteFile))
|
||||
if (!File.Exists(metadata.ExecuteFilePath))
|
||||
{
|
||||
string error = string.Format("Parse ini {0} failed: ExecuteFile didn't exist {1}", iniPath,
|
||||
metadata.ExecuteFile);
|
||||
string error = string.Format("Parse ini {0} failed: ExecuteFilePath didn't exist {1}", iniPath,
|
||||
metadata.ExecuteFilePath);
|
||||
Log.Error(error);
|
||||
#if (DEBUG)
|
||||
{
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace WinAlfred.PluginLoader
|
||||
{
|
||||
try
|
||||
{
|
||||
Assembly asm = Assembly.LoadFile(metadata.ExecuteFile);
|
||||
Assembly asm = Assembly.LoadFile(metadata.ExecuteFilePath);
|
||||
List<Type> types = asm.GetTypes().Where(o => o.GetInterfaces().Contains(typeof (IPlugin))).ToList();
|
||||
if (types.Count == 0)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using Newtonsoft.Json;
|
||||
using WinAlfred.Plugin;
|
||||
|
||||
namespace WinAlfred.PluginLoader
|
||||
@@ -10,27 +11,18 @@ namespace WinAlfred.PluginLoader
|
||||
private PluginMetadata metadata;
|
||||
|
||||
[DllImport("PyWinAlfred.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
||||
public extern static void ExecPython(string directory, string file, string query);
|
||||
|
||||
static PythonPluginWrapper()
|
||||
{
|
||||
|
||||
}
|
||||
private extern static IntPtr ExecPython(string directory, string file, string query);
|
||||
|
||||
public PythonPluginWrapper(PluginMetadata metadata)
|
||||
{
|
||||
this.metadata = metadata;
|
||||
}
|
||||
|
||||
|
||||
public List<Result> Query(Query query)
|
||||
{
|
||||
List<Result> results = new List<Result>();
|
||||
ExecPython(metadata.PluginDirecotry, metadata.ExecuteFile.Replace(".py", ""), query.RawQuery);
|
||||
results.Add(new Result()
|
||||
{
|
||||
});
|
||||
return results;
|
||||
string s = Marshal.PtrToStringAnsi(ExecPython(metadata.PluginDirecotry, metadata.ExecuteFileName.Replace(".py", ""), query.RawQuery));
|
||||
List<Result> o = JsonConvert.DeserializeObject<List<Result>>(s);
|
||||
return o;
|
||||
}
|
||||
|
||||
public void Init()
|
||||
|
||||
Reference in New Issue
Block a user