June 7, 2013

Dependency Injection of Multiple Objects Same Interface using StructureMap


I have been reading Mark Seemann's excellent book on Dependency Injection & applying what I have been learning to StructureMap.

Often times I have multiple objects that implement the same interface. In the past I may have used an abstract factory to create the instance I needed at a given time based on some sort of key or identifier like so:





However I was interested in using an IOC container like StructureMap to get rid of the ugly switch statement with the factory object. I did so by registering each object in my container and giving it a name with the .Named() method like so:

If you would like to see more please check out a simple example project over at my GitHub called MultipleObjectDemo.

Fun With Strongly Typed Enums!

Nobody likes using plain old boring Enums in C# these days! So why not try using a cool strongly typed Enum instead.


May 2, 2013

CSS Font Shortcuts



Using multiple weights and styles

In CSS, you can specify font-weights other than normal and bold by using numeric font-weight values. Here is a list of which numeric values most frequently correspond to which weights:
  • 100 = thin
  • 200 = extra-light
  • 300 = light
  • 400 = normal, book
  • 500 = medium
  • 600 = demi-bold
  • 700 = bold
  • 800 = heavy
  • 900 = black