mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-04 10:16:24 +02:00
* [Analyzers][Settings] Fix SA1516 * [Analyzers][Workspaces] Fix SA1516 * [Analyzers][Awake] Fix SA1516 * [Analyzers][Wox] Fix SA1516 * [MWB] Disable CA1716 warning on class name * [Wox] Update ExecuteFilePath property visibility for Json Source Generator * [Analyzers][MWB] Fix CA1716 on NativeMethods. --------- Co-authored-by: Jaime Bernardo <jaime@janeasystems.com>
48 lines
1.4 KiB
C#
48 lines
1.4 KiB
C#
// Copyright (c) Microsoft Corporation
|
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
using System;
|
|
using System.Globalization;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Runtime.Loader;
|
|
|
|
using ManagedCommon;
|
|
|
|
namespace Wox.Plugin
|
|
{
|
|
internal class PluginLoadContext : AssemblyLoadContext
|
|
{
|
|
private AssemblyDependencyResolver _resolver;
|
|
|
|
public PluginLoadContext(string pluginPath)
|
|
{
|
|
_resolver = new AssemblyDependencyResolver(pluginPath);
|
|
}
|
|
|
|
protected override Assembly Load(AssemblyName assemblyName)
|
|
{
|
|
string assemblyPath = _resolver.ResolveAssemblyToPath(assemblyName);
|
|
if (assemblyPath != null)
|
|
{
|
|
var existingAssembly = Default.Assemblies.FirstOrDefault(x => x.FullName == assemblyName.FullName);
|
|
return existingAssembly ?? LoadFromAssemblyPath(assemblyPath);
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
protected override IntPtr LoadUnmanagedDll(string unmanagedDllName)
|
|
{
|
|
string libraryPath = _resolver.ResolveUnmanagedDllToPath(unmanagedDllName);
|
|
if (libraryPath != null)
|
|
{
|
|
return LoadUnmanagedDllFromPath(libraryPath);
|
|
}
|
|
|
|
return IntPtr.Zero;
|
|
}
|
|
}
|
|
}
|