PartBuilder.SelectConstructor Method

Definition

Specifies the constructor that matching types should use as an importing constructor.

Overloads

SelectConstructor(Func<ConstructorInfo[],ConstructorInfo>)

Specifies the constructor that matching types should use as an importing constructor.

SelectConstructor(Func<ConstructorInfo[],ConstructorInfo>, Action<ParameterInfo,ImportBuilder>)

Specifies the constructor that matching types should use as an importing constructor, and provides configuration information for the resulting import.

SelectConstructor(Func<ConstructorInfo[],ConstructorInfo>)

Source:
PartBuilder.cs
Source:
PartBuilder.cs
Source:
PartBuilder.cs

Specifies the constructor that matching types should use as an importing constructor.

C#
public System.ComponentModel.Composition.Registration.PartBuilder SelectConstructor(Func<System.Reflection.ConstructorInfo[],System.Reflection.ConstructorInfo> constructorFilter);

Parameters

constructorFilter
Func<ConstructorInfo[],ConstructorInfo>

A function that chooses one constructor from a set of constructors.

Returns

The current object, to allow chaining.

Exceptions

constructorFilter is null.

constructorFilter returns null.

constructorFilter returns a constructor that is not associated with the target type.

Applies to

.NET 10 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.1 (package-provided)

SelectConstructor(Func<ConstructorInfo[],ConstructorInfo>, Action<ParameterInfo,ImportBuilder>)

Source:
PartBuilder.cs
Source:
PartBuilder.cs
Source:
PartBuilder.cs

Specifies the constructor that matching types should use as an importing constructor, and provides configuration information for the resulting import.

C#
public System.ComponentModel.Composition.Registration.PartBuilder SelectConstructor(Func<System.Reflection.ConstructorInfo[],System.Reflection.ConstructorInfo> constructorFilter, Action<System.Reflection.ParameterInfo,System.ComponentModel.Composition.Registration.ImportBuilder> importConfiguration);

Parameters

constructorFilter
Func<ConstructorInfo[],ConstructorInfo>

A function that chooses one constructor from a set of constructors.

importConfiguration
Action<ParameterInfo,ImportBuilder>

An object that contains configuration information for the importing constructor. The default is null.

Returns

The current object, to allow chaining.

Exceptions

constructorFilter is null.

constructorFilter returns null.

constructorFilter returns a constructor that is not associated with the target type.

Applies to

.NET 10 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.1 (package-provided)