Skip to content

Commit

Permalink
Refactor interface name
Browse files Browse the repository at this point in the history
  • Loading branch information
iadgovuser29 committed Apr 12, 2024
1 parent d0deb49 commit c1f63c7
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using HardwareManifestProto;

namespace HardwareManifestPlugin {
public abstract class HardwareManifest : IHardwareManifest {
public abstract class HardwareManifestPlugin : IHardwareManifestPlugin {
public string Name {
get;
protected set;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using HardwareManifestProto;

namespace HardwareManifestPlugin {
public interface IHardwareManifest {
public interface IHardwareManifestPlugin {
string Name {
get;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ public class HardwareManifestPluginManagerUtils {
public static readonly string TrustPath = Path.Combine(Path.GetDirectoryName(Environment.ProcessPath), "trust");
#pragma warning restore CS8604 // Possible null reference argument.

public static List<IHardwareManifest> LoadPlugins(List<string> names, bool sbomExpected) {
public static List<IHardwareManifestPlugin> LoadPlugins(List<string> names, bool sbomExpected) {
string[] pluginDlls = System.IO.Directory.GetFiles(PluginsPath, "*.dll");
List<IHardwareManifest> manifests = new();
List<IHardwareManifestPlugin> manifests = new();
List<Tuple<string, string>> namesWithArgs = new();
foreach(string dllPath in pluginDlls) {
Assembly pluginAssembly = LoadAssemblyFromDll(dllPath);
IHardwareManifest? manifest = GatherManifestIfNameSelected(pluginAssembly, names);
IHardwareManifestPlugin? manifest = GatherManifestIfNameSelected(pluginAssembly, names);
if (manifest != null) {
bool trustManifest = !sbomExpected;
if (sbomExpected) {
Expand All @@ -44,10 +44,10 @@ private static Assembly LoadAssemblyFromDll(string relativePath) {
return loadContext.LoadFromAssemblyName(new AssemblyName(Path.GetFileNameWithoutExtension(fullPath)));
}

private static IHardwareManifest? GatherManifestIfNameSelected(Assembly assembly, List<string> names) {
private static IHardwareManifestPlugin? GatherManifestIfNameSelected(Assembly assembly, List<string> names) {
foreach (Type type in assembly.GetTypes()) {
if (typeof(IHardwareManifest).IsAssignableFrom(type)) {
if (Activator.CreateInstance(type) is IHardwareManifest result && names.Remove(result.Name)) {
if (typeof(IHardwareManifestPlugin).IsAssignableFrom(type)) {
if (Activator.CreateInstance(type) is IHardwareManifestPlugin result && names.Remove(result.Name)) {
Log.Debug("Found " + result.Name + ".");
return result;
}
Expand Down
Loading

0 comments on commit c1f63c7

Please sign in to comment.