Watson Jon

Code and ramblings from Watson
posts - 15, comments - 7, trackbacks - 0

My Links

News

Twitter












Archives

Post Categories

User Groups

Unity

Injecting an array of objects with Unity
If you only have one implementation of a registered interface then it is pretty straight forward, but what do you do if you have multiple implementations of an interface? Now you have to get a little more explicit when registering items in your container. Let’s go through a simple example. Say you have a class, OrderProcessor, that takes one implementation of IMessageWriter: public class OrderProcessor { private readonly IMessageWriter _messageWriter; public OrderProcessor(IMessageWriter messageWriter)...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Posted On Monday, October 19, 2009 10:56 PM | Feedback (1) | Filed Under [ IoC Unity ]

Unity Convention Based Registration
Maybe it is just me, but I’m not a big fan of huge amounts of XML configuration. I can get by with a few name-value pairs in an app.config or a web.config but much more makes me nervous that I’m going to mistype something and not know about it until run time. I’ve been using Unity and it has the ability to load up its configuration from the app.config or web.config. Here’s a sample: Yeah…..what else ya got? It offers a “fluent” API for programmatic registration. Sweet! Now I just have to convert...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Posted On Monday, September 28, 2009 9:35 PM | Feedback (1) | Filed Under [ IoC Unity ]

Powered by: