Class OneOfExtensions
Extension methods for working with OneOf types.
Inherited Members
Namespace: DevToys.Api
Assembly: DevToys.Api.dll
Syntax
public static class OneOfExtensions
Methods
GetStreamAsync(OneOf<FileInfo, string>, IFileStorage, CancellationToken)
Gets a stream asynchronously based on the input OneOf type.
Declaration
public static Task<ResultInfo<Stream>> GetStreamAsync(this OneOf<FileInfo, string> input, IFileStorage fileStorage, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| OneOf<FileInfo, string> | input | The input OneOf type. |
| IFileStorage | fileStorage | The file storage implementation. |
| CancellationToken | cancellationToken | The cancellation token. |
Returns
| Type | Description |
|---|---|
| Task<ResultInfo<Stream>> | A task that represents the asynchronous operation. The task result contains the stream and a flag indicating if the stream was successfully retrieved. |
GetStreamAsync(OneOf<string, FileInfo>, IFileStorage, CancellationToken)
Gets a stream asynchronously based on the input OneOf type.
Declaration
public static Task<ResultInfo<Stream>> GetStreamAsync(this OneOf<string, FileInfo> input, IFileStorage fileStorage, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| OneOf<string, FileInfo> | input | The input OneOf type. |
| IFileStorage | fileStorage | The file storage implementation. |
| CancellationToken | cancellationToken | The cancellation token. |
Returns
| Type | Description |
|---|---|
| Task<ResultInfo<Stream>> | A task that represents the asynchronous operation. The task result contains the stream and a flag indicating if the stream was successfully retrieved. |
ReadAllTextAsync(OneOf<FileInfo, string>, IFileStorage, CancellationToken)
Reads all text asynchronously based on the input OneOf type.
Declaration
public static Task<ResultInfo<string>> ReadAllTextAsync(this OneOf<FileInfo, string> input, IFileStorage fileStorage, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| OneOf<FileInfo, string> | input | The input OneOf type. |
| IFileStorage | fileStorage | The file storage implementation. |
| CancellationToken | cancellationToken | The cancellation token. |
Returns
| Type | Description |
|---|---|
| Task<ResultInfo<string>> | A task that represents the asynchronous operation. The task result contains the text content and a flag indicating if the content was successfully read. |
ReadAllTextAsync(OneOf<string, FileInfo>, IFileStorage, CancellationToken)
Reads all text asynchronously based on the input OneOf type.
Declaration
public static Task<ResultInfo<string>> ReadAllTextAsync(this OneOf<string, FileInfo> input, IFileStorage fileStorage, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| OneOf<string, FileInfo> | input | The input OneOf type. |
| IFileStorage | fileStorage | The file storage implementation. |
| CancellationToken | cancellationToken | The cancellation token. |
Returns
| Type | Description |
|---|---|
| Task<ResultInfo<string>> | A task that represents the asynchronous operation. The task result contains the text content and a flag indicating if the content was successfully read. |