public GetExpressionValue ( DataDictionary.Interpreter.InterpretationContext context, |
||
context | DataDictionary.Interpreter.InterpretationContext | The context on which the value must be found |
explain | ||
return | IValue |
/// <summary> /// Edits a value expression and provides the edited expression after user has performed his changes /// </summary> /// <param name="expression"></param> /// <returns></returns> private Expression EditExpression(Expression expression) { Expression retVal = expression; if (expression != null) { ModelElement.DontRaiseError(() => { InterpretationContext context = new InterpretationContext(Model) {UseDefaultValue = false}; IValue value = expression.GetExpressionValue(context, null); if (value != null) { StructureEditor.Window window = new StructureEditor.Window(); window.SetModel(value); window.ShowDialog(); string newExpression = value.ToExpressionWithDefault(); const bool doSemanticalAnalysis = true; const bool silent = true; retVal = new Parser().Expression(expression.Root, newExpression, AllMatches.INSTANCE, doSemanticalAnalysis, null, silent); } }); } return retVal; }
/// <summary> /// Provides the value of the expression provided /// </summary> /// <param name="instance"></param> /// <param name="expression"></param> /// <param name="explain"></param> /// <returns></returns> private bool getBoolValue(ModelElement instance, Expression expression, ExplanationPart explain) { bool retVal; InterpretationContext context = new InterpretationContext(instance); BoolValue val = expression.GetExpressionValue(context, explain) as BoolValue; if (val != null) { retVal = val.Val; } else { throw new Exception("Cannot evaluate value of " + expression); } return retVal; }