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

Load external plugins #21

Open
3 tasks
paoloambrosio opened this issue May 18, 2021 · 1 comment
Open
3 tasks

Load external plugins #21

paoloambrosio opened this issue May 18, 2021 · 1 comment
Labels
enhancement New feature or request
Milestone

Comments

@paoloambrosio
Copy link
Contributor

paoloambrosio commented May 18, 2021

  • Dynamically load plugin assemblies (and dependencies)
  • Extract HUD and PitManager out in their own GitHub projects
  • Documentation on how to create a plugin

See "Create a .NET Core application with plugins".

@paoloambrosio paoloambrosio added the enhancement New feature or request label May 18, 2021
@paoloambrosio paoloambrosio added this to the 0.2 milestone May 18, 2021
@paoloambrosio paoloambrosio mentioned this issue May 18, 2021
3 tasks
@paoloambrosio paoloambrosio modified the milestones: 0.2, 0.3 Jun 9, 2022
@paoloambrosio
Copy link
Contributor Author

Note: assemblies are dynamically loaded.

This snippet will only find the DefaultPlugin:

public static IEnumerable<IPlugin> InstantiatePlugins()
{
    var pluginType = typeof(IPlugin);
    var plugins = AppDomain.CurrentDomain.GetAssemblies()
        .SelectMany(a => a.GetTypes())
        .Where(t => pluginType.IsAssignableFrom(t) && t.IsClass && !t.IsAbstract)
        .Select(t => (IPlugin) Activator.CreateInstance(t)!);
    return plugins;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant