Register and Resolve with Class Scope
Suppose you have an IDoWhatever interface, and you have some concrete implementations like DoWhateverToFoos and DoWhateverToBars. They both implement IDoWhatever, but the former is to be used for Foos while the latter is for Bars.
You can now use the Class object or any instance of the Class as the registration scope. In particular, this came in handy when we had command handlers for various command classes.
1 2 3 4 5 6 7
Resolve with Fallback Scope
We also had some cases where a class wasn’t registered in the specific scope being requested, but it was registered in the default scope. For example, a default command handler doing some logging might not find the registered ILogger in its own scope. It is now possible to specify to asfac that you’d like to take a look in the default scope in the case where a resolution cannot be performed from the specified scope.
1 2 3 4 5 6 7
We also found a few bugs that are now fixed (with accompanying tests, of course!). Basically these were all chalked up to scoped registration using the fluent syntax.
Consider this code:
We found that Widget was actually registered in scope â€˜foo’, and we expected it to be in the default scope. We hope asfac users agree. If you did indeed want to register many things into a common scope, you can do it like this:
1 2 3 4 5 6
If you’re using asfac, please let us know what you think. If you run into any problems, please log an issue on github. Thanks!
Also, thanks to Adobe for tweeting about asfac. However, we want to clarify that the video embedded in Joey’s original asfac post is not us creating asfac. It’s Jon Skeet hacking out IOC concepts in C#.
Learn how #Asfac, an #IoC container, was created in this in-depth #ActionScript video: bit.ly/SZGXo4 â€” Adobe Flash Platform (@AdobeFlash) February 15, 2013
This post originally appeared on The DevStop.