Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

are multiple ninject bindings guaranteed to maintain their binding order

If I register:

Bind<IWeapon>().To<Sword>();
Bind<IWeapon>().To<Knife>();
Bind<IWeapon>().To<ChuckNorris>();

And then retrieve via:

IEnumerable<IWeapon> weapons = ServiceLocator.Current.GetAllInstances<IWeapon>();

Am I guaranteed the bindings will always be handed back in that order?

I tried it, and it seems it does, but this could be purely incidental.

like image 221
AaronHS Avatar asked Oct 21 '11 08:10

AaronHS


1 Answers

Short answer: No, you aren't!

A bit longer answer: The current implementation keeps the order. But it is not garanteed that this will still be the case in future versions of Ninject. Also you shouldn't have such business rules in the IoC container configuration.

like image 97
Remo Gloor Avatar answered Sep 28 '22 18:09

Remo Gloor