Show / Hide Table of Contents

Class Conversion

Provides task result conversion methods.

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

Methods

| Improve this Doc View Source

AsDynamic(Task)

Allows to convert Task<TResult> of unknown result type into dynamically typed task which result can be obtained as Object or any other data type using dynamic approach.

Declaration
public static DynamicTaskAwaitable AsDynamic(this Task task)
Parameters
Type Name Description
Task task

The arbitrary task of type Task<TResult>.

Returns
Type Description
DynamicTaskAwaitable

The dynamically typed task.

Remarks

The type of the returned task is not known at compile time and therefore treated as dynamic. The result value returned by await operator is equal to Value if task is not of type Task<TResult>.

| Improve this Doc View Source

Convert<TInput, TOutput>(Task<TInput>)

Converts one type of task into another.

Declaration
public static Task<TOutput> Convert<TInput, TOutput>(this Task<TInput> task)

    where TInput : TOutput
Parameters
Type Name Description
Task<TInput> task

The task to convert.

Returns
Type Description
Task<TOutput>

The converted task.

Type Parameters
Name Description
TInput

The source task type.

TOutput

The target task type.

| Improve this Doc View Source

Convert<TInput, TOutput>(Task<TInput>, Converter<TInput, TOutput>)

Converts one type of task into another.

Declaration
public static Task<TOutput> Convert<TInput, TOutput>(this Task<TInput> task, Converter<TInput, TOutput> converter)
Parameters
Type Name Description
Task<TInput> task

The task to convert.

Converter<TInput, TOutput> converter

Non-blocking conversion function.

Returns
Type Description
Task<TOutput>

The converted task.

Type Parameters
Name Description
TInput

The source task type.

TOutput

The target task type.

| Improve this Doc View Source

Convert<TInput, TOutput>(Task<TInput>, Converter<TInput, Task<TOutput>>)

Converts one type of task into another.

Declaration
public static Task<TOutput> Convert<TInput, TOutput>(this Task<TInput> task, Converter<TInput, Task<TOutput>> converter)
Parameters
Type Name Description
Task<TInput> task

The task to convert.

Converter<TInput, Task<TOutput>> converter

Asynchronous conversion function.

Returns
Type Description
Task<TOutput>

The converted task.

Type Parameters
Name Description
TInput

The source task type.

TOutput

The target task type.

| Improve this Doc View Source

ToNullable<T>(Task<T>)

Converts value type into nullable value type.

Declaration
public static Task<T?> ToNullable<T>(this Task<T> task)

    where T : struct
Parameters
Type Name Description
Task<T> task

The task to convert.

Returns
Type Description
Task<Nullable<T>>

The converted task.

Type Parameters
Name Description
T

The value type.

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