Class Type<T>.Constructor<P>
Provides access to constructor of type T
with single parameter.
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 SourceGet(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. |
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 |
Exceptions
Type | Condition |
---|---|
MissingConstructorException | Constructor doesn't exist. |
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. |
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 |