私のMEFの使用法では、コードの他の多くの部分で利用できるようにしたいインポートがたくさんあります。何かのようなもの:
[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 */);
}
}
インポートされた各サービスを個別のパラメーターとして渡すこともできますが、それは多くの退屈なコードです。もっといいものがあるに違いない。何か案は?