Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > Other ASP.NET > BOOK: Professional ASP.NET Design Patterns
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
BOOK: Professional ASP.NET Design Patterns
This is the forum to discuss the Wrox book Professional ASP.NET Design Patterns by Scott Millett; ISBN: 978-0-470-29278-5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional ASP.NET Design Patterns section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 18th, 2010, 11:37 PM
Authorized User
 
Join Date: Jan 2006
Location: , , Canada.
Posts: 13
Thanks: 6
Thanked 1 Time in 1 Post
Default IoC container for ProductService without registry entry?

I am studying Chapter 8 at the moment and am reading the MVP section where you have the following in bootstrapper:

publicclassControllerRegistry : Registry
{
public ControllerRegistry()
{
ForRequestedType<
ICategoryRepository>().TheDefault.Is.OfConcreteType<CategoryRepository>();
ForRequestedType<
IProductRepository>().TheDefault.Is.OfConcreteType<ProductRepository>();
ForRequestedType<
IPageNavigator>().TheDefault.Is.OfConcreteType<PageNavigator>();
ForRequestedType<
IBasket>().TheDefault.Is.OfConcreteType<WebBasket>();
}
}

And I am also seeing code like this

protectedvoid Page_Init(object sender, EventArgs e)
{
_presenter =
newProductDetailPresenter(this, ObjectFactory.GetInstance<ProductService>(),
ObjectFactory.GetInstance<IBasket>(),
ObjectFactory.GetInstance<IPageNavigator>());
}

see the bolded line above.

My question is: since we don't have an entry for ProductService, how can we get IoC to pass a reference this way?

Shouldn't we instead have

_presenter = newProductDetailPresenter(this,
newProductService(
ObjectFactory.GetInstance<ICategoryRepository>(),

ObjectFactory.GetInstance<IProductRepository>()
),
....
....)



Is this explained anywhere in the book?

Thanks!
Reply With Quote
  #2 (permalink)  
Old November 21st, 2010, 09:03 AM
elbandit's Avatar
Wrox Author
Points: 599, Level: 8
Points: 599, Level: 8 Points: 599, Level: 8 Points: 599, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2007
Location: Southsea, Portsmouth, Hampshire, United Kingdom.
Posts: 107
Thanks: 10
Thanked 17 Times in 15 Posts
Default

Hi SamVan,

Hope you are still enjoying the book.

If you take a look at page 296 I mention how this is achieved using the order service sample code...

Quote:
You may have noticed that you didn’t explicitly register the OrderService type with StructureMap even though it was able to resolve it. This happens because StructureMap auto-wires the dependencies based on what it already has in its container. Auto-wiring your dependencies gives you the maximum benefit of using any type of container. Your client code can remain blissfully unaware of the concrete dependencies defined.


You can find more info on how structuremap does autowiring by reading the info on the structuremap project page -- http://structuremap.net/structuremap/AutoWiring.htm.

I hope this answers your questions.
Cheers
Scott
Reply With Quote
The Following User Says Thank You to elbandit For This Useful Post:
samvan (November 22nd, 2010)
  #3 (permalink)  
Old November 22nd, 2010, 03:13 PM
Authorized User
 
Join Date: Jan 2006
Location: , , Canada.
Posts: 13
Thanks: 6
Thanked 1 Time in 1 Post
Default

yes, how could I miss that paragraph..... thanks Scott and I really enjoy reading your book!
Reply With Quote
  #4 (permalink)  
Old November 22nd, 2010, 04:05 PM
elbandit's Avatar
Wrox Author
Points: 599, Level: 8
Points: 599, Level: 8 Points: 599, Level: 8 Points: 599, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2007
Location: Southsea, Portsmouth, Hampshire, United Kingdom.
Posts: 107
Thanks: 10
Thanked 17 Times in 15 Posts
Default

No worries! Glad your still enjoying the book, let me know if you have any other questions, and it would be great if you could add your feedback in a review on amazon .

Cheers
Scott
Reply With Quote
  #5 (permalink)  
Old November 25th, 2010, 01:56 AM
Authorized User
 
Join Date: Jan 2006
Location: , , Canada.
Posts: 13
Thanks: 6
Thanked 1 Time in 1 Post
Default

Scott,

I plan to write a review once I finish Part II of the book (Chapter 9). Thanks again for your support the past few weeks :)
Reply With Quote
  #6 (permalink)  
Old November 25th, 2010, 01:39 PM
elbandit's Avatar
Wrox Author
Points: 599, Level: 8
Points: 599, Level: 8 Points: 599, Level: 8 Points: 599, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2007
Location: Southsea, Portsmouth, Hampshire, United Kingdom.
Posts: 107
Thanks: 10
Thanked 17 Times in 15 Posts
Default

Fantastico! I really appreciate it, and no worries please ask as many questions as you want :0)

Cheers
Scott
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What is the difference between AOP and IoC kotaiah Spring 0 September 6th, 2007 01:21 AM
Container Binding problem tany4u Javascript How-To 0 October 3rd, 2006 01:36 AM
what the heck is a container?[:D] lcsgeek General .NET 0 January 24th, 2005 12:56 PM
Name 'Container' is not declared. surendran ASP.NET 1.0 and 1.1 Professional 1 August 17th, 2004 10:33 AM
Form Container shortynelson General .NET 1 August 13th, 2004 01:27 PM



All times are GMT -4. The time now is 07:34 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.