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

Auto register events #150

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Conversation

Blinke
Copy link
Contributor

@Blinke Blinke commented Feb 29, 2020

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.

/// <param name="services"></param>
/// <param name="assemblies"></param>
/// <returns></returns>
public static IServiceCollection AddEventsFromAssemblies(this IServiceCollection services, params Assembly[] assemblies)
Copy link
Owner

@jamesmh jamesmh Mar 25, 2020

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 👍

Copy link
Contributor Author

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 🙂

Copy link
Owner

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 😊

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.

2 participants