Skip to content

Commit dfc62de

Browse files
committed
Refactor Assemblies.cs.
1 parent febdd65 commit dfc62de

1 file changed

Lines changed: 21 additions & 8 deletions

File tree

NetLeaf.Bridge/Assemblies.cs

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,32 @@ namespace NetLeaf.Bridge;
44

55
public static class Assemblies
66
{
7+
/// <summary>
8+
/// Represents a loaded plugin/assembly.
9+
/// </summary>
710
private class LoadedPlugin
811
{
912
public PluginLoadContext Context;
1013
public Assembly Assembly;
1114
public string Path;
15+
16+
/// <summary>
17+
/// Initializes a new instance of the <see cref="LoadedPlugin"/> class.
18+
/// </summary>
19+
public LoadedPlugin(PluginLoadContext context, Assembly assembly, string path) => (Context, Assembly, Path) = (context, assembly, path);
1220
}
1321

1422
private static readonly List<LoadedPlugin> _loadedPlugins = new();
1523

16-
public static IEnumerable<Assembly> LoadedAssemblies
17-
=> _loadedPlugins.Select(p => p.Assembly);
24+
/// <summary>
25+
/// All currently loaded assemblies.
26+
/// </summary>
27+
public static IEnumerable<Assembly> LoadedAssemblies => _loadedPlugins.Select(p => p.Assembly);
1828

29+
/// <summary>
30+
/// Load an assembly.
31+
/// </summary>
32+
/// <param name="path">Path to the assembly.</param>
1933
public static void LoadAssembly(string path)
2034
{
2135
string fullPath = Path.IsPathRooted(path)
@@ -31,16 +45,15 @@ public static void LoadAssembly(string path)
3145
var context = new PluginLoadContext(fullPath);
3246
var assembly = context.LoadFromAssemblyPath(fullPath);
3347

34-
_loadedPlugins.Add(new LoadedPlugin
35-
{
36-
Context = context,
37-
Assembly = assembly,
38-
Path = fullPath
39-
});
48+
_loadedPlugins.Add(new LoadedPlugin(context, assembly, fullPath));
4049

4150
Console.WriteLine($"[NetLeaf] Assembly loaded: {fullPath}");
4251
}
4352

53+
/// <summary>
54+
/// Unload an assembly.
55+
/// </summary>
56+
/// <param name="path">Path to the assembly.</param>
4457
public static void UnloadAssembly(string path)
4558
{
4659
var plugin = _loadedPlugins.Find(p => p.Path == path);

0 commit comments

Comments
 (0)