chorse (16) [Avatar] Offline
#1
At the bottom of page 393 this code in italics appears incomplete in the final version of the Meap. It appears to be missing code lines A & 3.

One of the important features of child containers is that they allow us to properly release components
when the usage scope completes. We create a new child container with the CreateChildContainer method
and release all appropriate components by invoking its Dispose method:

using (var child = container.CreateChildContainer()) 1
{
var meal = child.Resolve<IMeal>(); 2
A
} 3

1 Create child container
2 Resolve meal
A Consume meal
3 Dispose child container


-R

Message was edited by:
chorse

Message was edited by:
chorse
mark.seemann (383) [Avatar] Offline
#2
Re: Missing Text Page 393 - Unity Dispose
Thanks for writing.

The 'A' cueball is a placeholder for any code you might like to use - I've instructed the typesetter for the book to make that apparent, but I'm not sure that's clear in the MEAP...

Closing the using scope disposes the child container, so cueball 3 is correct.
chorse (16) [Avatar] Offline
#3
Re: Missing Text Page 393 - Unity Dispose
Thanks.

I think it would be clearer if one just states something like 'placeholder for your code' or 'insert your code here' at the line at "A" . I did notice a comment on the "A" on the next page, but IMHO that does not really mitigate the initial confusion a reader might have when going through the example code.

As for line 3, I was just expecting an explicit dispose statement. It's nice to know that just closing the bracket does the same thing.

BTW: I found your book very useful. I particularly liked the way you went through DI patterns and how they applied to different types of programming. I also found the sections of the different DI containers, especially the Unity chapter, extremely helpful on a current MVC3 project.

I also found it helpful in deciphering the open source nopCommerce site structure (DI in ASP.NET), which allowed me to add some new functionality customize it for a client. I also used interception to add a few new wrinkles to the standard models.

-Richard
mark.seemann (383) [Avatar] Offline
#4
Re: Missing Text Page 393 - Unity Dispose
I'll work with the typesetter to ensure that the 'placeholder' is more apparent.

Thanks for your feedback smilie