Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds the ability to create external plugins #733

Merged
merged 2 commits into from
Feb 5, 2018
Merged

Conversation

nul800sebastiaan
Copy link
Contributor

See issue #732

if (!allowNull)
var baseDir = AppDomain.CurrentDomain.BaseDirectory;
string[] extensions = { ".dll" };
var allFiles = Directory.EnumerateFileSystemEntries(baseDir, "*.*")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not filter by *.dll instead of this construction?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I'll update!

var allFiles = Directory.EnumerateFileSystemEntries(baseDir, "*.*")
.Where(x => extensions.Any(ext => ext == Path.GetExtension(x)));
var assemblies = new List<Assembly> { Assembly.GetExecutingAssembly() };
assemblies.AddRange(allFiles.Select(AssemblyName.GetAssemblyName).Select(Assembly.Load));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add some try-catch with a Log.Warn if it fails to load? (Not sure if the logger is available at this point)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, agreed, couldn't figure out how to get the logger, but I'll look into it again.

@nul800sebastiaan
Copy link
Contributor Author

@WouterTinus Thanks for the review, this is now updated:

  • Only looking for dll files without the verbose filterinig
  • Added logger (not sure if this is the best way but it seems to make sense
  • Loads the internal plugins regardless of anything
  • Tries to load plugin types in dlls, with a try-catch to handle problems

@WouterTinus WouterTinus merged commit 872267e into master Feb 5, 2018
@WouterTinus
Copy link
Member

Thanks for the update!

@WouterTinus WouterTinus deleted the issue/732 branch May 2, 2018 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants