Skip to content

Commit 72ecb73

Browse files
author
LoneWandererProductions
committed
smaller touchups
1 parent 78233ad commit 72ecb73

File tree

8 files changed

+831
-820
lines changed

8 files changed

+831
-820
lines changed

PluginLoader/LoaderErrorEventArgs.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* COPYRIGHT: See COPYING in the top level directory
3-
* PROJECT: Plugin
4-
* FILE: PluginLoader/LoaderErrorEventArgs.cs
3+
* PROJECT: PluginLoader
4+
* FILE: LoaderErrorEventArgs.cs
55
* PURPOSE: Basic error Logging Class, can and will be used for further external Communication
66
* PROGRAMER: Peter Geinitz (Wayfarer)
77
*/

PluginLoader/PluginController.xaml.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* COPYRIGHT: See COPYING in the top level directory
33
* PROJECT: PluginLoader
4-
* FILE: PluginLoader/PluginController.xaml.cs
4+
* FILE: PluginController.xaml.cs
55
* PURPOSE: Plugin Control, that displays all plugins
66
* PROGRAMER: Peter Geinitz (Wayfarer)
77
*/
@@ -32,6 +32,9 @@ public sealed partial class PluginController : INotifyPropertyChanged
3232
typeof(string),
3333
typeof(PluginController), new PropertyMetadata(default(string)));
3434

35+
/// <summary>
36+
/// The extension property
37+
/// </summary>
3538
public static readonly DependencyProperty ExtensionProperty = DependencyProperty.Register(nameof(Extension),
3639
typeof(string),
3740
typeof(PluginController), new PropertyMetadata(default(string)));

PluginLoader/PluginItem.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* COPYRIGHT: See COPYING in the top level directory
33
* PROJECT: PluginLoader
4-
* FILE: PluginLoader/PluginItem.cs
4+
* FILE: PluginItem.cs
55
* PURPOSE: Container for the collected Plugins
66
* PROGRAMER: Peter Geinitz (Wayfarer)
77
*/

PluginLoader/PluginLoad.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* COPYRIGHT: See COPYING in the top level directory
3-
* PROJECT: Plugin
4-
* FILE: PluginLoader/PluginLoader.cs
3+
* PROJECT: PluginLoader
4+
* FILE: PluginLoader.cs
55
* PURPOSE: Basic Plugin Support, Load all Plugins
66
* PROGRAMER: Peter Geinitz (Wayfarer)
77
* SOURCES: https://docs.microsoft.com/en-us/dotnet/core/tutorials/creating-app-with-plugin-support

PluginLoader/PluginLoadContext.cs

Lines changed: 50 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,70 @@
11
/*
22
* COPYRIGHT: See COPYING in the top level directory
3-
* PROJECT: Plugin
4-
* FILE: PluginLoader/PluginLoadContext.cs
3+
* PROJECT: PluginLoader
4+
* FILE: PluginLoadContext.cs
55
* PURPOSE: Basic Plugin Support, Load all Plugins
66
* PROGRAMER: Peter Geinitz (Wayfarer)
77
* SOURCES: https://docs.microsoft.com/en-us/dotnet/core/tutorials/creating-app-with-plugin-support
88
*/
99

10-
using System;
1110
using System.Reflection;
1211
using System.Runtime.Loader;
1312

14-
namespace PluginLoader;
15-
16-
internal sealed class PluginLoadContext : AssemblyLoadContext
13+
namespace PluginLoader
1714
{
1815
/// <summary>
19-
/// The resolver
20-
/// </summary>
21-
private readonly AssemblyDependencyResolver _resolver;
22-
23-
/// <inheritdoc />
24-
/// <summary>
25-
/// Initializes a new instance of the <see cref="T:PluginLoader.PluginLoadContext" /> class.
16+
/// Plugin Load Context.
2617
/// </summary>
27-
/// <param name="pluginPath">The plugin path.</param>
28-
public PluginLoadContext(string pluginPath)
18+
/// <seealso cref="System.Runtime.Loader.AssemblyLoadContext" />
19+
internal sealed class PluginLoadContext : AssemblyLoadContext
2920
{
30-
_resolver = new AssemblyDependencyResolver(pluginPath);
31-
}
21+
/// <summary>
22+
/// The resolver
23+
/// </summary>
24+
private readonly AssemblyDependencyResolver _resolver;
3225

33-
/// <inheritdoc />
34-
/// <summary>
35-
/// When overridden in a derived class, allows an assembly to be resolved and loaded based on its
36-
/// <see cref="AssemblyName" />.
37-
/// </summary>
38-
/// <param name="assemblyName">The object that describes the assembly to be loaded.</param>
39-
/// <returns>
40-
/// The loaded assembly, or <see langword="null" />.
41-
/// </returns>
42-
protected override Assembly Load(AssemblyName assemblyName)
43-
{
44-
var assemblyPath = _resolver.ResolveAssemblyToPath(assemblyName);
26+
/// <inheritdoc />
27+
/// <summary>
28+
/// Initializes a new instance of the <see cref="T:PluginLoader.PluginLoadContext" /> class.
29+
/// </summary>
30+
/// <param name="pluginPath">The plugin path.</param>
31+
public PluginLoadContext(string pluginPath)
32+
{
33+
_resolver = new AssemblyDependencyResolver(pluginPath);
34+
}
4535

46-
return assemblyPath != null ? LoadFromAssemblyPath(assemblyPath) : null;
47-
}
36+
/// <inheritdoc />
37+
/// <summary>
38+
/// When overridden in a derived class, allows an assembly to be resolved and loaded based on its
39+
/// <see cref="AssemblyName" />.
40+
/// </summary>
41+
/// <param name="assemblyName">The object that describes the assembly to be loaded.</param>
42+
/// <returns>
43+
/// The loaded assembly, or <see langword="null" />.
44+
/// </returns>
45+
protected override Assembly Load(AssemblyName assemblyName)
46+
{
47+
var assemblyPath = _resolver.ResolveAssemblyToPath(assemblyName);
4848

49-
/// <inheritdoc />
50-
/// <summary>
51-
/// Allows derived class to load an unmanaged library by name.
52-
/// </summary>
53-
/// <param name="unmanagedDllName">
54-
/// Name of the unmanaged library. Typically this is the filename without its path or
55-
/// extensions.
56-
/// </param>
57-
/// <returns>
58-
/// A handle to the loaded library, or <see cref="IntPtr.Zero" />.
59-
/// </returns>
60-
protected override IntPtr LoadUnmanagedDll(string unmanagedDllName)
61-
{
62-
var libraryPath = _resolver.ResolveUnmanagedDllToPath(unmanagedDllName);
49+
return assemblyPath != null ? LoadFromAssemblyPath(assemblyPath) : null;
50+
}
51+
52+
/// <inheritdoc />
53+
/// <summary>
54+
/// Allows derived class to load an unmanaged library by name.
55+
/// </summary>
56+
/// <param name="unmanagedDllName">
57+
/// Name of the unmanaged library. Typically this is the filename without its path or
58+
/// extensions.
59+
/// </param>
60+
/// <returns>
61+
/// A handle to the loaded library, or <see cref="nint.Zero" />.
62+
/// </returns>
63+
protected override nint LoadUnmanagedDll(string unmanagedDllName)
64+
{
65+
var libraryPath = _resolver.ResolveUnmanagedDllToPath(unmanagedDllName);
6366

64-
return libraryPath != null ? LoadUnmanagedDllFromPath(libraryPath) : IntPtr.Zero;
67+
return libraryPath != null ? LoadUnmanagedDllFromPath(libraryPath) : nint.Zero;
68+
}
6569
}
6670
}
Lines changed: 47 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* COPYRIGHT: See COPYING in the top level directory
3-
* PROJECT: Plugin
4-
* FILE: PluginLoader/PluginLoaderResources.cs
3+
* PROJECT: PluginLoader
4+
* FILE: PluginLoaderResources.cs
55
* PURPOSE: String Resources
66
* PROGRAMER: Peter Geinitz (Wayfarer)
77
* SOURCES: https://docs.microsoft.com/en-us/dotnet/core/tutorials/creating-app-with-plugin-support
@@ -10,53 +10,54 @@
1010
using System;
1111
using System.Reflection;
1212

13-
namespace PluginLoader;
14-
15-
/// <summary>
16-
/// String Resources
17-
/// </summary>
18-
internal static class PluginLoaderResources
13+
namespace PluginLoader
1914
{
2015
/// <summary>
21-
/// The file ext
22-
/// </summary>
23-
internal const string FileExt = "*.dll";
24-
25-
/// <summary>
26-
/// The separator
27-
/// </summary>
28-
internal const string Separator = ",";
29-
30-
/// <summary>
31-
/// The error could not find plugin
32-
/// </summary>
33-
internal const string ErrorCouldNotFindPlugin = "Can't find any type which implements ICommand in: ";
34-
35-
/// <summary>
36-
/// The Error with the Path (const). Value: "Plugin path does not exist.".
37-
/// </summary>
38-
internal const string ErrorPath = "Plugin path does not exist.";
39-
40-
/// <summary>
41-
/// The Error Directory did not exist (const). Value: "Directory does not exist.".
42-
/// </summary>
43-
internal const string ErrorDirectory = "Directory does not exist.";
44-
45-
/// <summary>
46-
/// Information about Plugin Status (const). Value: "No Plugins found.".
47-
/// </summary>
48-
internal const string InformationPlugin = "No Plugins found.";
49-
50-
/// <summary>
51-
/// Format Information about the specified assembly.
16+
/// String Resources
5217
/// </summary>
53-
/// <param name="assembly">The assembly.</param>
54-
/// <param name="availableTypes">The available types.</param>
55-
/// <returns>Information about the assembly</returns>
56-
internal static string Information(Assembly assembly, string availableTypes)
18+
internal static class PluginLoaderResources
5719
{
58-
return string.Concat($" {assembly} from {assembly.Location}.",
59-
Environment.NewLine, "Available types:",
60-
$" {availableTypes}");
20+
/// <summary>
21+
/// The file ext
22+
/// </summary>
23+
internal const string FileExt = "*.dll";
24+
25+
/// <summary>
26+
/// The separator
27+
/// </summary>
28+
internal const string Separator = ",";
29+
30+
/// <summary>
31+
/// The error could not find plugin
32+
/// </summary>
33+
internal const string ErrorCouldNotFindPlugin = "Can't find any type which implements ICommand in: ";
34+
35+
/// <summary>
36+
/// The Error with the Path (const). Value: "Plugin path does not exist.".
37+
/// </summary>
38+
internal const string ErrorPath = "Plugin path does not exist.";
39+
40+
/// <summary>
41+
/// The Error Directory did not exist (const). Value: "Directory does not exist.".
42+
/// </summary>
43+
internal const string ErrorDirectory = "Directory does not exist.";
44+
45+
/// <summary>
46+
/// Information about Plugin Status (const). Value: "No Plugins found.".
47+
/// </summary>
48+
internal const string InformationPlugin = "No Plugins found.";
49+
50+
/// <summary>
51+
/// Format Information about the specified assembly.
52+
/// </summary>
53+
/// <param name="assembly">The assembly.</param>
54+
/// <param name="availableTypes">The available types.</param>
55+
/// <returns>Information about the assembly</returns>
56+
internal static string Information(Assembly assembly, string availableTypes)
57+
{
58+
return string.Concat($" {assembly} from {assembly.Location}.",
59+
Environment.NewLine, "Available types:",
60+
$" {availableTypes}");
61+
}
6162
}
6263
}

0 commit comments

Comments
 (0)