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