ContractBasedImportDefinition Constructor (String, String, IEnumerable<KeyValuePair<String, Type>>, ImportCardinality, Boolean, Boolean, CreationPolicy)
Microsoft Silverlight will reach end of support after October 2021. Learn more.
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)
Syntax
'Declaration
Public Sub New ( _
contractName As String, _
requiredTypeIdentity As String, _
requiredMetadata As IEnumerable(Of KeyValuePair(Of String, Type)), _
cardinality As ImportCardinality, _
isRecomposable As Boolean, _
isPrerequisite As Boolean, _
requiredCreationPolicy As CreationPolicy _
)
public ContractBasedImportDefinition(
string contractName,
string requiredTypeIdentity,
IEnumerable<KeyValuePair<string, Type>> requiredMetadata,
ImportCardinality cardinality,
bool isRecomposable,
bool isPrerequisite,
CreationPolicy requiredCreationPolicy
)
Parameters
- contractName
Type: System.String
A string that contains the contract name of the Export object required by the ContractBasedImportDefinition.
- 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 nulla null reference (Nothing in Visual Basic).
- requiredMetadata
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 nulla null reference (Nothing in Visual Basic) to set the RequiredMetadata property to an empty IEnumerable<T> collection.
- cardinality
Type: System.ComponentModel.Composition.Primitives.ImportCardinality
One of the ImportCardinality values that indicates the cardinality of the Export objects required by the ContractBasedImportDefinition.
- isRecomposable
Type: System.Boolean
true to specify that the ContractBasedImportDefinition can be satisfied multiple times throughout the lifetime of a ComposablePart; otherwise, false.
- isPrerequisite
Type: System.Boolean
true to specify that the ContractBasedImportDefinition 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 CreationPolicy for the exports used to satisfy this import. If no specific CreationPolicy is needed, the default is Any.
Exceptions
Exception | Condition |
---|---|
ArgumentNullException | contractName is nulla null reference (Nothing in Visual Basic). |
ArgumentException | contractName is an empty string (""). -or- requiredMetadata contains an element that is nulla null reference (Nothing in Visual Basic). -or- cardinality is not one of the ImportCardinality values. |
Version Information
Silverlight
Supported in: 5, 4
Platforms
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.