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

allow multiple registrations with Last In First Out #2143

Merged
merged 2 commits into from
Aug 10, 2020
Merged

allow multiple registrations with Last In First Out #2143

merged 2 commits into from
Aug 10, 2020

Conversation

dansiegel
Copy link
Member

Description of Change

Changes default behavior for DryIoc to retain multiple registrations for a given service. Given the following code:

containerRegistry.Register<IFoo, FooA>();
containerRegistry.Register<IFoo, FooB>();

Prism has always and will continue to expect that when we call Resolve<IFoo>() a new instance of FooB should be returned by the container.

As documented in the original Prism.Container.Extensions issue, a developer may which to resolve IEnumerable<IFoo>() such as with Shiny in which Shiny does a ResolveAll<T> to return an IEnumerable<T> for any delegates that were registered. This change now allows the container to retain each registration to return the IEnumerable with an instance from each registration when IEnumerable<T> is resolved, and continue to return the last registration when T is resolved.

Bugs Fixed

API Changes

None

Behavioral Changes

Given the above code:

var single = Container.Resolve<IFoo>(); // Resolves FooB
var all = Container.Resolve<IEnumerable<IFoo>>(); // Returns an enumerable with an instance for both FooA and FooB

PR Checklist

  • Has tests (if omitted, state reason in description)
  • Rebased on top of master at time of PR
  • Changes adhere to coding standard

@dansiegel dansiegel added the DO-NOT-MERGE-!!! 🛑 Pull Request should not be merged in it's current state label Jun 29, 2020
@dansiegel dansiegel added enhancement and removed DO-NOT-MERGE-!!! 🛑 Pull Request should not be merged in it's current state labels Aug 10, 2020
@dansiegel dansiegel merged commit 4906e5f into master Aug 10, 2020
@dansiegel dansiegel deleted the lifo branch August 10, 2020 18:22
@dansiegel dansiegel added this to the Prism 8.0 milestone Aug 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants