The Bitter Coder Tutorials, Binsor Style VI: Switching Lifestyles
Previous posts in the series:
So, we create the same adding service component (minus the spelling errors ;)):
You have counted 75 sheep and herded 75 angry cats
This seems a bit odd, as the container is using the same instance for both AddingService requests. Let’s make it give us a new one for each request. This is accomplished by adding the “lifestyle” attribute to the component:
You have counted 60 sheep and herded 15 angry cats
Snot on. Alex goes on to say how you can add an attribute on the class to indicate it’s lifestyle. That isn’t really relevent to what I’m doing here, but you should check it out all the same.
Coming up….Switching Implementations, which is where a DI container really starts to make sense.