Container for Silverlight
For most of our projects we use StructureMap as a Container. Silverlight seems to change this a little. From preliminary review looks like StructureMap is not yet ready for Silverlight, so we started to look into a different container. The one that looked good was Ninject. Simple, straight forward, and elegant.
Binding module defines components:
public class BindingModule : NinjectModule { public override void Load() { Bind<IPrinter>().To<ConsolePrinter>(); Bind<IFooter>().To<Footer>(); Bind<IHeader>().To<Header>(); } }
(there are ways to define some complex scenarios).
Kernel can load binding module(s) by scanning one or more assemblies:
var kernel = new StandardKernel(); kernel.Load(Assembly.GetExecutingAssembly());
Ninject has a few extension projects. Among those one that allows scanning with conventions.
What do I miss from StructureMap? That probably would be the ObjectFactory singleton. Not a biggie, and can be implemented, but very convenient to have it in place from the beginning.
And what are you using as a container for Silverlight?