Yeah, that's the intended behaviour the reason is that the rule is assosciated to the key class, not the actual impl class. However, if you do:
SmartyPants.whenAskedFor(VideoStreamPlayer).useSingleton();
(or add [Singleton] to VideoStreamPlayer)
And then create your other two rules like this, it should only create one instance. If not, it's a bug :)
SmartyPants.whenAskedFor(INetStreamProvider).useClass(VideoStreamPlayer);
SmartyPants.whenAskedFor(VideoStreamPlayer).useClass(VideoStreamPlayer);
The rules:
.useSingleton() creates an instance per key
.useClass() looks up the impl class and attempts whatever is specified in the rules (including the default rule)
.createInstanceOf(Foo) doesn't process any more rules about Foo, and always creates a new instance of the specified impl class.
-Josh
--
"Therefore, send not to know For whom the bell tolls. It tolls for thee."
Josh 'G-Funk' McDonald
-
jo...@joshmcdonald.info
-
http://twitter.com/sophistifunk -
http://flex.joshmcdonald.info/