Show / Hide Table of Contents

Class Type<T>.Constructor<P>

Provides access to constructor of type T with single parameter.

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

Type of constructor parameter.

Methods

| Improve this Doc View Source

Get(Boolean)

Returns constructor T with single parameter of type P.

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

true to reflect non-public constructor.

Returns
Type Description
Constructor<Func<P, T>>

Reflected constructor with single parameter; or null, if it doesn't exist.

| Improve this Doc View Source

Invoke(P, Boolean)

Invokes constructor.

Declaration
public static T Invoke(P arg, bool nonPublic = false)
Parameters
Type Name Description
P arg

Constructor argument.

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 constructor T with single parameter of type P.

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

true to reflect non-public constructor.

Returns
Type Description
Constructor<Func<P, T>>

Reflected constructor with single parameter.

Exceptions
Type Condition
MissingConstructorException

Constructor doesn't exist.

| Improve this Doc View Source

TryInvoke(P, Boolean)

Invokes constructor.

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

Constructor argument.

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