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

.NET Framework (current version)
 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com 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
)

Parameters

contractName
Type: System.String

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

requiredTypeIdentity
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.

requiredMetadata
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.

cardinality
Type: System.ComponentModel.Composition.Primitives.ImportCardinality

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

isRecomposable
Type: System.Boolean

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

isPrerequisite
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.

requiredCreationPolicy
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.

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

The metadata associated with this import.

Exception Condition
ArgumentNullException

contractName is null.

ArgumentException

contractName is an empty string ("").

-or-

requiredMetadata contains an element that is null.

-or-

cardinality is not one of the ImportCardinality values.

.NET Framework
Available since 4.5
Return to top
Show: