v9: Added Extension method to register all custom Notifications #11199
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Let me ask you a question. How many tears have you felt, running down your chin, every-time you’d forgot to register your freshly created notification? How many times do you think you’d started the cms, and didn’t add your notifications? If you are like me, that is more than once, and that is too many.
What if i told you that you’d never had to forget to registers any custom notification handlers ever again, and that the solution would be helpful and friendly at the same time?
Enter this PR.
What does it do? It is an immediate pain reliever, that comes in a form of an Extension Method to
IUmbracoBuilder
namedAddNotificationsFromAssembly<T>
where T is the type within the assembly your or the customer custom notifications is located. It locates all your implementations ofINotificationHandler<TNotification>
and registers them in theIServiceCollector
so you dont have to manually remember and add them your self.How does it look in the wild?
You can add all notifications on One line
Whatever custom notification that you have in your project will now be registered and the best thing is, that if you create a new one, then you no longer have to forget to register it.
Cheers 🍻