Show / Hide Table of Contents

Class Type<T>.Constructor

Provides access to constructor of type T without parameters.

Inheritance
Object
Type<T>.Constructor
Namespace: DotNext.Reflection
Assembly: DotNext.Reflection.dll
Syntax
public static class Constructor : object

Methods

| Improve this Doc View Source

Get(Boolean)

Returns public constructor of type T without parameters.

Declaration
public static Constructor<Func<T>> Get(bool nonPublic = false)
Parameters
Type Name Description
Boolean nonPublic

true to reflect non-public constructor.

Returns
Type Description
Constructor<Func<T>>

Reflected constructor without parameters; or null, if it doesn't exist.

| Improve this Doc View Source

Get<D>(Boolean)

Reflects constructor of type T which signature is specified by delegate type.

Declaration
public static Constructor<D> Get<D>(bool nonPublic = false)

    where D : MulticastDelegate
Parameters
Type Name Description
Boolean nonPublic

true to reflect non-public constructor.

Returns
Type Description
Constructor<D>

Reflected constructor; or null, if constructor doesn't exist.

Type Parameters
Name Description
D

Type of delegate describing constructor signature.

| Improve this Doc View Source

Invoke(Boolean)

Invokes constructor.

Declaration
public static T Invoke(bool nonPublic = false)
Parameters
Type Name Description
Boolean nonPublic

true to reflect non-public constructor.

Returns
Type Description
T

Instance of T.

Exceptions
Type Condition
MissingConstructorException

Constructor doesn't exist.

| Improve this Doc View Source

Require(Boolean)

Returns public constructor of type T without parameters.

Declaration
public static Constructor<Func<T>> Require(bool nonPublic = false)
Parameters
Type Name Description
Boolean nonPublic

true to reflect non-public constructor.

Returns
Type Description
Constructor<Func<T>>

Reflected constructor without parameters.

Exceptions
Type Condition
MissingConstructorException

Constructor doesn't exist.

| Improve this Doc View Source

Require<D>(Boolean)

Reflects constructor of type T which signature is specified by delegate type.

Declaration
public static Constructor<D> Require<D>(bool nonPublic = false)

    where D : MulticastDelegate
Parameters
Type Name Description
Boolean nonPublic

true to reflect non-public constructor.

Returns
Type Description
Constructor<D>

Reflected constructor.

Type Parameters
Name Description
D

Type of delegate describing constructor signature.

Exceptions
Type Condition
MissingConstructorException

Constructor doesn't exist.

| Improve this Doc View Source

TryInvoke(Boolean)

Invokes constructor.

Declaration
public static Optional<T> TryInvoke(bool nonPublic = false)
Parameters
Type Name Description
Boolean nonPublic

true to reflect non-public constructor.

Returns
Type Description
Optional<T>

Instance of T if constructor exists.

  • Improve this Doc
  • View Source
Back to top Generated by DocFX