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
TModelThe type of the model.
TMetadataThe type of the metadata.
- Inheritance
-
AsyncSpecBase<TModel>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
specAsyncSpecBase<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
specificationFactoryFunc<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
Methods
EvaluateSpecAsync(TModel, CancellationToken)
Asynchronously determines whether the specified model satisfies the proposition.
protected override Task<BooleanResultBase<TMetadata>> EvaluateSpecAsync(TModel model, CancellationToken cancellationToken)
Parameters
modelTModelThe model to be checked against the proposition.
cancellationTokenCancellationTokenA 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
modelTModelThe model to evaluate the specification against.
cancellationTokenCancellationTokenA token that can cancel the evaluation.