Table of Contents

Class ConstructorInfoExtensions

Namespace
Garyon.Reflection
Assembly
Garyon.dll

Provides extension methods for the ConstructorInfo class.

public static class ConstructorInfoExtensions
Inheritance
ConstructorInfoExtensions
Inherited Members

Methods

InitializeInstance<T>(ConstructorInfo)

Initializes a new instance of a type, given its parameterless ConstructorInfo.

public static T InitializeInstance<T>(this ConstructorInfo ctor)

Parameters

ctor ConstructorInfo

The parameterless constructor of the type. Must not be null.

Returns

T

The initialized instance as an instance of type T.

Type Parameters

T

The type of the resulting instance.

Exceptions

NullReferenceException

The provided parameterless constructor was null.

InitializeInstance<T>(ConstructorInfo, params object?[]?)

Initializes a new instance of a type, given its ConstructorInfo.

public static T InitializeInstance<T>(this ConstructorInfo ctor, params object?[]? parameters)

Parameters

ctor ConstructorInfo

The constructor of the type. Must not be null.

parameters object[]

The parameters to pass to the constructor

Returns

T

The initialized instance as an instance of type T.

Type Parameters

T

The type of the resulting instance.

Exceptions

NullReferenceException

The provided constructor was null.