SimonG96 / LightweightIocContainer

A lightweight IOC Container that is powerful enough to do all the things you need it to do.
MIT License
4 stars 2 forks source link

Resolve implementation that is registered with interface #49

Closed SimonG96 closed 3 years ago

SimonG96 commented 3 years ago

Allow resolving of an implementation that is registered with an interface.

Registration:

container.Register<TInterface, TImplementation>();

Resolve:

TImplementation impl = container.Resolve<TImplementation>();
theKBro commented 3 years ago

Should this also work for dependency injected objects?

SimonG96 commented 3 years ago

@theKBro: Yes, injected objects are resolved as well:

https://github.com/SimonG96/LightweightIocContainer/blob/34cdbc52df284aacc115b531bc9eb2966364a530/LightweightIocContainer/IocContainer.cs#L559-L560