コード例 #1
0
ファイル: CommandTemporal.cs プロジェクト: raad287/KOS
        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;
        }
コード例 #2
0
ファイル: ExecutionContext.cs プロジェクト: phcorcoran/KOS
        public Variable CreateVariable(string varName)
        {
            varName = varName.ToLower();

            var v = new Variable();
            Variables.Add(varName, v);
            return v;
        }
コード例 #3
0
        // 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;
            }
        }
コード例 #4
0
ファイル: Expression.cs プロジェクト: raad287/KOS
        // 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;
            }
        }