-
-
Notifications
You must be signed in to change notification settings - Fork 101
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
Add InsertProvider extensions and tests #247
Conversation
Codecov Report
@@ Coverage Diff @@
## main #247 +/- ##
===================================
Coverage 84% 84%
===================================
Files 75 75
Lines 2036 2045 +9
Branches 294 296 +2
===================================
+ Hits 1722 1733 +11
+ Misses 230 228 -2
Partials 84 84
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
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.
Looks good, but the lifetime check can probably be skipped (same for removing), because clearing the providers/processors uses Services.RemoveAll()
that only looks at the service type anyway.
@ronaldbarendse Agreed. Removed that additional check. |
I had another look at this and there are some issues with the current implementation: builder.ClearProviders();
builder.AddProvider<PhysicalFileSystemProvider>();
builder.AddProvider<MockImageProvider>();
builder.InsertProvider<MockImageProvider>(2); // Does not throw ArgumentOutOfRangeException, because it's inserted after the existing 2 providers, but TryAddEnumerable only adds the first implementation builder.ClearProviders();
builder.AddProvider<PhysicalFileSystemProvider>();
builder.InsertProvider<MockImageProvider>(0);
builder.InsertProvider<MockImageProvider>(1); // Does not change the index to 1 (last), because there's already an implementation added before it See the implementation of TryAddEnumerable. |
Prerequisites
Description
Adds the ability to insert an
IImageProvider
or factory into the provider collection. This reduces boilerplate code when adding multiple providers.