Show / Hide Table of Contents

Class Converter

Provides extension methods for delegate and predefined converters.

Inheritance
Object
Converter
Namespace: DotNext
Assembly: DotNext.dll
Syntax
public static class Converter : object

Methods

| Improve this Doc View Source

AsFunc<I, O>(Converter<I, O>)

Converts into .

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 referencing the same method as original delegate.

Type Parameters
Name Description
I

The type of input argument.

O

Return type of the function.

| Improve this Doc View Source

AsPredicate<T>(Converter<T, Boolean>)

Converts into predicate.

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 referencing the same method as original delegate.

Type Parameters
Name Description
T

Type of predicate argument.

| Improve this Doc View Source

AsValueFunc<I, O>(Converter<I, O>, Boolean)

Converts into ValueFunc<T, R>.

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 converter into this delegate; false to extract method pointer without holding reference to the passed delegate.

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
| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

  • Improve this Doc
  • View Source
Back to top Generated by DocFX