public override void Evaluate() { targetVariable = ParentContext.FindOrCreateVariable(RegexMatch.Groups[1].Value); targetCommand = Command.Get(RegexMatch.Groups[2].Value, ParentContext); if (!objToBool(targetVariable.Value, out originalValue)) { throw new Exception("Value type error"); } ParentContext.Lock(this); State = ExecutionState.DONE; }
public Variable CreateVariable(string varName) { varName = varName.ToLower(); var v = new Variable(); Variables.Add(varName, v); return v; }
// Check if this expression term represents a registered variable private bool TryParseVariable(String text) { if (this.Variable != null) { Value = this.Variable.Value; return true; } else { bool startsWithAtSign = text.StartsWith("@"); Variable variable = executionContext.FindVariable(startsWithAtSign ? text.Substring(1) : text); if (variable != null) { IsStatic = startsWithAtSign; Value = variable.Value; Variable = variable; return true; } return false; } }
// Check if this expression term represents a registered variable private bool TryParseVariable(String text) { if (this.Variable != null) { Value = this.Variable.Value; return true; } else { bool startsWithAtSign = text.StartsWith("@"); String variableName = startsWithAtSign ? text.Substring(1) : text; Variable variable = executionContext.FindVariable(variableName); if (variable != null) { if (variable.Value is SpecialValue) { IsStatic = startsWithAtSign; if (IsStatic) { Variable = variable; Value = Variable.Value; } else { EvalDlg = delegate() { executionContext.UpdateLock(variableName); Value = variable.Value; }; EvalDlg(); } return true; } else { EvalDlg = delegate() { executionContext.UpdateLock(variableName); Value = variable.Value; }; EvalDlg(); return true; } } return false; } }