コード例 #1
0
        public override string ToString()
        {
            string returnVal  = "IF ";
            var    statements = VariableFunction.Select(x => x.Key.VariableName + " = " + x.Value.SetName).ToList();

            statements.ForEach(x => returnVal += " " + x + " " + RuleOperator.GetName(typeof(RuleOperator), RuleOperator));
            returnVal  = returnVal.Substring(0, returnVal.Length - 3);
            returnVal += (" THEN " + OuputVariableFunction.Item1.VariableName + " = " + OuputVariableFunction.Item2.SetName);
            return(returnVal);
        }
コード例 #2
0
        /// <summary>
        /// Запустить функцию объекта с заданными аргументами [в основном для вызова из скрипта]
        /// </summary>
        public object executeDotFunction(object obj, string functionName, Engine engine, object[] args)
        {
            VariableFunction function = null;

            obj = getRealValue(obj);

            if (obj == null)
            {
                throw new ScriptException(ScriptException.NULL_POINTER, "Попытка вызова функции: \"" + functionName + "\" у null объекта!");
            }

            if (obj is string)
            {
                if (stringFunctions.ContainsKey(functionName))
                {
                    function = stringFunctions[functionName];
                }
            }
            else if (obj is List <object> )
            {
                if (listFunctions.ContainsKey(functionName))
                {
                    function = listFunctions[functionName];
                }
            }
            else if (obj is Dictionary <string, object> )
            {
                if (dictFunctions.ContainsKey(functionName))
                {
                    function = dictFunctions[functionName];
                }
            }
            else if (obj is CustomVariable)
            {
                addToCallStack(FunctionType.GLOBAL, null);
                object functionResult = ((CustomVariable)obj).executeFunction(functionName, this, args);
                removeFromCallStack();
                return(functionResult);
            }
            if (function != null)
            {
                addToCallStack(FunctionType.GLOBAL, null);
                object functionResult = function.function.Invoke(obj, engine, args);
                removeFromCallStack();
                return(functionResult);
            }
            else
            {
                throw new ScriptException(ScriptException.FUNCTION_NOT_FOUND, "Функция \"" + functionName + "\" не найдена в типе \"" + obj.GetType() + "\"!");
            }
        }
コード例 #3
0
ファイル: Node.cs プロジェクト: zyxia/CodeConfusion
 public override void ToFunction(out Function function)
 {
     function = new VariableFunction(_paramName);
 }