Tuesday, March 18, 2014

Migrating from HaveBox 1.6.1 to 2.0.0

It's here, the lastest version of HaveBox. HaveBox 2.0.0. A bump in the major vision number means there are some breaking changes, when migrating from a prior version of HaveBox.

The breaking changes was needed, to get HaveBox in the direction I wanted. My goal is still to keep HaveBox simple, it doesn't mean less features in the future, but on the other hand I will not bloat HaveBox with features. HaveBox 2.0.0 now consist of a core with the basic features build in. Auxiliary features like scanners, config injection or xml configuration, will be added via sub-configs. Sub-config is the key word to extend HaveBox from now on. It should now be possible for everybody, to write a sub-config to customize HaveBox.

The Breaking Changes


Scanners

I have removed the scanner concept from config. I deprecated scanners in version 1.6.0, and from now on, scanner has to be defined sub-configs. HaveBox still comes with a scanner called SimpleScanner, but now it is a sub-config which have to be merged in to the config. See more in the documentation: HaveBox Scanners

Config injection

Config injection has to be enabled by merging in the Config Injection sub-config into the config.  See more in the documentation: Config Injection

Spawning Child Containers

The Spawn methods has been removed. Now you have to configure the life-time, of the singletons in the config section and call CreateChildContainer to create a child container. In this way, it is possible to combine the functionality of the spawn methods. See more in the documentation: Custom life-times

The New Features


TryGetInstance

It now possible to try-getting an instance. It is the same try-get functionality known from the rest of the .NET frameworks. If it succeeds the method returns true, and there will be an instance in the out parameter, else it return false, and there will be NULL in the out parameter.

How About Performance?


HaveBox 2.0.0 has also been optimized for performance. The ilasm has been cleaned and reduced, plus I have written a hashtable to replace Dictionary. The new hashtable is almost twice as fast compared to Dictionary(which also is a hashtable, but less optimal written, check the .NET reference sources.).

The concept app, is showing some nice improvement in performance, but I urge you download HaveBox and do your own testing.

That's all for now


HaveBox 2.0.0 can be downloaded from Nuget: http://www.nuget.org/packages/HaveBox/
The project page: https://bitbucket.org/Have/havebox/downloads

And don't forget to checkout HaveBoxJSON and HaveBoxStates.

Enjoy