ContractBasedImportDefinition Constructor (String, String, IEnumerable(KeyValuePair(String, Type)), ImportCardinality, Boolean, Boolean, CreationPolicy)

ContractBasedImportDefinition Constructor (String, String, IEnumerable<KeyValuePair<String, Type>>, ImportCardinality, Boolean, Boolean, CreationPolicy)

Initializes a new instance of the ContractBasedImportDefinition class with the specified contract name, required type identity, required metadata, cardinality, a value that indicates if the import definition is recomposable, a value that indicates if the import definition is a prerequisite, and a value that indicates the required creation policy.

Namespace:  System.ComponentModel.Composition.Primitives
Assembly:  System.ComponentModel.Composition (in System.ComponentModel.Composition.dll)

public ContractBasedImportDefinition(
	string contractName,
	string requiredTypeIdentity,
	IEnumerable<KeyValuePair<string, Type>> requiredMetadata,
	ImportCardinality cardinality,
	bool isRecomposable,
	bool isPrerequisite,
	CreationPolicy requiredCreationPolicy


Type: System.String
A string that contains the contract name of the Export object required by the ContractBasedImportDefinition.
Type: System.String
The type identity of the export type expected. Use the GetTypeIdentity method to generate a type identity for a given type. If no specific type is required, use null.
Type: System.Collections.Generic.IEnumerable<KeyValuePair<String, Type>>
A collection of key/value pairs containing the metadata names and types required by the ContractBasedImportDefinition; or null to set the RequiredMetadata property to an empty IEnumerable<T> collection.
Type: System.ComponentModel.Composition.Primitives.ImportCardinality
One of the ImportCardinality values that indicates the cardinality of the Export objects required by the ContractBasedImportDefinition.
Type: System.Boolean
true to specify that the ContractBasedImportDefinition can be satisfied multiple times throughout the lifetime of a ComposablePart; otherwise, false.
Type: System.Boolean
true to specify that the ContractBasedImportDefinition is required to be satisfied before a ComposablePart can start producing exported objects; otherwise, false.
Type: System.ComponentModel.Composition.CreationPolicy
A value that indicates that the importer requires a specific CreationPolicy for the exports used to satisfy this import. If no specific CreationPolicy is needed, the default is Any.


contractName is null.


contractName is an empty string ("").


requiredMetadata contains an element that is null.


cardinality is not one of the ImportCardinality values.


Supported in: 5, 4

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

© 2016 Microsoft