In my MEF usage, I have a bunch of imports that I want to make available in many other parts of my code. Something like:
[Export (typeof (IBarProvider))]
class MyBarFactory : IBarPovider
{
[Import]
public IFoo1Service IFoo1Service { get; set; }
[Import]
public IFoo2Service IFoo2Service { get; set; }
[Import]
public IFoo3Service IFoo3Service { get; set; }
[Import]
public IFoo4Service IFoo4Service { get; set; }
[Import]
public IFoo5Service IFoo5Service { get; set; }
public IBar CreateBar()
{
return new BarImplementation(/* want to pass the imported services here */);
}
}
class BarImplementation : IBar
{
readonly zib zib;
public BarImplementation(/* ... */)
{
this.zib = new Zib(/* pass services here, too */);
}
}
I could pass each imported service as an individual parameter, but it's a lot of boring code. There's gotta be something better. Any ideas?