Exemple #1
0
 /// <summary>
 ///  Create a PartDefinitionInfo representing partDefinition.
 /// </summary>
 /// <param name="partDefinition">The part to be analyzed.</param>
 public PartDefinitionInfo(ComposablePartDefinition partDefinition)
 {
     PartDefinition    = partDefinition;
     ImportDefinitions = Enumerable.Empty <ImportDefinitionInfo>();
     _isRejected       = new Lazy <bool>(() => ImportDefinitions
                                         .Any(idi => idi.Exception is ImportCardinalityMismatchException));
 }
        // alwayc called under a lock
        private bool RequiresActivation()
        {
            // If we have any imports then we need activation
            // (static imports are not supported)
            if (ImportDefinitions.Any())
            {
                return(true);
            }

            // If we have any instance exports, then we also
            // need activation.
            return(ExportDefinitions.Any(definition =>
            {
                ExportingMember member = GetExportingMemberFromDefinition(definition);

                return member.RequiresInstance;
            }));
        }
Exemple #3
0
 /// <summary>
 /// Determine whether the part imports a contract.
 /// </summary>
 /// <param name="contract">Name of the contract to check for.</param>
 /// <returns>True if the part imports the contract.</returns>
 public bool ImportsContract(string contract)
 {
     return(ImportDefinitions.Any(id => id.ImportDefinition.ContractName == contract));
 }