Пример #1
0
        void json_stringify(LanguageInterpreter sender, FunctionArgs args)
        {
            if (EUtils.CheckArgs(1, args))
            {
                object param = args.EvaluateParameters()[0];

                if (EUtils.CheckArgType(param, typeof(AnonymousVariableArray)))
                {
                    AnonymousVariableArray array = (AnonymousVariableArray)param;

                    args.HasResult = true;
                    args.Result    = array.SerializeToJSON();
                }
                else
                {
                    sender.Interpreter.HandleException(new Exception(sender.Interpreter.CurrentFile, sender.Interpreter.CurrentLine, "Invalid parameter type.", "Function expects parameter of type 'AnonymousVariableArray', got '" + param.GetType().Name + "'.", ""));
                }
            }
            else
            {
                sender.Interpreter.HandleException(Consts.Exceptions.ParameterCountMismatch(sender.Interpreter.CurrentFile, sender.Interpreter.CurrentLine, 1));
            }
        }