Table of Contents

Class AsyncSpec<TModel>

Namespace
Motiv
Assembly
Motiv.dll

Represents an asynchronous proposition that defines a condition for a model of type TModel. This proposition is associated with a string metadata.

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

Type Parameters

TModel

The type of the model.

Inheritance
AsyncSpec<TModel>
Inherited Members
Extension Methods

Constructors

AsyncSpec(AsyncSpecBase<TModel, string>)

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

protected AsyncSpec(AsyncSpecBase<TModel, string> spec)

Parameters

spec AsyncSpecBase<TModel, string>

The base proposition associated with the AsyncSpec instance.

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

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

protected AsyncSpec(Func<AsyncSpecBase<TModel, string>> specFactory)

Parameters

specFactory Func<AsyncSpecBase<TModel, string>>

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<string>> 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<string>>

A BooleanResultBase containing the result of the proposition being applied to a model.

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.