Class Converter
Provides extension methods for delegate
Namespace: DotNext
Assembly: DotNext.dll
Syntax
public static class Converter : object
Methods
| Improve this Doc View SourceAsFunc<I, O>(Converter<I, O>)
Converts
Declaration
public static Func<I, O> AsFunc<I, O>(this Converter<I, O> converter)
Parameters
Type | Name | Description |
---|---|---|
DotNext.Converter<I, O> | converter | The converted delegate. |
Returns
Type | Description |
---|---|
DotNext.Func<I, O> | A delegate of type |
Type Parameters
Name | Description |
---|---|
I | The type of input argument. |
O | Return type of the function. |
AsPredicate<T>(Converter<T, Boolean>)
Converts
Declaration
public static Predicate<T> AsPredicate<T>(this Converter<T, bool> converter)
Parameters
Type | Name | Description |
---|---|---|
DotNext.Converter<T, Boolean> | converter | A delegate to convert. |
Returns
Type | Description |
---|---|
DotNext.Predicate<T> | A delegate of type |
Type Parameters
Name | Description |
---|---|
T | Type of predicate argument. |
AsValueFunc<I, O>(Converter<I, O>, Boolean)
Converts
Declaration
public static ValueFunc<I, O> AsValueFunc<I, O>(this Converter<I, O> converter, bool wrap = false)
Parameters
Type | Name | Description |
---|---|---|
DotNext.Converter<I, O> | converter | The type the input object is to be converted to. |
Boolean | wrap | true to wrap |
Returns
Type | Description |
---|---|
ValueFunc<I, O> | The value delegate representing converter. |
Type Parameters
Name | Description |
---|---|
I | The type of object that is to be converted. |
O |
Identity<T>()
The converter which returns input argument without any modifications.
Declaration
public static Converter<T, T> Identity<T>()
Returns
Type | Description |
---|---|
DotNext.Converter<T, T> | The identity function. |
Type Parameters
Name | Description |
---|---|
T | The type of input and output. |
Remarks
This method returns the same instance of predicate on every call.
Identity<I, O>()
The converter which returns input argument without any modifications.
Declaration
public static Converter<I, O> Identity<I, O>()
where I : O
Returns
Type | Description |
---|---|
DotNext.Converter<I, O> | The identity function. |
Type Parameters
Name | Description |
---|---|
I | Type of input. |
O | Type of output. |
Remarks
This method returns the same instance of predicate on every call.
TryInvoke<I, O>(Converter<I, O>, I)
Converts the input value without throwing exception.
Declaration
public static Result<O> TryInvoke<I, O>(this Converter<I, O> converter, I input)
Parameters
Type | Name | Description |
---|---|---|
DotNext.Converter<I, O> | converter | The converter to invoke. |
I | input | The input value to be converted. |
Returns
Type | Description |
---|---|
Result<O> | The conversion result. |
Type Parameters
Name | Description |
---|---|
I | The type of the value to be converted. |
O | The type of the conversion result. |