I got an interface like this
public interface IWriter
{
...
}
and a class
public class WriterMerger
{
public WriterMerger(IEnumerable<IWriter> writers)
...
}
I want structuremap to fill out the constructor argument on WriterMerger with all registered IWriter's. I registered the different writers with
StructureMap.ObjectFactory.Initialize(x =>
{
x.ForRequestedType<IWriter>().AddConcreteType<MemoryWriter>();
x.ForRequestedType<IWriter>().AddConcreteType<FlatFileWriter>();
x.ForRequestedType<IWriter>().AddConcreteType<DbWriter>();
}
however calling
ObjectFactory.CreateInstance<WriterMerger>();
Returns an exception "No Default Instance defined for PluginFamily System.Collections.Generic.IEnumerable`1[[IWriter..]]" (class name edited)
Any trick for doing this automatically? or will i have to make a custom factory method?