Class Spec<TModel, TMetadata>
- Namespace
- Motiv
- Assembly
- Motiv.dll
Represents a proposition that yields custom metadata based on the outcome of the underlying spec/predicate.
public class Spec<TModel, TMetadata> : SpecBase<TModel, TMetadata>
Type Parameters
TModelThe type of the model.
TMetadataThe type of the metadata.
- Inherited Members
- Extension Methods
Constructors
Spec(SpecBase<TModel, TMetadata>)
Initializes a new instance of the Spec class with a SpecBase instance.
protected Spec(SpecBase<TModel, TMetadata> spec)
Parameters
specSpecBase<TModel, TMetadata>The base proposition associated with the Spec instance.
Spec(Func<SpecBase<TModel, TMetadata>>)
Initializes a new instance of the Spec class with a specification factory.
protected Spec(Func<SpecBase<TModel, TMetadata>> specificationFactory)
Parameters
specificationFactoryFunc<SpecBase<TModel, TMetadata>>The specification factory to create the Spec 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
EvaluateSpec(TModel)
Determines whether the specified model satisfies the proposition.
protected override BooleanResultBase<TMetadata> EvaluateSpec(TModel model)
Parameters
modelTModelThe model to be checked against the proposition.
Returns
- BooleanResultBase<TMetadata>
A BooleanResultBase containing the result of the proposition check and the associated metadata.
Matches(TModel)
Evaluates the proposition against the model and returns a boolean indicating whether it is satisfied, without allocating result objects.
public override bool Matches(TModel model)
Parameters
modelTModelThe model to evaluate the specification against.
Returns
- bool
trueif the model satisfies the proposition; otherwise,false.