Class TypeConstructorExtensions

Namespace
Cratis.Reflection
Assembly
Cratis.Fundamentals.dll

Provides a set of methods for working with types and their constructors.

public static class TypeConstructorExtensions
Inheritance
TypeConstructorExtensions
Inherited Members

Methods

GetDefaultConstructor(Type)

Get the default constructor from a type.

public static ConstructorInfo GetDefaultConstructor(this Type type)

Parameters

type Type

Type to get from.

Returns

ConstructorInfo

The default ConstructorInfo.

GetNonDefaultConstructor(Type)

Get the non default constructor, assuming there is only one.

public static ConstructorInfo GetNonDefaultConstructor(this Type type)

Parameters

type Type

Type to get from.

Returns

ConstructorInfo

The ConstructorInfo for the constructor.

GetNonDefaultConstructor(Type, Type[])

Get the non default constructor matching the types.

public static ConstructorInfo GetNonDefaultConstructor(this Type type, Type[] parameterTypes)

Parameters

type Type

Type to get from.

parameterTypes Type[]

Types for matching the parameters.

Returns

ConstructorInfo

The ConstructorInfo for the constructor.

GetNonDefaultConstructorWithGreatestNumberOfParameters(Type)

Get the non default constructor with the greatest number of parameters. Should be used with care. Constructors are not ordered, so if there are multiple constructors with the same number of parameters, it is indeterminate which will be returned.

public static ConstructorInfo GetNonDefaultConstructorWithGreatestNumberOfParameters(this Type type)

Parameters

type Type

Type to get from.

Returns

ConstructorInfo

The ConstructorInfo for the constructor.

HasDefaultConstructor(Type)

Check if a type has a default constructor that does not take any arguments.

public static bool HasDefaultConstructor(this Type type)

Parameters

type Type

Type to check.

Returns

bool

true if it has a default constructor, false if not.

HasNonDefaultConstructor(Type)

Check if a type has a non default constructor.

public static bool HasNonDefaultConstructor(this Type type)

Parameters

type Type

Type to check.

Returns

bool

true if it has a non default constructor, false if not.