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

.NET Framework (current version)

The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

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

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,
	IDictionary<string, object> metadata


Type: System.String

The contract name of the Export object required by the import definition.

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 that contain the metadata names and types required by the import definition; or null to set the RequiredMetadata property to an empty IEnumerable<T> collection.

Type: System.ComponentModel.Composition.Primitives.ImportCardinality

One of the enumeration values that indicates the cardinality of the Export objects required by the import definition.

Type: System.Boolean

true to specify that the import definition can be satisfied multiple times throughout the lifetime of a ComposablePart; otherwise, false.

Type: System.Boolean

true to specify that the import definition 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 creation policy for the exports used to satisfy this import. If no specific creation policy is needed, the default is CreationPolicy.Any.

Type: System.Collections.Generic.IDictionary<String, Object>

The metadata associated with this import.

Exception Condition

contractName is null.


contractName is an empty string ("").


requiredMetadata contains an element that is null.


cardinality is not one of the ImportCardinality values.

.NET Framework
Available since 4.5
Return to top