Table of Contents

Class ExpressionCompiler

Namespace
TimeCockpit.Data.DataModel
Assembly
TimeCockpit.Data.dll

Represents a class that is able to compile TCQL expressions into either abstract syntax tree or expression trees. Further this class provides methods to translate TCQL expressions into executable code.

public static class ExpressionCompiler
Inheritance
Object
ExpressionCompiler
Inherited Members
Object.ToString()
Object.Equals(Object)
Object.Equals(Object, Object)
Object.ReferenceEquals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()

Methods

BuildSyntaxTree(String)

Gets the abstract syntax tree for a specified expression

public static IAstNode BuildSyntaxTree(string expression)

Parameters

expression String

the expression to build the abstract syntax tree for

Returns

IAstNode

an instance of IAstNode

Evaluate<T>(String)

Evaluates the specified expression.

public static T Evaluate<T>(string expression)

Parameters

expression String

The expression.

Returns

T

A value that the expression resulted in.

Type Parameters

T

The return type of the method.

Evaluate<T>(String, Environment, EntityObject)

Evaluates the specified expression.

public static T Evaluate<T>(string expression, Environment environment, EntityObject current = null)

Parameters

expression String

The expression.

environment Environment

(Optional) current entity object.

current EntityObject

The environment.

Returns

T

A value that the expression resulted in.

Type Parameters

T

The return type of the method.

EvaluateExpressionMember<T>(EntityObject, String, Environment, T)

Evaluates the specified expression.

public static T EvaluateExpressionMember<T>(EntityObject source, string propertyName, Environment environment, T fallbackValue)

Parameters

source EntityObject

The source entity object.

propertyName String

The expression to evaluate.

environment Environment

The environment to evaluate against.

fallbackValue T

The fallback value if something goes wrong.

Returns

T

Returns the result of the evaluated expression, or the fallbackvalue if something goes wrong.

Type Parameters

T

The type of the result.

EvaluateOptionalExpression(EntityObject, String, Environment)

returns a field, evaluating the value of the field if it starts with a = and represents an expression.

public static object EvaluateOptionalExpression(EntityObject eo, string propertyName, Environment environment)

Parameters

eo EntityObject

The source entity object.

propertyName String

The name of the property.

environment Environment

The environment to use for evaluating.

Returns

Object

Returns the result of the expression if it is an expression, the value of the property otherwise.

EvaluateResultType(String, ModelEntityBase, Model, IEnumerable<QueryParameter>)

Gets the resulting CLR type of an expression.

public static Type EvaluateResultType(string expression, ModelEntityBase current, Model model, IEnumerable<QueryParameter> parameters = null)

Parameters

expression String

The TCQL expression.

current ModelEntityBase

The ModelEntity representing the Current entity.

model Model

The model.

parameters IEnumerable<QueryParameter>

The query parameters.

Returns

Type

Returns the clr type produced by such an expression.

GetParticipatingMembers(String)

Gets the properties that are targeted by a Condition

public static List<string> GetParticipatingMembers(string expression)

Parameters

expression String

the expression to build the abstract syntax tree for

Returns

List<String>

an IEnumerable of property names

GetParticipatingMembers(String, ModelElement)

Gets the properties that are targeted by a Condition

public static List<string> GetParticipatingMembers(string expression, ModelElement element)

Parameters

expression String

the expression to build the abstract syntax tree for

element ModelElement

a model element to validate against

Returns

List<String>

an IEnumerable of property names

GetParticipatingProperties(String, ModelElement, Model)

Gets the properties that are targeted by a Condition

public static IEnumerable<IAstMemberAccessNode> GetParticipatingProperties(string expression, ModelElement element, Model model = null)

Parameters

expression String

the expression to build the abstract syntax tree for

element ModelElement

a model element to validate against

model Model

An optional instance of Model. This model can be used if modelElement is not attached to a model.

Returns

IEnumerable<IAstMemberAccessNode>

an IEnumerable of property names

GetParticipatingRelations(String, ModelElement, Model)

Gets the relations that are targeted by a Condition

public static List<string> GetParticipatingRelations(string expression, ModelElement element, Model model = null)

Parameters

expression String

the expression to build the abstract syntax tree for

element ModelElement

a model element to validate against

model Model

An optional instance of Model. This model can be used if modelElement is not attached to a model.

Returns

List<String>

an IEnumerable of relation names

Validate<T1, T2>(ref IList<PropertyValidationMessage>, String, String, ModelElement, Type, Boolean)

Validates the specified messages.

public static T1 Validate<T1, T2>(ref IList<PropertyValidationMessage> messages, string propertyName, string expression, ModelElement element, Type expectedDataType, bool isEnvironmentalizedExpression)
    where T1 : CompiledExpressionBase<T2>

Parameters

messages IList<PropertyValidationMessage>

The validation messages collected by the method.

propertyName String

Name of the property that is validated.

expression String

The expression that is validated.

element ModelElement

The modelelement that contains the expression.

expectedDataType Type

The expected datatype.

isEnvironmentalizedExpression Boolean

if set to true [is environmentalized expression].

Returns

T1

An CompiledExpressionBase<T>.

Type Parameters

T1

The type of the 1.

T2

The type of the 2.

ValidateExpression(String)

Parses an expression and validates it.

public static void ValidateExpression(string expression)

Parameters

expression String

The string expression to parse

Exceptions

AbstractSyntaxException

Thrown if the expression is syntactically incorrect.