Class ExpressionCompiler
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.
Inheritance
Inherited Members
Namespace: TimeCockpit.Data.DataModel
Assembly: TimeCockpit.Data.dll
Syntax
public static class ExpressionCompiler
Methods
BuildSyntaxTree(String)
Gets the abstract syntax tree for a specified expression
Declaration
public static IAstNode BuildSyntaxTree(string expression)
Parameters
Type | Name | Description |
---|---|---|
System.String | expression | the expression to build the abstract syntax tree for |
Returns
Type | Description |
---|---|
IAstNode | an instance of IAstNode |
Evaluate<T>(String)
Evaluates the specified expression.
Declaration
public static T Evaluate<T>(string expression)
Parameters
Type | Name | Description |
---|---|---|
System.String | expression | The expression. |
Returns
Type | Description |
---|---|
T | A value that the expression resulted in. |
Type Parameters
Name | Description |
---|---|
T | The return type of the method. |
Evaluate<T>(String, Environment, EntityObject)
Evaluates the specified expression.
Declaration
public static T Evaluate<T>(string expression, Environment environment, EntityObject current = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | expression | The expression. |
Environment | environment | (Optional) current entity object. |
EntityObject | current | The environment. |
Returns
Type | Description |
---|---|
T | A value that the expression resulted in. |
Type Parameters
Name | Description |
---|---|
T | The return type of the method. |
EvaluateExpressionMember<T>(EntityObject, String, Environment, T)
Evaluates the specified expression.
Declaration
public static T EvaluateExpressionMember<T>(EntityObject source, string propertyName, Environment environment, T fallbackValue)
Parameters
Type | Name | Description |
---|---|---|
EntityObject | source | The source entity object. |
System.String | propertyName | The expression to evaluate. |
Environment | environment | The environment to evaluate against. |
T | fallbackValue | The fallback value if something goes wrong. |
Returns
Type | Description |
---|---|
T | Returns the result of the evaluated expression, or the fallbackvalue if something goes wrong. |
Type Parameters
Name | Description |
---|---|
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.
Declaration
public static object EvaluateOptionalExpression(EntityObject eo, string propertyName, Environment environment)
Parameters
Type | Name | Description |
---|---|---|
EntityObject | eo | The source entity object. |
System.String | propertyName | The name of the property. |
Environment | environment | The environment to use for evaluating. |
Returns
Type | Description |
---|---|
System.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.
Declaration
public static Type EvaluateResultType(string expression, ModelEntityBase current, Model model, IEnumerable<QueryParameter> parameters = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | expression | The TCQL expression. |
ModelEntityBase | current | The ModelEntity representing the Current entity. |
Model | model | The model. |
System.Collections.Generic.IEnumerable<QueryParameter> | parameters | The query parameters. |
Returns
Type | Description |
---|---|
System.Type | Returns the clr type produced by such an expression. |
GetParticipatingMembers(String)
Gets the properties that are targeted by a Condition
Declaration
public static List<string> GetParticipatingMembers(string expression)
Parameters
Type | Name | Description |
---|---|---|
System.String | expression | the expression to build the abstract syntax tree for |
Returns
Type | Description |
---|---|
System.Collections.Generic.List<System.String> | an IEnumerable of property names |
GetParticipatingMembers(String, ModelElement)
Gets the properties that are targeted by a Condition
Declaration
public static List<string> GetParticipatingMembers(string expression, ModelElement element)
Parameters
Type | Name | Description |
---|---|---|
System.String | expression | the expression to build the abstract syntax tree for |
ModelElement | element | a model element to validate against |
Returns
Type | Description |
---|---|
System.Collections.Generic.List<System.String> | an IEnumerable of property names |
GetParticipatingProperties(String, ModelElement, Model)
Gets the properties that are targeted by a Condition
Declaration
public static IEnumerable<IAstMemberAccessNode> GetParticipatingProperties(string expression, ModelElement element, Model model = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | expression | the expression to build the abstract syntax tree for |
ModelElement | element | 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
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IAstMemberAccessNode> | an IEnumerable of property names |
GetParticipatingRelations(String, ModelElement, Model)
Gets the relations that are targeted by a Condition
Declaration
public static List<string> GetParticipatingRelations(string expression, ModelElement element, Model model = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | expression | the expression to build the abstract syntax tree for |
ModelElement | element | 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
Type | Description |
---|---|
System.Collections.Generic.List<System.String> | an IEnumerable of relation names |
Validate<T1, T2>(ref IList<PropertyValidationMessage>, String, String, ModelElement, Type, Boolean)
Validates the specified messages.
Declaration
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
Type | Name | Description |
---|---|---|
System.Collections.Generic.IList<PropertyValidationMessage> | messages | The validation messages collected by the method. |
System.String | propertyName | Name of the property that is validated. |
System.String | expression | The expression that is validated. |
ModelElement | element | The modelelement that contains the expression. |
System.Type | expectedDataType | The expected datatype. |
System.Boolean | isEnvironmentalizedExpression | if set to |
Returns
Type | Description |
---|---|
T1 |
Type Parameters
Name | Description |
---|---|
T1 | The type of the 1. |
T2 | The type of the 2. |
ValidateExpression(String)
Parses an expression and validates it.
Declaration
public static void ValidateExpression(string expression)
Parameters
Type | Name | Description |
---|---|---|
System.String | expression | The string expression to parse |
Exceptions
Type | Condition |
---|---|
AbstractSyntaxException | Thrown if the expression is syntactically incorrect. |