-
-
Notifications
You must be signed in to change notification settings - Fork 259
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
Auto register events #150
base: master
Are you sure you want to change the base?
Auto register events #150
Conversation
/// <param name="services"></param> | ||
/// <param name="assemblies"></param> | ||
/// <returns></returns> | ||
public static IServiceCollection AddEventsFromAssemblies(this IServiceCollection services, params Assembly[] assemblies) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be much simpler to take the logic you had placed in the AssemblyScanner
class and inline it as one of the these service methods (private).
We should expose one method that will scan all loaded assemblies and auto-register them all at once. That way the client doesn't need to manually specify what assemblies they want to use. We'll just scan them all.
Coravel Pro does something like this to auto-register all invocables:
GetAllTypesOfType<IInvocable>()
.Distinct()
.ToList()
.ForEach(i => services.AddTransient(i));
If you have any thoughts or I missed something please let me know 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense, I'll make the changes in the coming days. I was a bit too locked in on the proposed implementation (with two different calls) that I didn't stop to consider an easier way 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's all good. Thanks! No rush 😊
Implementation for #148
I went back and forth between a few different approaches but I think this is the one I'm happiest with. Any feedback is much appreciated.