Based on your last few questions, it looks like you are digging into Unity. If you haven't read it already, I recommend the
Developer's Guide to Dependency Injection Using Unity.
I tried reading it ( downloaded it as DIPwithUnity.pdf ) after I've finished DIP in Net by Seeman. While I've managed to digest Seeman's book in just a few days, this pdf is like pulling teeth. Text is so confusing and ambiguous, that it manages to confuse
even when describing a concept the reader is totally familiar with. So I did crawl up to page 30, but then all my nails were gone due to biting them veraciously, so I had no choice but stop reading it
Instead I opted for trial and error approach, where I learn how Unity behaves by trying different combinations of configurations etc.
Msdn articles on Unity 2 are much clearer, though at times they still are way more confusing and ambigous than they should be. Here's are two examples (
) of what I'm talking about ( and if you find some time, I'd appreciate if you'd help me with the question ):
Using the RegisterInstance method to register an existing object results in the same behavior as if you just registered the lifetime container with RegisterType. Therefore, it is recommended that you do not use the RegisterInstance method to register
an existing object when using the non-default lifetime managers except for the thread in which the RegisterInstance was invoked.
The confusing part:
... when using the non-default lifetime managers except for the thread in which the RegisterInstance was invoked.
What is the above excerpt trying to convey? That in other threads we should only use __RegisterInstance __ when using default lifetime managers, but in thread where it was invoked we can use it even if using non-default lifetime managers?
If you registered an existing instance of an object using the RegisterInstance method, the container returns the same instance for all calls to Resolve or ResolveAll or when the dependency mechanism injects instances into other classes, provided
that one of the following is true:
• You are resolving in the same context in which you registered the instance when using a different lifetime manager.
I understand that we'll get same instance for all calls to Resolve
if this instance is resolved in the same context in which we called
. But I don't get what they meant by "using a different lifetime manager
thanks much for your help
Anyways, thank you for your help