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

Simplify Registration class API by removing the service type #345

Closed
dotnetjunkie opened this Issue Dec 13, 2016 · 0 comments

Comments

1 participant
@dotnetjunkie
Collaborator

dotnetjunkie commented Dec 13, 2016

From the early days on, Simple Injector tried to provide users with a flexible and extendible API. Throughout this process though, flexibility was created that seems to have no appropriate use case, and now has proven to be a limiting factor. These are especially the parts that accept a ServiceType and ImplementationType pair.

Affected API:

  • ILifestyleSelectionBehavior.SelectLifestyle(Type, Type). Supplying the service type to SelectLifestyle assumes that two calls to SelectLifestyle using the same implementation type could return a different lifestyle in case the service type is different, which is really weird and is actually something that we are trying to combat while implementing #219.
  • IConstructorResolutionBehavior.GetConstructor(Type, Type); This assumes that for the same implementation type a different constructor could be selected based on the service type. Such requirement is a clear case of bad application design; such class violates SRP. It's unlikely that there is any user of Simple Injector that is actually relying on this behavior.
  • Lifestyle.CreateRegistration<TService, TImplementation>(Container); The only reason that TService is included here is because of the two previously described calls.
  • Lifestyle.CreateRegistration(Type, Type, Container); same as above.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment