Table of Contents

Class ExpressionPolicyBase<TModel, TMetadata>

Namespace
Motiv
Assembly
Motiv.dll

The base class for policies that retain a recoverable predicate expression tree. A policy resolves to a single assertion or metadata value per evaluation, and this variant additionally allows the composed predicate expression to be recovered via ToExpression() for use with query providers.

public abstract class ExpressionPolicyBase<TModel, TMetadata> : PolicyBase<TModel, TMetadata>, IExpressionSpec<TModel>

Type Parameters

TModel

The model type that the policy evaluates against.

TMetadata

The type of the metadata associated with the policy.

Inheritance
SpecBase<TModel>
SpecBase<TModel, TMetadata>
PolicyBase<TModel, TMetadata>
ExpressionPolicyBase<TModel, TMetadata>
Implements
Inherited Members
Extension Methods

Methods

And(ExpressionPolicyBase<TModel, TMetadata>)

Combines this proposition with another expression-backed proposition using the logical AND operator. Both operands will be evaluated, regardless of whether the left operand evaluated to false.

public ExpressionSpecBase<TModel, TMetadata> And(ExpressionPolicyBase<TModel, TMetadata> spec)

Parameters

spec ExpressionPolicyBase<TModel, TMetadata>

The expression-backed proposition to combine with this proposition.

Returns

ExpressionSpecBase<TModel, TMetadata>

An expression-backed proposition representing the logical AND of the two propositions.

And(ExpressionSpecBase<TModel, TMetadata>)

Combines this proposition with another expression-backed proposition using the logical AND operator. Both operands will be evaluated, regardless of whether the left operand evaluated to false.

public ExpressionSpecBase<TModel, TMetadata> And(ExpressionSpecBase<TModel, TMetadata> spec)

Parameters

spec ExpressionSpecBase<TModel, TMetadata>

The expression-backed proposition to combine with this proposition.

Returns

ExpressionSpecBase<TModel, TMetadata>

An expression-backed proposition representing the logical AND of the two propositions.

And(SpecBase<TModel, TMetadata>)

Combines this proposition with a same-metadata proposition that is not itself expression-backed, using the logical AND operator. Because the other operand's predicate cannot be recovered as an expression, the result degrades to an ordinary (non expression-backed) proposition. Redeclared here (rather than relying on the inherited base implementation) so this overload remains a candidate of equal declaring-type precedence to And<TSpec>(TSpec), preserving overload resolution parity.

public SpecBase<TModel, TMetadata> And(SpecBase<TModel, TMetadata> spec)

Parameters

spec SpecBase<TModel, TMetadata>

The proposition to combine with this proposition.

Returns

SpecBase<TModel, TMetadata>

An ordinary proposition representing the logical AND of the two propositions.

And(SpecBase<TModel>)

Combines this proposition with an ordinary proposition of a different metadata type, using the logical AND operator. Because neither operand's predicate can be recovered as an expression (the other operand isn't expression-backed), the result degrades to an ordinary explanation proposition. Redeclared here (rather than relying on the inherited base implementation) so this overload remains a candidate of equal declaring-type precedence to And<TSpec>(TSpec), preserving overload resolution parity.

public SpecBase<TModel, string> And(SpecBase<TModel> spec)

Parameters

spec SpecBase<TModel>

The proposition to combine with this proposition.

Returns

SpecBase<TModel, string>

An ordinary explanation proposition representing the logical AND of the two propositions.

AndAlso(ExpressionPolicyBase<TModel, TMetadata>)

Combines this proposition with another expression-backed proposition using the conditional AND operator. The right operand is only evaluated if the left operand resolves to true, since a false left operand means the AND operation cannot return true. This is commonly referred to as "short-circuiting".

public ExpressionSpecBase<TModel, TMetadata> AndAlso(ExpressionPolicyBase<TModel, TMetadata> spec)

Parameters

spec ExpressionPolicyBase<TModel, TMetadata>

The expression-backed proposition to combine with this proposition.

Returns

ExpressionSpecBase<TModel, TMetadata>

An expression-backed proposition representing the conditional AND of the two propositions.

AndAlso(ExpressionSpecBase<TModel, TMetadata>)

Combines this proposition with another expression-backed proposition using the conditional AND operator. The right operand is only evaluated if the left operand resolves to true, since a false left operand means the AND operation cannot return true. This is commonly referred to as "short-circuiting".

public ExpressionSpecBase<TModel, TMetadata> AndAlso(ExpressionSpecBase<TModel, TMetadata> spec)

Parameters

spec ExpressionSpecBase<TModel, TMetadata>

The expression-backed proposition to combine with this proposition.

Returns

ExpressionSpecBase<TModel, TMetadata>

An expression-backed proposition representing the conditional AND of the two propositions.

AndAlso(SpecBase<TModel, TMetadata>)

Combines this proposition with a same-metadata proposition that is not itself expression-backed, using the conditional AND operator. Because the other operand's predicate cannot be recovered as an expression, the result degrades to an ordinary (non expression-backed) proposition. Redeclared here (rather than relying on the inherited base implementation) so this overload remains a candidate of equal declaring-type precedence to AndAlso<TSpec>(TSpec), preserving overload resolution parity.

public SpecBase<TModel, TMetadata> AndAlso(SpecBase<TModel, TMetadata> spec)

Parameters

spec SpecBase<TModel, TMetadata>

The proposition to combine with this proposition.

Returns

SpecBase<TModel, TMetadata>

An ordinary proposition representing the conditional AND of the two propositions.

AndAlso(SpecBase<TModel>)

Combines this proposition with an ordinary proposition of a different metadata type, using the conditional AND operator. Because neither operand's predicate can be recovered as an expression (the other operand isn't expression-backed), the result degrades to an ordinary explanation proposition. Redeclared here (rather than relying on the inherited base implementation) so this overload remains a candidate of equal declaring-type precedence to AndAlso<TSpec>(TSpec), preserving overload resolution parity.

public SpecBase<TModel, string> AndAlso(SpecBase<TModel> spec)

Parameters

spec SpecBase<TModel>

The proposition to combine with this proposition.

Returns

SpecBase<TModel, string>

An ordinary explanation proposition representing the conditional AND of the two propositions.

AndAlso<TSpec>(TSpec)

Combines this proposition with an expression-backed proposition that has a different metadata type, using the conditional AND operator. The right operand is only evaluated if the left operand resolves to true. The operands are coerced to string metadata, and the result remains expression-backed.

public ExpressionSpecBase<TModel, string> AndAlso<TSpec>(TSpec spec) where TSpec : SpecBase<TModel>, IExpressionSpec<TModel>

Parameters

spec TSpec

The expression-backed proposition to combine with this proposition.

Returns

ExpressionSpecBase<TModel, string>

An expression-backed explanation proposition representing the conditional AND.

Type Parameters

TSpec

The type of the other proposition.

And<TSpec>(TSpec)

Combines this proposition with an expression-backed proposition that has a different metadata type, using the logical AND operator. The operands are coerced to string metadata, and the result remains expression-backed.

public ExpressionSpecBase<TModel, string> And<TSpec>(TSpec spec) where TSpec : SpecBase<TModel>, IExpressionSpec<TModel>

Parameters

spec TSpec

The expression-backed proposition to combine with this proposition.

Returns

ExpressionSpecBase<TModel, string>

An expression-backed explanation proposition representing the logical AND.

Type Parameters

TSpec

The type of the other proposition.

Not()

Negates this policy. The result remains both a policy and expression-backed.

public ExpressionPolicyBase<TModel, TMetadata> Not()

Returns

ExpressionPolicyBase<TModel, TMetadata>

An expression-backed policy representing the logical NOT of this policy.

Or(ExpressionPolicyBase<TModel, TMetadata>)

Combines this proposition with another expression-backed proposition using the logical OR operator. Both operands will be evaluated, regardless of whether the left operand evaluated to true.

public ExpressionSpecBase<TModel, TMetadata> Or(ExpressionPolicyBase<TModel, TMetadata> spec)

Parameters

spec ExpressionPolicyBase<TModel, TMetadata>

The expression-backed proposition to combine with this proposition.

Returns

ExpressionSpecBase<TModel, TMetadata>

An expression-backed proposition representing the logical OR of the two propositions.

Or(ExpressionSpecBase<TModel, TMetadata>)

Combines this proposition with another expression-backed proposition using the logical OR operator. Both operands will be evaluated, regardless of whether the left operand evaluated to true.

public ExpressionSpecBase<TModel, TMetadata> Or(ExpressionSpecBase<TModel, TMetadata> spec)

Parameters

spec ExpressionSpecBase<TModel, TMetadata>

The expression-backed proposition to combine with this proposition.

Returns

ExpressionSpecBase<TModel, TMetadata>

An expression-backed proposition representing the logical OR of the two propositions.

Or(SpecBase<TModel, TMetadata>)

Combines this proposition with a same-metadata proposition that is not itself expression-backed, using the logical OR operator. Because the other operand's predicate cannot be recovered as an expression, the result degrades to an ordinary (non expression-backed) proposition. Redeclared here (rather than relying on the inherited base implementation) so this overload remains a candidate of equal declaring-type precedence to Or<TSpec>(TSpec), preserving overload resolution parity.

public SpecBase<TModel, TMetadata> Or(SpecBase<TModel, TMetadata> spec)

Parameters

spec SpecBase<TModel, TMetadata>

The proposition to combine with this proposition.

Returns

SpecBase<TModel, TMetadata>

An ordinary proposition representing the logical OR of the two propositions.

Or(SpecBase<TModel>)

Combines this proposition with an ordinary proposition of a different metadata type, using the logical OR operator. Because neither operand's predicate can be recovered as an expression (the other operand isn't expression-backed), the result degrades to an ordinary explanation proposition. Redeclared here (rather than relying on the inherited base implementation) so this overload remains a candidate of equal declaring-type precedence to Or<TSpec>(TSpec), preserving overload resolution parity.

public SpecBase<TModel, string> Or(SpecBase<TModel> spec)

Parameters

spec SpecBase<TModel>

The proposition to combine with this proposition.

Returns

SpecBase<TModel, string>

An ordinary explanation proposition representing the logical OR of the two propositions.

OrElse(ExpressionPolicyBase<TModel, TMetadata>)

Creates a policy equivalent to a conditional "OR" of this policy and the alternative policy. The result remains both a policy and expression-backed.

public ExpressionPolicyBase<TModel, TMetadata> OrElse(ExpressionPolicyBase<TModel, TMetadata> alternative)

Parameters

alternative ExpressionPolicyBase<TModel, TMetadata>

The policy to evaluate when this policy is unsatisfied.

Returns

ExpressionPolicyBase<TModel, TMetadata>

An expression-backed policy representing the conditional OR of the two policies.

OrElse(ExpressionSpecBase<TModel, TMetadata>)

Combines this proposition with another expression-backed proposition using the conditional OR operator. The right operand is only evaluated if the left operand resolves to false, since a true left operand means the OR operation is already satisfied. This is commonly referred to as "short-circuiting".

public ExpressionSpecBase<TModel, TMetadata> OrElse(ExpressionSpecBase<TModel, TMetadata> spec)

Parameters

spec ExpressionSpecBase<TModel, TMetadata>

The expression-backed proposition to combine with this proposition.

Returns

ExpressionSpecBase<TModel, TMetadata>

An expression-backed proposition representing the conditional OR of the two propositions.

OrElse(PolicyBase<TModel, TMetadata>)

Combines this policy with an ordinary PolicyBase<TModel, TMetadata> alternative using the Policy-Else combinator (see OrElse(PolicyBase<TModel, TMetadata>)). Redeclared here (rather than relying on the inherited base implementation) so this overload remains a candidate of equal declaring-type precedence to OrElse<TSpec>(TSpec) and the same-metadata SpecBase<TModel, TMetadata> overload below, preserving overload resolution parity and the distinct Policy-Else return type.

public PolicyBase<TModel, TMetadata> OrElse(PolicyBase<TModel, TMetadata> alternative)

Parameters

alternative PolicyBase<TModel, TMetadata>

The policy to evaluate when this policy is unsatisfied.

Returns

PolicyBase<TModel, TMetadata>

A PolicyBase<TModel, TMetadata> representing the conditional OR of the two policies.

OrElse(SpecBase<TModel, TMetadata>)

Combines this proposition with a same-metadata proposition that is not itself expression-backed, using the conditional OR operator. Because the other operand's predicate cannot be recovered as an expression, the result degrades to an ordinary (non expression-backed) proposition. Redeclared here (rather than relying on the inherited base implementation) so this overload remains a candidate of equal declaring-type precedence to OrElse<TSpec>(TSpec), preserving overload resolution parity.

public SpecBase<TModel, TMetadata> OrElse(SpecBase<TModel, TMetadata> spec)

Parameters

spec SpecBase<TModel, TMetadata>

The proposition to combine with this proposition.

Returns

SpecBase<TModel, TMetadata>

An ordinary proposition representing the conditional OR of the two propositions.

OrElse(SpecBase<TModel>)

Combines this proposition with an ordinary proposition of a different metadata type, using the conditional OR operator. Because neither operand's predicate can be recovered as an expression (the other operand isn't expression-backed), the result degrades to an ordinary explanation proposition. Redeclared here (rather than relying on the inherited base implementation) so this overload remains a candidate of equal declaring-type precedence to OrElse<TSpec>(TSpec), preserving overload resolution parity.

public SpecBase<TModel, string> OrElse(SpecBase<TModel> spec)

Parameters

spec SpecBase<TModel>

The proposition to combine with this proposition.

Returns

SpecBase<TModel, string>

An ordinary explanation proposition representing the conditional OR of the two propositions.

OrElse<TSpec>(TSpec)

Combines this proposition with an expression-backed proposition that has a different metadata type, using the conditional OR operator. The right operand is only evaluated if the left operand resolves to false. The operands are coerced to string metadata, and the result remains expression-backed.

public ExpressionSpecBase<TModel, string> OrElse<TSpec>(TSpec spec) where TSpec : SpecBase<TModel>, IExpressionSpec<TModel>

Parameters

spec TSpec

The expression-backed proposition to combine with this proposition.

Returns

ExpressionSpecBase<TModel, string>

An expression-backed explanation proposition representing the conditional OR.

Type Parameters

TSpec

The type of the other proposition.

Or<TSpec>(TSpec)

Combines this proposition with an expression-backed proposition that has a different metadata type, using the logical OR operator. The operands are coerced to string metadata, and the result remains expression-backed.

public ExpressionSpecBase<TModel, string> Or<TSpec>(TSpec spec) where TSpec : SpecBase<TModel>, IExpressionSpec<TModel>

Parameters

spec TSpec

The expression-backed proposition to combine with this proposition.

Returns

ExpressionSpecBase<TModel, string>

An expression-backed explanation proposition representing the logical OR.

Type Parameters

TSpec

The type of the other proposition.

ToExplanationSpec()

Converts this policy to an explanation proposition (string metadata) while preserving the underlying predicate expression tree.

public override SpecBase<TModel, string> ToExplanationSpec()

Returns

SpecBase<TModel, string>

An expression-backed explanation proposition.

ToExpression()

Gets the predicate expression tree that this policy represents.

public abstract Expression<Func<TModel, bool>> ToExpression()

Returns

Expression<Func<TModel, bool>>

The predicate lambda expression describing this policy.

XOr(ExpressionPolicyBase<TModel, TMetadata>)

Combines this proposition with another expression-backed proposition using the logical XOR operator. Both operands are always evaluated.

public ExpressionSpecBase<TModel, TMetadata> XOr(ExpressionPolicyBase<TModel, TMetadata> spec)

Parameters

spec ExpressionPolicyBase<TModel, TMetadata>

The expression-backed proposition to combine with this proposition.

Returns

ExpressionSpecBase<TModel, TMetadata>

An expression-backed proposition representing the logical XOR of the two propositions.

XOr(ExpressionSpecBase<TModel, TMetadata>)

Combines this proposition with another expression-backed proposition using the logical XOR operator. Both operands are always evaluated.

public ExpressionSpecBase<TModel, TMetadata> XOr(ExpressionSpecBase<TModel, TMetadata> spec)

Parameters

spec ExpressionSpecBase<TModel, TMetadata>

The expression-backed proposition to combine with this proposition.

Returns

ExpressionSpecBase<TModel, TMetadata>

An expression-backed proposition representing the logical XOR of the two propositions.

XOr(SpecBase<TModel, TMetadata>)

Combines this proposition with a same-metadata proposition that is not itself expression-backed, using the logical XOR operator. Because the other operand's predicate cannot be recovered as an expression, the result degrades to an ordinary (non expression-backed) proposition. Redeclared here (rather than relying on the inherited base implementation) so this overload remains a candidate of equal declaring-type precedence to XOr<TSpec>(TSpec), preserving overload resolution parity.

public SpecBase<TModel, TMetadata> XOr(SpecBase<TModel, TMetadata> spec)

Parameters

spec SpecBase<TModel, TMetadata>

The proposition to combine with this proposition.

Returns

SpecBase<TModel, TMetadata>

An ordinary proposition representing the logical XOR of the two propositions.

XOr(SpecBase<TModel>)

Combines this proposition with an ordinary proposition of a different metadata type, using the logical XOR operator. Because neither operand's predicate can be recovered as an expression (the other operand isn't expression-backed), the result degrades to an ordinary explanation proposition. Redeclared here (rather than relying on the inherited base implementation) so this overload remains a candidate of equal declaring-type precedence to XOr<TSpec>(TSpec), preserving overload resolution parity.

public SpecBase<TModel, string> XOr(SpecBase<TModel> spec)

Parameters

spec SpecBase<TModel>

The proposition to combine with this proposition.

Returns

SpecBase<TModel, string>

An ordinary explanation proposition representing the logical XOR of the two propositions.

XOr<TSpec>(TSpec)

Combines this proposition with an expression-backed proposition that has a different metadata type, using the logical XOR operator. Both operands are always evaluated. The operands are coerced to string metadata, and the result remains expression-backed.

public ExpressionSpecBase<TModel, string> XOr<TSpec>(TSpec spec) where TSpec : SpecBase<TModel>, IExpressionSpec<TModel>

Parameters

spec TSpec

The expression-backed proposition to combine with this proposition.

Returns

ExpressionSpecBase<TModel, string>

An expression-backed explanation proposition representing the logical XOR.

Type Parameters

TSpec

The type of the other proposition.

Operators

operator &(ExpressionPolicyBase<TModel, TMetadata>, ExpressionPolicyBase<TModel, TMetadata>)

Combines two expression-backed propositions using the logical AND operator.

public static ExpressionSpecBase<TModel, TMetadata> operator &(ExpressionPolicyBase<TModel, TMetadata> left, ExpressionPolicyBase<TModel, TMetadata> right)

Parameters

left ExpressionPolicyBase<TModel, TMetadata>

The left operand of the AND operation.

right ExpressionPolicyBase<TModel, TMetadata>

The right operand of the AND operation.

Returns

ExpressionSpecBase<TModel, TMetadata>

An expression-backed proposition representing the logical AND of the two propositions.

operator |(ExpressionPolicyBase<TModel, TMetadata>, ExpressionPolicyBase<TModel, TMetadata>)

Combines two expression-backed propositions using the logical OR operator.

public static ExpressionSpecBase<TModel, TMetadata> operator |(ExpressionPolicyBase<TModel, TMetadata> left, ExpressionPolicyBase<TModel, TMetadata> right)

Parameters

left ExpressionPolicyBase<TModel, TMetadata>

The left operand of the OR operation.

right ExpressionPolicyBase<TModel, TMetadata>

The right operand of the OR operation.

Returns

ExpressionSpecBase<TModel, TMetadata>

An expression-backed proposition representing the logical OR of the two propositions.

operator ^(ExpressionPolicyBase<TModel, TMetadata>, ExpressionPolicyBase<TModel, TMetadata>)

Combines two expression-backed propositions using the logical XOR operator.

public static ExpressionSpecBase<TModel, TMetadata> operator ^(ExpressionPolicyBase<TModel, TMetadata> left, ExpressionPolicyBase<TModel, TMetadata> right)

Parameters

left ExpressionPolicyBase<TModel, TMetadata>

The left operand of the XOR operation.

right ExpressionPolicyBase<TModel, TMetadata>

The right operand of the XOR operation.

Returns

ExpressionSpecBase<TModel, TMetadata>

An expression-backed proposition representing the logical XOR of the two propositions.

operator !(ExpressionPolicyBase<TModel, TMetadata>)

Negates an expression-backed policy.

public static ExpressionPolicyBase<TModel, TMetadata> operator !(ExpressionPolicyBase<TModel, TMetadata> policy)

Parameters

policy ExpressionPolicyBase<TModel, TMetadata>

The policy to negate.

Returns

ExpressionPolicyBase<TModel, TMetadata>

An expression-backed policy representing the logical NOT of the policy.