NancyFx / Nancy.Bootstrappers.Windsor

Nancy boostrapper for the Windsor container
http://nancyfx.org
MIT License
14 stars 24 forks source link

Container incorrectly configured when providing external container via GetApplicationContainer override. #17

Closed do0g closed 10 years ago

do0g commented 10 years ago

When overriding GetApplicationContainer in a subclass of WindsorNancyBootstrapper and returning an existing IWindsorContainer that is not created by the WindsorNancyBootstrapper, the container is not configured correctly for use with Nancy, resulting in the exception Castle.MicroKernel.Handlers.HandlerException: Handler for System.Collections.Generic.IEnumerable1[Nancy.ViewEngines.IViewEngine] was not found.`

Workarounds provided here and here copy the registration of the components verbatim from WindsorNancyBootstrapper. I would like to suggest that the configuration of the container occurs in an override of ConfigureApplicationContainer(IWindsorContainer existingContainer) so that both containers owned by WindsorNancyBootstrapper and provided to it will result in correctly configured containers. If configuration is not required it will be possible to opt out of the registration via subclass of WindsorNancyBootstrapper and override of ConfigureApplicationContainer.

Happy to submit a pull request for the change.

horsdal commented 10 years ago

Sorry for the wait. Looks good, except it would be nice to have test that would fail without this. E.g. a test that sets up a bootstrapper which creates its own IContainer in GetApplicationContainer and have the test assert that IViewEngine can be resolved.