Table of Contents

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

TModel

The type of the model.

Inheritance
SpecBase<TModel>
SpecBase<TModel, string>
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 SpecBase<TModel, string>

The base proposition associated with the Spec instance.

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

specFactory Func<SpecBase<TModel, string>>

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

IEnumerable<SpecBase>

Methods

EvaluateSpec(TModel)

Determines whether the specified model satisfies the proposition.

protected override BooleanResultBase<string> EvaluateSpec(TModel model)

Parameters

model TModel

The 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

model TModel

The model to evaluate the specification against.

Returns

bool

true if the model satisfies the proposition; otherwise, false.