ScriptStack 1.0.5
Loading...
Searching...
No Matches
ScriptStack.Plugins.PluginLoadContext Class Reference
Inheritance diagram for ScriptStack.Plugins.PluginLoadContext:

Public Member Functions

 PluginLoadContext (string pluginMainAssemblyPath, string[]? sharedAssemblyNames=null)

Protected Member Functions

override? Assembly Load (AssemblyName assemblyName)
override IntPtr LoadUnmanagedDll (string unmanagedDllName)

Private Attributes

readonly AssemblyDependencyResolver _resolver
readonly string[] _sharedAssemblies

Detailed Description

Definition at line 7 of file PluginLoadContext.cs.

Constructor & Destructor Documentation

◆ PluginLoadContext()

ScriptStack.Plugins.PluginLoadContext.PluginLoadContext ( string pluginMainAssemblyPath,
string?[] sharedAssemblyNames = null )

Definition at line 12 of file PluginLoadContext.cs.

13 : base(isCollectible: true)
14 {
15 _resolver = new AssemblyDependencyResolver(pluginMainAssemblyPath);
16 _sharedAssemblies = sharedAssemblyNames ?? Array.Empty<string>();
17 }

References _resolver, and _sharedAssemblies.

Member Function Documentation

◆ Load()

override? Assembly ScriptStack.Plugins.PluginLoadContext.Load ( AssemblyName assemblyName)
protected

Definition at line 19 of file PluginLoadContext.cs.

20 {
21 foreach (var shared in _sharedAssemblies)
22 {
23 if (string.Equals(shared, assemblyName.Name, StringComparison.OrdinalIgnoreCase))
24 {
25 try { return Assembly.Load(assemblyName); } catch { return null; }
26 }
27 }
28
29 string? assemblyPath = _resolver.ResolveAssemblyToPath(assemblyName);
30 if (assemblyPath != null)
31 return LoadFromAssemblyPath(assemblyPath);
32
33 return null;
34 }

References _resolver, and _sharedAssemblies.

◆ LoadUnmanagedDll()

override IntPtr ScriptStack.Plugins.PluginLoadContext.LoadUnmanagedDll ( string unmanagedDllName)
protected

Definition at line 36 of file PluginLoadContext.cs.

37 {
38 string? path = _resolver.ResolveUnmanagedDllToPath(unmanagedDllName);
39 if (path != null) return LoadUnmanagedDllFromPath(path);
40 return base.LoadUnmanagedDll(unmanagedDllName);
41 }

References _resolver.

Member Data Documentation

◆ _resolver

readonly AssemblyDependencyResolver ScriptStack.Plugins.PluginLoadContext._resolver
private

Definition at line 9 of file PluginLoadContext.cs.

Referenced by Load(), LoadUnmanagedDll(), and PluginLoadContext().

◆ _sharedAssemblies

readonly string [] ScriptStack.Plugins.PluginLoadContext._sharedAssemblies
private

Definition at line 10 of file PluginLoadContext.cs.

Referenced by Load(), and PluginLoadContext().


The documentation for this class was generated from the following file: