/// <summary> /// Provides the value of an expression /// </summary> /// <param name="expression"></param> /// <returns></returns> public Value GetExpressionValue(string expression) { Value retVal = null; EfsAccess.WaitOne(); try { Expression expressionTree = new Parser().Expression(EfsSystem.Instance.Dictionaries[0], expression); if (expressionTree != null) { Util.DontNotify(() => { retVal = ConvertOut(expressionTree.GetExpressionValue(new InterpretationContext(), null)); }); } } catch (Exception) { // TODO } finally { EfsAccess.ReleaseMutex(); } return(retVal); }
/// <summary> /// Sets the value of a specific variable /// </summary> /// <param name="variableName"></param> /// <param name="value"></param> public void SetVariableValue(string variableName, Value value) { EfsAccess.WaitOne(); try { if (Runner != null) { IVariable variable = EfsSystem.Instance.FindByFullName(variableName) as IVariable; if (variable != null) { Util.DontNotify(() => { Runner.CacheImpact = new CacheImpact(); SyntheticVariableUpdateAction action = new SyntheticVariableUpdateAction(variable, value.ConvertBack(variable.Type)); VariableUpdate variableUpdate = new VariableUpdate(action, null, null); Runner.EventTimeLine.AddModelEvent(variableUpdate, true); Runner.ClearCaches(); }); } else { throw new FaultException <EFSServiceFault> ( new EFSServiceFault("Cannot find variable " + variableName), new FaultReason(new FaultReasonText("Cannot find variable " + variableName))); } } } finally { EfsAccess.ReleaseMutex(); } }
/// <summary> /// Provides the value of a specific variable /// </summary> /// <param name="variableName"></param> /// <returns></returns> public Value GetVariableValue(string variableName) { Value retVal = null; EfsAccess.WaitOne(); try { IVariable variable = EfsSystem.Instance.FindByFullName(variableName) as IVariable; if (variable != null) { retVal = ConvertOut(variable.Value); } } catch (Exception) { // TODO } finally { EfsAccess.ReleaseMutex(); } return(retVal); }