forked from MefContrib/MefContrib
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewritten FilteringCatalog so that it use InterceptingCatalog internally
- Loading branch information
Showing
7 changed files
with
57 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
namespace MefContrib.Hosting.Filter | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel.Composition.Primitives; | ||
using System.Linq; | ||
using MefContrib.Hosting.Interception; | ||
|
||
public class FilteringExportHandler : IExportHandler | ||
{ | ||
private readonly Func<ComposablePartDefinition, bool> filter; | ||
|
||
public FilteringExportHandler(Func<ComposablePartDefinition, bool> filter) | ||
{ | ||
if (filter == null) throw new ArgumentNullException("filter"); | ||
|
||
this.filter = filter; | ||
} | ||
|
||
public void Initialize(ComposablePartCatalog interceptedCatalog) | ||
{ | ||
} | ||
|
||
public IEnumerable<Tuple<ComposablePartDefinition, ExportDefinition>> GetExports(ImportDefinition definition, IEnumerable<Tuple<ComposablePartDefinition, ExportDefinition>> exports) | ||
{ | ||
return exports.Where(export => this.filter(export.Item1)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters