Class Type<T>.Constructor
Provides access to constructor of type T
without parameters.
Inherited Members
Namespace: DotNext.Reflection
Assembly: DotNext.Reflection.dll
Syntax
public static class Constructor
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<TSignature>(Boolean)
Reflects constructor of type T
which signature
is specified by delegate type.
Declaration
public static Constructor<TSignature> Get<TSignature>(bool nonPublic = false)
where TSignature : MulticastDelegate
Parameters
Type | Name | Description |
---|---|---|
Boolean | nonPublic | true to reflect non-public constructor. |
Returns
Type | Description |
---|---|
Constructor<TSignature> | Reflected constructor; or null, if constructor doesn't exist. |
Type Parameters
Name | Description |
---|---|
TSignature | 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<TSignature>(Boolean)
Reflects constructor of type T
which signature
is specified by delegate type.
Declaration
public static Constructor<TSignature> Require<TSignature>(bool nonPublic = false)
where TSignature : MulticastDelegate
Parameters
Type | Name | Description |
---|---|---|
Boolean | nonPublic | true to reflect non-public constructor. |
Returns
Type | Description |
---|---|
Constructor<TSignature> | Reflected constructor. |
Type Parameters
Name | Description |
---|---|
TSignature | 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 |