Class ResponseCastingExtensions
Extension methods for casting and transforming REST API response types.
Inheritance
ResponseCastingExtensions
Assembly: Glitch9.IO.dll
Syntax
public static class ResponseCastingExtensions
Methods
|
Edit this page
View Source
GetBody<TResponse>(UniTask<RESTResponse<TResponse>>)
Awaits the response and extracts the body.
Declaration
public static UniTask<TResponse> GetBody<TResponse>(this UniTask<RESTResponse<TResponse>> task)
Parameters
Returns
| Type |
Description |
| UniTask<TResponse> |
|
Type Parameters
| Name |
Description |
| TResponse |
|
|
Edit this page
View Source
GetBody<TResponse>(RESTResponse<TResponse>)
Extracts the response body.
Declaration
public static TResponse GetBody<TResponse>(this RESTResponse<TResponse> response)
Parameters
Returns
| Type |
Description |
| TResponse |
|
Type Parameters
| Name |
Description |
| TResponse |
|
|
Edit this page
View Source
GetResult<T>(UniTask<T>)
Awaits the UniTask and returns the result.
Declaration
public static UniTask<T> GetResult<T>(this UniTask<T> t)
Parameters
| Type |
Name |
Description |
| UniTask<T> |
t |
|
Returns
| Type |
Description |
| UniTask<T> |
|
Type Parameters
|
Edit this page
View Source
GetResult<T>(T)
Wraps a value into a UniTask.
Use it to avoid using 'async' keyword when you just want to return a completed UniTask.
Declaration
public static UniTask<T> GetResult<T>(this T value)
Parameters
| Type |
Name |
Description |
| T |
value |
|
Returns
| Type |
Description |
| UniTask<T> |
|
Type Parameters
|
Edit this page
View Source
GetResult<T1, T2>(UniTask<T1[]>)
Awaits the array UniTask and upcasts to a base type array.
Declaration
public static UniTask<T2[]> GetResult<T1, T2>(this UniTask<T1[]> source) where T1 : T2
Parameters
| Type |
Name |
Description |
| UniTask<T1[]> |
source |
|
Returns
| Type |
Description |
| UniTask<T2[]> |
|
Type Parameters
|
Edit this page
View Source
GetResult<T1, T2>(UniTask<T1>)
Awaits the UniTask and upcasts the result to a base type.
Declaration
public static UniTask<T2> GetResult<T1, T2>(this UniTask<T1> t) where T1 : T2
Parameters
| Type |
Name |
Description |
| UniTask<T1> |
t |
|
Returns
| Type |
Description |
| UniTask<T2> |
|
Type Parameters
|
Edit this page
View Source
GetResult<T1, T2>(UniTask<T1>, Func<T1, T2>)
Awaits the UniTask and converts the result using the provided converter.
Declaration
public static UniTask<T2> GetResult<T1, T2>(this UniTask<T1> t, Func<T1, T2> converter)
Parameters
| Type |
Name |
Description |
| UniTask<T1> |
t |
|
| Func<T1, T2> |
converter |
|
Returns
| Type |
Description |
| UniTask<T2> |
|
Type Parameters
|
Edit this page
View Source
GetResult<T1, T2>(T1[])
Casts an array to a base type array asynchronously.
Declaration
public static UniTask<T2[]> GetResult<T1, T2>(this T1[] source) where T1 : T2
Parameters
| Type |
Name |
Description |
| T1[] |
source |
|
Returns
| Type |
Description |
| UniTask<T2[]> |
|
Type Parameters
|
Edit this page
View Source
GetTextSource<T>(UniTask<T>)
Extracts text from an ITextSource result.
Declaration
public static UniTask<string> GetTextSource<T>(this UniTask<T> t) where T : ITextSource
Parameters
| Type |
Name |
Description |
| UniTask<T> |
t |
|
Returns
| Type |
Description |
| UniTask<string> |
|
Type Parameters
|
Edit this page
View Source
IsDeleted<T>(UniTask<T>)
Checks if the resource was deleted successfully.
Declaration
public static UniTask<bool> IsDeleted<T>(this UniTask<T> t) where T : IDeletionStatus
Parameters
| Type |
Name |
Description |
| UniTask<T> |
t |
|
Returns
| Type |
Description |
| UniTask<bool> |
|
Type Parameters
|
Edit this page
View Source
IsNotNull<T>(UniTask<T>)
Checks if the awaited result is not null.
Declaration
public static UniTask<bool> IsNotNull<T>(this UniTask<T> t) where T : class
Parameters
| Type |
Name |
Description |
| UniTask<T> |
t |
|
Returns
| Type |
Description |
| UniTask<bool> |
|
Type Parameters
|
Edit this page
View Source
IsSuccess(UniTask<RESTResponse>)
Checks if the REST response indicates success.
Declaration
public static UniTask<bool> IsSuccess(this UniTask<RESTResponse> t)
Parameters
Returns
| Type |
Description |
| UniTask<bool> |
|
|
Edit this page
View Source
ToArray<T>(UniTask<Queried<T>>)
Extracts the data array from a Queried result.
Declaration
public static UniTask<T[]> ToArray<T>(this UniTask<Queried<T>> t)
Parameters
| Type |
Name |
Description |
| UniTask<Queried<T>> |
t |
|
Returns
| Type |
Description |
| UniTask<T[]> |
|
Type Parameters
|
Edit this page
View Source
ToParams(IRequestParameterProvider)
Converts provider parameters to an array.
Declaration
public static RequestParameter[] ToParams(this IRequestParameterProvider provider)
Parameters
Returns
|
Edit this page
View Source
ToParams(IRequestParameterProvider, params RequestParameter[])
Converts provider parameters to an array, optionally merging with additional parameters.
Declaration
public static RequestParameter[] ToParams(this IRequestParameterProvider provider, params RequestParameter[] @params)
Parameters
Returns
|
Edit this page
View Source
Upcast<TBase, TDerived>(UniTask<Queried<TDerived>>)
Awaits a Queried result and extracts the data as a base type array.
Declaration
public static UniTask<TBase[]> Upcast<TBase, TDerived>(this UniTask<Queried<TDerived>> t) where TDerived : class, TBase
Parameters
| Type |
Name |
Description |
| UniTask<Queried<TDerived>> |
t |
|
Returns
| Type |
Description |
| UniTask<TBase[]> |
|
Type Parameters
| Name |
Description |
| TBase |
|
| TDerived |
|
|
Edit this page
View Source
Upcast<TBase, TDerived>(UniTask<TDerived>)
Awaits and upcasts the result to a base type.
Declaration
public static UniTask<TBase> Upcast<TBase, TDerived>(this UniTask<TDerived> t) where TDerived : class, TBase
Parameters
| Type |
Name |
Description |
| UniTask<TDerived> |
t |
|
Returns
| Type |
Description |
| UniTask<TBase> |
|
Type Parameters
| Name |
Description |
| TBase |
|
| TDerived |
|
|
Edit this page
View Source
Upcast<TBase, TDerived>(UniTask<TDerived>, Func<TDerived, TBase[]>)
Awaits and converts the result to a base type array using a converter.
Declaration
public static UniTask<TBase[]> Upcast<TBase, TDerived>(this UniTask<TDerived> t, Func<TDerived, TBase[]> converter)
Parameters
| Type |
Name |
Description |
| UniTask<TDerived> |
t |
|
| Func<TDerived, TBase[]> |
converter |
|
Returns
| Type |
Description |
| UniTask<TBase[]> |
|
Type Parameters
| Name |
Description |
| TBase |
|
| TDerived |
|