Geeks With Blogs
Watson Jon Code and ramblings from Watson October 2009 Entries
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) ......

Posted On Monday, October 19, 2009 10:56 PM

It is hard to know when to move on
A post, possibly flame-bait, was sent out to a group that I subscribe. It was a response to a previous post about the “Duct Tape Programmer.” Incase you’re not familiar, it was started by a post from Joel Spolsky and taken to several extremes by way too many people. Anyway, the poster said something like this: “I used to idolize Joel Spolsky. However after reading his thoughts and listening to his podcast for the last couple of years I've come to realize he's an arrogant blowhard.” This made me pause ......

Posted On Tuesday, October 6, 2009 9:42 PM

Go ahead and repeat yourself
Did you know about the “Repeat” extension method? Enumerable.Repeat generates a sequence of repeated values – perfect for some testing scenarios. Here’s how I’ve used it… private static ISearchService CreateSearchServiceWithExpe... searchText, int ountOfResults) { var results = Enumerable.Repeat(new SearchResult { Id = searchText, Description = searchText, Title = searchText, Project = searchText }, countOfResults); return new MockSearchService(results.T... } This method takes ......

Posted On Monday, October 5, 2009 4:13 PM

Copyright © Jon Dalberg | Powered by: