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

Ability to run custom (IWork) code without dynamic loading #8

Closed
hirre opened this issue Jul 19, 2024 · 1 comment
Closed

Ability to run custom (IWork) code without dynamic loading #8

hirre opened this issue Jul 19, 2024 · 1 comment

Comments

@hirre
Copy link
Owner

hirre commented Jul 19, 2024

Have an option to run custom code, e.g. have a library implementing the IWork interface which is then linked by the WebWorker service. This way we can run code without dynamically loading it.

@hirre hirre changed the title Ability to run custom code Ability to run custom (IWork) code without dynamic loading Jul 19, 2024
@hirre
Copy link
Owner Author

hirre commented Jul 29, 2024

This one can be done by referencing a custom lib from webworker. Then add your custom classes that implement the IWork interface to the workPluginRepo. Class name --> object instance.

Example based on Program.cs:

var repo = app.Services.GetService<WorkPluginRepo>();
LoadWorkPlugins(repo);

Loads all dynamic plugins.

And then you can e.g. after that method call do:

var myCustomWorkClassInstance = app.Services.GetService<MyCustomWorkClass>(); // Singleton
repo.AddWorkPlugin("MyCustomWorkClass", myCustomWorkClassInstance);

MyCustomWorkClass implements IWork.

@hirre hirre closed this as completed Jul 29, 2024
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

No branches or pull requests

1 participant