Exemplo n.º 1
0
        public void GetExports()
        {
            var catalog = new AggregateCatalog();
            Expression <Func <ExportDefinition, bool> > constraint = (ExportDefinition exportDefinition) => exportDefinition.ContractName == AttributedModelServices.GetContractName(typeof(MyExport));
            IEnumerable <Tuple <ComposablePartDefinition, ExportDefinition> > matchingExports = null;

            matchingExports = catalog.GetExports(constraint);
            Assert.NotNull(matchingExports);
            Assert.True(matchingExports.Count() == 0);

            var testsDirectoryCatalog = new DirectoryCatalog(TemporaryFileCopier.GetTemporaryDirectory());

            catalog.Catalogs.Add(testsDirectoryCatalog);
            matchingExports = catalog.GetExports(constraint);

            Assert.NotNull(matchingExports);
            Assert.True(matchingExports.Count() >= 0);

            IEnumerable <Tuple <ComposablePartDefinition, ExportDefinition> > expectedMatchingExports = catalog.Parts
                                                                                                        .SelectMany(part => part.ExportDefinitions, (part, export) => new Tuple <ComposablePartDefinition, ExportDefinition>(part, export))
                                                                                                        .Where(partAndExport => partAndExport.Item2.ContractName == AttributedModelServices.GetContractName(typeof(MyExport)));

            Assert.True(matchingExports.SequenceEqual(expectedMatchingExports));

            catalog.Catalogs.Remove(testsDirectoryCatalog);
            matchingExports = catalog.GetExports(constraint);
            Assert.NotNull(matchingExports);
            Assert.True(matchingExports.Count() == 0);
        }
Exemplo n.º 2
0
 GetExports(ImportDefinition definition)
 {
     return(_aggregateCatalog.GetExports(definition));
 }
Exemplo n.º 3
0
 /// <inheritdoc />
 public override IEnumerable <Tuple <ComposablePartDefinition, ExportDefinition> > GetExports(ImportDefinition definition) =>
 _aggregateCatalog.GetExports(definition);