2016-04-06 8 views
1

私はStructureMapで依存関係を設定しており、それを2回デコレートしたいと思います。私は以下のようにEnrichWithメソッドを使用しましたが、2番目のデコレータのみが実行されます(ResultistAdvertisementInjector)。私がそれらを切り替えると、他のデコレータだけが実行されます。StructureMapで依存関係を2回デコレートする方法

For<IResultListViewModelMapper<ZoekObject>>().Use<ResultListViewModelMapper<ZoekObject>>() 
    .EnrichWith(original => new ResultListDateSeparatorInjector<ZoekObject>(original)) 
    .EnrichWith(original => new ResultistAdvertisementInjector<ZoekObject>(original)); 

2つのデコレータを使用して依存関係を充実させるにはどうすればよいですか?私の頭の上オフ

答えて

1

あなただけの巣のように例えば「装飾」クラス自身、次のことができます。

For<IResultListViewModelMapper<ZoekObject>>().Use<ResultListViewModelMapper<ZoekObject>>() 
       .EnrichWith(original => 
       new ResultListDateSeparatorInjector<ZoekObject>(
        new ResultistAdvertisementInjector<ZoekObject>(original))); 
0

、私はあなたがこのような何かを行うことができると思う。

For<IResultListViewModelMapper<ZoekObject>>() 
    .Use<ResultListViewModelMapper<ZoekObject>>() 
    .EnrichWith(original => 
     new ResultListDateSeparatorInjector<ZoekObject>(
      new ResultistAdvertisementInjector<ZoekObject>(original))); 
関連する問題