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

| Edit this page 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.

| Edit this page View Source

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

Converts Converter<TInput, TOutput> into predicate.

Declaration
public static Predicate<T> AsPredicate<T>(this Converter<T, bool> converter)
Parameters
Type Name Description
Converter<T, bool> 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.

| Edit this page 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.

| Edit this page 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.

| Edit this page 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.

  • Edit this page
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾