Class Spec<TModel>
- Namespace
- Motiv
- Assembly
- Motiv.dll
Represents a proposition that defines a condition for a model of type TModel. This proposition is associated with a string metadata.
public class Spec<TModel> : SpecBase<TModel, string>
Type Parameters
TModelThe type of the model.
- Inheritance
-
SpecBase<TModel>Spec<TModel>
- Inherited Members
- Extension Methods
Constructors
Spec(SpecBase<TModel, string>)
Initializes a new instance of the Spec class with a SpecBase instance.
protected Spec(SpecBase<TModel, string> spec)
Parameters
Spec(Func<SpecBase<TModel, string>>)
Initializes a new instance of the Spec class with a specification factory.
protected Spec(Func<SpecBase<TModel, string>> specFactory)
Parameters
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<string> EvaluateSpec(TModel model)
Parameters
modelTModelThe model to be checked against the proposition.
Returns
- BooleanResultBase<string>
A BooleanResultBase containing the result of the proposition being applied to a model 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.