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 registration of multiple interfaces for one type #33

Closed
SimonG96 opened this issue Dec 6, 2019 · 2 comments
Closed

Allow registration of multiple interfaces for one type #33

SimonG96 opened this issue Dec 6, 2019 · 2 comments
Assignees
Labels
enhancement New feature or request FluentRegistration Issues or features related to the FluentRegistration IocContainer Issues or features related to the IocContainer
Milestone

Comments

@SimonG96
Copy link
Owner

SimonG96 commented Dec 6, 2019

Allow the registration of multiple interfaces for one registered type, e.g.:

The interface

public interface IFoo : IBar { }

is implemented by

public class Foo : IFoo { }

Users may want to get a IBar or a IFoo and both times need the implementing type Foo.
The registration should look something like this:

container.Register<IBar, IFoo, Foo>();

For registrations with Lifestyle.Transient this could be done by calling IIocContainer.Register<>() multiple times:

container.Register<IBar, Foo>();
container.Register<IFoo, Foo>();

What can be done for registrations with Lifestyle.Singleton? Every Resolve<>() call has to return the same instance of the implemented type.

@SimonG96 SimonG96 added enhancement New feature or request IocContainer Issues or features related to the IocContainer FluentRegistration Issues or features related to the FluentRegistration labels Dec 6, 2019
@SimonG96 SimonG96 added this to the V2.1 milestone Dec 6, 2019
@SimonG96 SimonG96 self-assigned this Dec 6, 2019
@SimonG96 SimonG96 added this to To do in Lightweight IOC Container via automation Dec 6, 2019
@SimonG96 SimonG96 moved this from To do to In progress in Lightweight IOC Container Dec 7, 2019
@SimonG96
Copy link
Owner Author

SimonG96 commented Dec 7, 2019

For Lifestyle.Singleton:
Add the registered Type to the _singletons-list, and not the interface. This way there can be a check if there is already an instance of the type that has to be resolved.

SimonG96 added a commit that referenced this issue Dec 11, 2019
Needed to handle OnCreateActions from inheriting types later on
SimonG96 added a commit that referenced this issue Dec 14, 2019
SimonG96 added a commit that referenced this issue Dec 14, 2019
SimonG96 added a commit that referenced this issue Dec 14, 2019
@SimonG96 SimonG96 moved this from In progress to Testing in Lightweight IOC Container Dec 14, 2019
@SimonG96
Copy link
Owner Author

SimonG96 commented Dec 16, 2019

Add MultipleRegistrations for up to five interfaces:

  • MultipleRegistration<TInterface1,...,TInterface5>
  • IOnCreate<TInterface1,...,TInterface5>
  • IIocContainer.Register<TInterface1,...,TInterface5>
  • RegistrationFactory.Register<TInterface1,...,TInterface5>

Lightweight IOC Container automation moved this from Testing to Done Jan 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request FluentRegistration Issues or features related to the FluentRegistration IocContainer Issues or features related to the IocContainer
Projects
Development

No branches or pull requests

1 participant