Table of Contents

Class AsyncSpec<TModel, TMetadata>

Namespace
Motiv
Assembly
Motiv.dll

Represents an asynchronous proposition that yields custom metadata based on the outcome of the underlying spec/predicate.

public class AsyncSpec<TModel, TMetadata> : AsyncSpecBase<TModel, TMetadata>

Type Parameters

TModel

The type of the model.

TMetadata

The type of the metadata.

Inheritance
AsyncSpecBase<TModel, TMetadata>
AsyncSpec<TModel, TMetadata>
Inherited Members
Extension Methods

Constructors

AsyncSpec(AsyncSpecBase<TModel, TMetadata>)

Initializes a new instance of the AsyncSpec class with an AsyncSpecBase instance.

protected AsyncSpec(AsyncSpecBase<TModel, TMetadata> spec)

Parameters

spec AsyncSpecBase<TModel, TMetadata>

The base proposition associated with the AsyncSpec instance.

AsyncSpec(Func<AsyncSpecBase<TModel, TMetadata>>)

Initializes a new instance of the AsyncSpec class with a specification factory.

protected AsyncSpec(Func<AsyncSpecBase<TModel, TMetadata>> specificationFactory)

Parameters

specificationFactory Func<AsyncSpecBase<TModel, TMetadata>>

The specification factory to create the AsyncSpec instance.

Properties

Description

Gets the description of the proposition.

public override ISpecDescription Description { get; }

Property Value

ISpecDescription

Underlying

Gets the underlying specifications that make up this composite proposition.

public override IEnumerable<SpecBase> Underlying { get; }

Property Value

IEnumerable<SpecBase>

Methods

EvaluateSpecAsync(TModel, CancellationToken)

Asynchronously determines whether the specified model satisfies the proposition.

protected override Task<BooleanResultBase<TMetadata>> EvaluateSpecAsync(TModel model, CancellationToken cancellationToken)

Parameters

model TModel

The model to be checked against the proposition.

cancellationToken CancellationToken

A token that can cancel the evaluation.

Returns

Task<BooleanResultBase<TMetadata>>

A BooleanResultBase containing the result of the proposition check and the associated metadata.

MatchesAsync(TModel, CancellationToken)

Asynchronously evaluates the proposition against the model and returns a boolean indicating whether it is satisfied, without allocating result objects where the underlying propositions permit.

public override Task<bool> MatchesAsync(TModel model, CancellationToken cancellationToken = default)

Parameters

model TModel

The model to evaluate the specification against.

cancellationToken CancellationToken

A token that can cancel the evaluation.

Returns

Task<bool>

true if the model satisfies the proposition; otherwise, false.