Show / Hide Table of Contents

Class Converter

Provides extension methods for delegate Converter<TInput,TOutput> and predefined converters.

Inheritance
Object
Converter
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Object.ToString()
Namespace: DotNext
Assembly: DotNext.dll
Syntax
public static class Converter

Methods

| Improve this Doc View Source

AsFunc<TInput, TOutput>(Converter<TInput, TOutput>)

Converts Converter<TInput,TOutput> into Func<T,TResult>.

Declaration
public static Func<TInput, TOutput> AsFunc<TInput, TOutput>(this Converter<TInput, TOutput> converter)
Parameters
Type Name Description
Converter<TInput, TOutput> converter

The converted delegate.

Returns
Type Description
Func<TInput, TOutput>

A delegate of type Func<T,TResult> referencing the same method as original delegate.

Type Parameters
Name Description
TInput

The type of input argument.

TOutput

Return type of the function.

| Improve this Doc View Source

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

Converts Converter<TInput,TOutput> into predicate.

Declaration
public static Predicate<T> AsPredicate<T>(this Converter<T, bool> converter)
Parameters
Type Name Description
Converter<T, Boolean> converter

A delegate to convert.

Returns
Type Description
Predicate<T>

A delegate of type Predicate<T> referencing the same method as original delegate.

Type Parameters
Name Description
T

Type of predicate argument.

| Improve this Doc View Source

AsValueFunc<TInput, TOutput>(Converter<TInput, TOutput>, Boolean)

Converts Converter<TInput,TOutput> into ValueFunc<T, TResult>.

Declaration
public static ValueFunc<TInput, TOutput> AsValueFunc<TInput, TOutput>(this Converter<TInput, TOutput> converter, bool wrap = false)
Parameters
Type Name Description
Converter<TInput, TOutput> 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<TInput, TOutput>

The value delegate representing converter.

Type Parameters
Name Description
TInput

The type of object that is to be converted.

TOutput

The result of conversion.

| 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
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<TInput, TOutput>()

The converter which returns input argument without any modifications.

Declaration
public static Converter<TInput, TOutput> Identity<TInput, TOutput>()

    where TInput : TOutput
Returns
Type Description
Converter<TInput, TOutput>

The identity function.

Type Parameters
Name Description
TInput

Type of input.

TOutput

Type of output.

Remarks

This method returns the same instance of predicate on every call.

| Improve this Doc View Source

TryInvoke<TInput, TOutput>(Converter<TInput, TOutput>, TInput)

Converts the input value without throwing exception.

Declaration
public static Result<TOutput> TryInvoke<TInput, TOutput>(this Converter<TInput, TOutput> converter, TInput input)
Parameters
Type Name Description
Converter<TInput, TOutput> converter

The converter to invoke.

TInput input

The input value to be converted.

Returns
Type Description
Result<TOutput>

The conversion result.

Type Parameters
Name Description
TInput

The type of the value to be converted.

TOutput

The type of the conversion result.

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