Class Type<T>.Constructor
Provides access to constructor of type T
without parameters.
Namespace: DotNext.Reflection
Assembly: DotNext.Reflection.dll
Syntax
public static class Constructor : object
Methods
| Improve this Doc View SourceGet(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. |
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. |
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 |
Exceptions
Type | Condition |
---|---|
MissingConstructorException | Constructor doesn't exist. |
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. |
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. |
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 |