Class Policy<TModel, TMetadata>
- Namespace
- Motiv
- Assembly
- Motiv.dll
Represents a proposition that yields custom metadata based on the outcome of the underlying policy/predicate.
public class Policy<TModel, TMetadata> : PolicyBase<TModel, TMetadata>
Type Parameters
TModelThe model type that will be evaluated
TMetadataThe metadata type
- Inheritance
-
SpecBase<TModel>SpecBase<TModel, TMetadata>PolicyBase<TModel, TMetadata>Policy<TModel, TMetadata>
- Derived
- Inherited Members
- Extension Methods
Constructors
Policy(PolicyBase<TModel, TMetadata>)
public Policy(PolicyBase<TModel, TMetadata> policy)
Parameters
policyPolicyBase<TModel, TMetadata>
Policy(Func<PolicyBase<TModel, TMetadata>>)
public Policy(Func<PolicyBase<TModel, TMetadata>> policyFactory)
Parameters
policyFactoryFunc<PolicyBase<TModel, TMetadata>>
Properties
Description
Gets a description of the specification. This is used for debugging/logging purposes.
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
Remarks
This will yield an empty collection if the specification is dynamically generated at evaluation-time.
Methods
EvaluatePolicy(TModel)
Executes the proposition as a policy and returns a PolicyResultBase<TMetadata> primarily containing a single metadata instance.
protected override PolicyResultBase<TMetadata> EvaluatePolicy(TModel model)
Parameters
modelTModelThe model to evaluate
Returns
- PolicyResultBase<TMetadata>
A PolicyResultBase<TMetadata> containing the metadata instance and the boolean result.
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.