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
-
ObjectExpressionCompiler
- 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
expressionStringthe expression to build the abstract syntax tree for
Returns
Evaluate<T>(String)
Evaluates the specified expression.
public static T Evaluate<T>(string expression)
Parameters
expressionStringThe expression.
Returns
- T
A value that the expression resulted in.
Type Parameters
TThe 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
expressionStringThe expression.
environmentEnvironment(Optional) current entity object.
currentEntityObjectThe environment.
Returns
- T
A value that the expression resulted in.
Type Parameters
TThe 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
sourceEntityObjectThe source entity object.
propertyNameStringThe expression to evaluate.
environmentEnvironmentThe environment to evaluate against.
fallbackValueTThe fallback value if something goes wrong.
Returns
- T
Returns the result of the evaluated expression, or the fallbackvalue if something goes wrong.
Type Parameters
TThe 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
eoEntityObjectThe source entity object.
propertyNameStringThe name of the property.
environmentEnvironmentThe 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
expressionStringThe TCQL expression.
currentModelEntityBaseThe ModelEntity representing the Current entity.
modelModelThe model.
parametersIEnumerable<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
expressionStringthe 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
expressionStringthe expression to build the abstract syntax tree for
elementModelElementa 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
expressionStringthe expression to build the abstract syntax tree for
elementModelElementa model element to validate against
modelModelAn 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
expressionStringthe expression to build the abstract syntax tree for
elementModelElementa model element to validate against
modelModelAn 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
messagesIList<PropertyValidationMessage>The validation messages collected by the method.
propertyNameStringName of the property that is validated.
expressionStringThe expression that is validated.
elementModelElementThe modelelement that contains the expression.
expectedDataTypeTypeThe expected datatype.
isEnvironmentalizedExpressionBooleanif set to
true[is environmentalized expression].
Returns
- T1
Type Parameters
T1The type of the 1.
T2The type of the 2.
ValidateExpression(String)
Parses an expression and validates it.
public static void ValidateExpression(string expression)
Parameters
expressionStringThe string expression to parse
Exceptions
- AbstractSyntaxException
Thrown if the expression is syntactically incorrect.