Bootstrapping without custom interface

Feb 14, 2012 at 10:28 AM

Hi,

I'm new to Bootstrapper, but I really like the idea and the way it is implemented. There's just one thing that directly stroke me as odd and I'd thought I'd share it with you to find out why it is implemented like this.

It has to do with the extensions. For example, to bootstrap Autofac you need to have classes that implement the IAutofacRegistration interface. Similarly, with AutoMapper you need to implement IMapCreator. The thing is, that both these components (and some of the rest) have their own way of defining classes to be used in scenarios like this one, namely Autofac.Module forAutofac and Profile for AutoMapper.

The question is, why not use these to scan the assemblies instead of a custom Bootstrapper interface? Wouldn't that be cleaner and less intrusive? Now for example I need to add references to Bootrstrapper extensions just for implementing the specific interface, while it wouldn't be necessary if I just implemented the component's default way of breaking it's configuration in different classes...

Anyway, nice job ;)

Kostas

Feb 27, 2012 at 12:34 AM
Edited Feb 27, 2012 at 12:34 AM

I tend to agree with you kkara, I am mostly a windsor guy, and I tend to prefer the default "container.Install(IWindsorInstaller)" method, however, I also like having the common format defined by the bootstrapper, as it applys a sort of common simplicity over the API. The idea of the project is to simplify the work needed to wire up the startup dependencies of your application, and it does that very well.

Perhaps a merged approach, in the case of windsor, it would scan all included assemblies and install all the WindsorInstallers into the container, as well would run all the classes implementing the IWindsorRegistration interface. Then it's up to you to choose.

In the meantime, if your a real stickler, there's nothing stopping you from making one class that implements the custom interface, that just runs all the installers/modules/profiles etc.

For Example:
public class RunWindsorInstallers : IWindsorRegistration {

public void Register(IWindsorContainer container){

var registrationHelper = new RegistrationHelper();
container.Install(registrationHelper
.GetInstancesOfTypesImplementing<IWindsorInstaller>().ToArray());

}

}

Coordinator
Apr 28, 2012 at 2:55 PM

Check out release 2.0.3.0. Bootstrapper now support Native Registration for all container (except Unity).