Esempio n. 1
0
 internal static bool IsImportDependentOnPart(this ImportDefinition import, ComposablePartDefinition part, ExportDefinition export, bool expandGenerics)
 {
     import = import.GetProductImportDefinition();
     if (expandGenerics)
     {
         return(part.TryGetExports(import, out _, out _));
     }
     else
     {
         return(TranslateImport(import, part).IsConstraintSatisfiedBy(export));
     }
 }
 internal static bool IsImportDependentOnPart(this ImportDefinition import, ComposablePartDefinition part, ExportDefinition export, bool expandGenerics)
 {
     import = import.GetProductImportDefinition();
     if (expandGenerics)
     {
         return(part.TryGetExports(import, out Tuple <ComposablePartDefinition, ExportDefinition>?singleMatch, out IEnumerable <Tuple <ComposablePartDefinition, ExportDefinition> >?multipleMatches));
     }
     else
     {
         return(TranslateImport(import, part).IsConstraintSatisfiedBy(export));
     }
 }
        internal static IEnumerable <string> GetCandidateContractNames(this ImportDefinition import, ComposablePartDefinition part)
        {
            import = import.GetProductImportDefinition();
            string contractName        = import.ContractName;
            string genericContractName = import.Metadata.GetValue <string>(CompositionConstants.GenericContractMetadataName);

            int[] importParametersOrder = import.Metadata.GetValue <int[]>(CompositionConstants.GenericImportParametersOrderMetadataName);
            if (importParametersOrder != null)
            {
                int partArity = part.Metadata.GetValue <int>(CompositionConstants.GenericPartArityMetadataName);
                if (partArity > 0)
                {
                    contractName = GenericServices.GetGenericName(contractName, importParametersOrder, partArity);
                }
            }

            yield return(contractName);

            if (!string.IsNullOrEmpty(genericContractName))
            {
                yield return(genericContractName);
            }
        }