コード例 #1
0
        static IEnumerable <Export> ResolveExports(this IComponentContext context, ContractBasedImportDefinition cbid)
        {
            var componentsForContract = context.ComponentsForContract(cbid);

            var exportsForContract = componentsForContract
                                     .Select(cpt => context.ResolveComponent(cpt, Enumerable.Empty <Parameter>()))
                                     .Cast <Export>()
                                     .ToList();

            return(exportsForContract);
        }
コード例 #2
0
        private static IEnumerable <Export> ResolveExports(this IComponentContext context, ContractBasedImportDefinition cbid)
        {
            var contractService = new ContractBasedService(cbid.ContractName, cbid.RequiredTypeIdentity);

            var componentsForContract = context.ComponentsForContract(cbid, contractService);

            var exportsForContract = componentsForContract
                                     .Select(cpt => context.ResolveComponent(new ResolveRequest(contractService, cpt, Enumerable.Empty <Parameter>())))
                                     .Cast <Export>()
                                     .ToList();

            return(exportsForContract);
        }
コード例 #3
0
        static Export[] ResolveExports(this IComponentContext context, ContractBasedImportDefinition cbid)
        {
            var componentsForContract = context.ComponentsForContract(cbid);

            var ts = new TypedService(typeof(Export));
            var exportsForContract = new Export[componentsForContract.Count];
            var emptyParams        = Enumerable.Empty <Parameter>();

            for (int i = 0; i < componentsForContract.Count; i++)
            {
                exportsForContract[i] = (Export)context.ResolveComponent(ts, componentsForContract[i], emptyParams);
            }
            return(exportsForContract);
        }