mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 03:36:44 +02:00
Add unittest [WIP]
This commit is contained in:
@@ -41,6 +41,13 @@ namespace Wox.Core.Plugin
|
||||
|
||||
private static void ParseSystemPlugins()
|
||||
{
|
||||
string systemPluginPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
|
||||
"Wox.Plugin.SystemPlugins.dll");
|
||||
if (!File.Exists(systemPluginPath))
|
||||
{
|
||||
throw new WoxCritialException("System Plugin DLL is missing.");
|
||||
}
|
||||
|
||||
pluginMetadatas.Add(new PluginMetadata()
|
||||
{
|
||||
Name = "System Plugins",
|
||||
@@ -65,8 +72,15 @@ namespace Wox.Core.Plugin
|
||||
{
|
||||
if (File.Exists((Path.Combine(directory, "NeedDelete.txt"))))
|
||||
{
|
||||
Directory.Delete(directory, true);
|
||||
continue;
|
||||
try
|
||||
{
|
||||
Directory.Delete(directory, true);
|
||||
continue;
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Log.Error(ExceptionFormatter.FormatExcpetion(e));
|
||||
}
|
||||
}
|
||||
PluginMetadata metadata = GetPluginMetadata(directory);
|
||||
if (metadata != null)
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using Wox.Core.Exception;
|
||||
using Wox.Infrastructure.Http;
|
||||
using Wox.Infrastructure.Logger;
|
||||
using Wox.Plugin;
|
||||
@@ -35,17 +36,19 @@ namespace Wox.Core.Plugin
|
||||
get
|
||||
{
|
||||
string userProfilePath = Environment.GetEnvironmentVariable("USERPROFILE");
|
||||
if (userProfilePath != null)
|
||||
if (string.IsNullOrEmpty(userProfilePath))
|
||||
{
|
||||
return Path.Combine(Path.Combine(userProfilePath, ".Wox"), "Plugins");
|
||||
throw new WoxCritialException("Wox Can't Find Environment Variable UserProfile");
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
return Path.Combine(Path.Combine(userProfilePath, ".Wox"), "Plugins");
|
||||
}
|
||||
}
|
||||
|
||||
static PluginManager()
|
||||
private static void SetupPluginDirectories()
|
||||
{
|
||||
pluginDirectories.Clear();
|
||||
|
||||
pluginDirectories.Add(DefaultPluginDirectory);
|
||||
pluginDirectories.Add(
|
||||
Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Plugins"));
|
||||
@@ -76,6 +79,9 @@ namespace Wox.Core.Plugin
|
||||
/// </summary>
|
||||
public static void Init(IPublicAPI api)
|
||||
{
|
||||
if (api == null) throw new WoxCritialException("api is null");
|
||||
|
||||
SetupPluginDirectories();
|
||||
API = api;
|
||||
plugins.Clear();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user