1 // -----------------------------------------------------------------------
\r
2 // Copyright (c) Microsoft Corporation. All rights reserved.
\r
3 // -----------------------------------------------------------------------
\r
5 using System.Collections.Generic;
\r
6 using System.ComponentModel.Composition.Hosting;
\r
7 using System.ComponentModel.Composition.Primitives;
\r
8 using System.Linq.Expressions;
\r
9 using System.Reflection;
\r
10 using Microsoft.Internal;
\r
12 namespace System.ComponentModel.Composition.ReflectionModel
\r
14 internal class PartCreatorParameterImportDefinition : ReflectionParameterImportDefinition, IPartCreatorImportDefinition
\r
16 private readonly ContractBasedImportDefinition _productImportDefinition;
\r
18 public PartCreatorParameterImportDefinition(
\r
19 Lazy<ParameterInfo> importingLazyParameter,
\r
20 ICompositionElement origin,
\r
21 ContractBasedImportDefinition productImportDefinition)
\r
22 : base(importingLazyParameter, CompositionConstants.PartCreatorContractName, CompositionConstants.PartCreatorTypeIdentity,
\r
23 productImportDefinition.RequiredMetadata, productImportDefinition.Cardinality, CreationPolicy.Any, origin)
\r
25 Assumes.NotNull(productImportDefinition);
\r
26 this._productImportDefinition = productImportDefinition;
\r
29 public ContractBasedImportDefinition ProductImportDefinition { get { return this._productImportDefinition; } }
\r
31 public override bool IsConstraintSatisfiedBy(ExportDefinition exportDefinition)
\r
33 if (!base.IsConstraintSatisfiedBy(exportDefinition))
\r
37 return PartCreatorExportDefinition.IsProductConstraintSatisfiedBy(this._productImportDefinition, exportDefinition);
\r
40 public override Expression<Func<ExportDefinition, bool>> Constraint
\r
44 return ConstraintServices.CreatePartCreatorConstraint(base.Constraint, this._productImportDefinition);
\r