Table of Contents

Class TransformFileScopeExtensions

Namespace
Invex.FileSystem
Assembly
Invex.FileSystem.dll

Provides extension methods for fluently chaining additional transformations onto a System.Threading.Tasks.Task<TResult> that yields a scope returned by one of the static CreateAsync factory methods.

public static class TransformFileScopeExtensions
Inheritance
object
TransformFileScopeExtensions

Remarks

These extensions exist so that CreateAsync and one or more AddAsync calls can be written as a single expression without intermediate variables:

await using var scope = await TransformFileScope
    .CreateAsync(file, _ => "v1")
    .AddAsync(c => c + "-patched");

Without them, the caller would need to await CreateAsync into a local and then await AddAsync separately.

Methods

AddAsync(Task<TransformFileScope>, Func<string, string>)

Applies an additional asynchronous transformation to the file within the TransformFileScope returned by scopeTask.

public static Task<TransformFileScope> AddAsync(this Task<TransformFileScope> scopeTask, Func<string, string> transform)

Parameters

scopeTask Task<TransformFileScope>

A task that produces a TransformFileScope.

transform Func<string, string>

A function to apply to the file's current content.

Returns

Task<TransformFileScope>

A task that completes with the same TransformFileScope instance after the transformation has been applied.

Remarks

This overload does not accept a System.Threading.CancellationToken; the inner AddAsync(Func<string, string>, CancellationToken) call runs with System.Threading.CancellationToken.None. Call that method directly if cancellation support is required.

AddAsync(Task<TransformMultiFileScope>, Func<string, string>)

Applies an additional asynchronous transformation to each file within the TransformMultiFileScope returned by scopeTask.

public static Task<TransformMultiFileScope> AddAsync(this Task<TransformMultiFileScope> scopeTask, Func<string, string> transform)

Parameters

scopeTask Task<TransformMultiFileScope>

A task that produces a TransformMultiFileScope.

transform Func<string, string>

A function to apply to each file's current content.

Returns

Task<TransformMultiFileScope>

A task that completes with the same TransformMultiFileScope instance after the transformation has been applied.

Remarks

This overload does not accept a System.Threading.CancellationToken; the inner AddAsync(Func<string, string>, CancellationToken) call runs with System.Threading.CancellationToken.None. Call that method directly if cancellation support is required.