public override void Context()
            {
                var catalog = new TypeCatalog(typeof(CtorOrderProcessor));
                var exports = catalog.GetExports(CtorOrderProcessorImportDefinition);

                result = GenericExportHandler.GetExports(CtorOrderProcessorImportDefinition, exports).Single();
            }
            public override void Context()
            {
                var catalog = new TypeCatalog(typeof(OrderRepository));
                var exports = catalog.GetExports(RepositoryImportDefinition);

                result = GenericExportHandler.GetExports(RepositoryImportDefinition, exports);
            }
示例#3
0
        [ActiveIssue(25498, TestPlatforms.AnyUnix)] // System.Reflection.ReflectionTypeLoadException : Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
        public void GetExports()
        {
            var catalog = new TypeCatalog(Assembly.GetExecutingAssembly().GetTypes());
            Expression <Func <ExportDefinition, bool> > constraint = (ExportDefinition exportDefinition) => exportDefinition.ContractName == AttributedModelServices.GetContractName(typeof(MyExport));
            IEnumerable <Tuple <ComposablePartDefinition, ExportDefinition> > 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));
        }