Пример #1
0
        protected override Variable Evaluate(ParsingScript script)
        {
            List <Variable> args = script.GetFunctionArgs();

            if (m_decimal)
            {
                return(new Variable(m_random.NextDouble()));
            }

            Utils.CheckArgs(args.Count, 1, m_name);
            int limit = args[0].AsInt();

            Utils.CheckPosInt(args[0], script);
            int numberRandoms = Utils.GetSafeInt(args, 1, 1);

            if (numberRandoms <= 1)
            {
                return(new Variable(m_random.Next(0, limit)));
            }

            List <int>      available = Enumerable.Range(0, limit).ToList();
            List <Variable> result    = new List <Variable>();

            for (int i = 0; i < numberRandoms && available.Count > 0; i++)
            {
                int nextRandom = m_random.Next(0, available.Count);
                result.Add(new Variable(available[nextRandom]));
                available.RemoveAt(nextRandom);
            }

            return(new Variable(result));
        }
Пример #2
0
        protected override Variable Evaluate(ParsingScript script)
        {
            bool            isList = false;
            List <Variable> args   = Utils.GetArgs(script,
                                                   Constants.START_ARG, Constants.END_ARG, out isList);

            Utils.CheckArgs(args.Count, 1, m_name);
            int limit = args[0].AsInt();

            Utils.CheckPosInt(args[0]);
            int numberRandoms = Utils.GetSafeInt(args, 1, 1);

            if (numberRandoms <= 1)
            {
                return(new Variable(m_random.Next(0, limit)));
            }

            List <int>      available = Enumerable.Range(0, limit).ToList();
            List <Variable> result    = new List <Variable>();

            for (int i = 0; i < numberRandoms && available.Count > 0; i++)
            {
                int nextRandom = m_random.Next(0, available.Count);
                result.Add(new Variable(available[nextRandom]));
                available.RemoveAt(nextRandom);
            }

            return(new Variable(result));
        }
Пример #3
0
        protected override Variable Evaluate(ParsingScript script)
        {
            List <Variable> args = script.GetFunctionArgs();

            Utils.CheckArgs(args.Count, 2, m_name);

            Variable arrayVar = Utils.GetSafeVariable(args, 0);
            int      col      = Utils.GetSafeInt(args, 1);
            int      fromCol  = Utils.GetSafeInt(args, 2, 0);

            var tuple = arrayVar.Tuple;

            List <Variable> result = new List <Variable>(tuple.Count);

            for (int i = fromCol; i < tuple.Count; i++)
            {
                Variable current = tuple[i];
                if (current.Tuple == null || current.Tuple.Count <= col)
                {
                    throw new ArgumentException(m_name + ": Index [" + col + "] doesn't exist in column " +
                                                i + "/" + (tuple.Count - 1));
                }
                result.Add(current.Tuple[col]);
            }

            return(new Variable(result));
        }
Пример #4
0
        protected override async Task <Variable> EvaluateAsync(ParsingScript script)
        {
            List <Variable> args = script.GetFunctionArgs();

            Utils.CheckArgs(args.Count, 2, m_name);
            string   method      = args[0].AsString().ToUpper();
            string   uri         = args[1].AsString();
            string   load        = Utils.GetSafeString(args, 2);
            string   tracking    = Utils.GetSafeString(args, 3);
            string   onSuccess   = Utils.GetSafeString(args, 4);
            string   onFailure   = Utils.GetSafeString(args, 5, onSuccess);
            string   contentType = Utils.GetSafeString(args, 6, "application/x-www-form-urlencoded");
            Variable headers     = Utils.GetSafeVariable(args, 7);
            int      timeoutMs   = Utils.GetSafeInt(args, 8, 15 * 1000);
            bool     justFire    = Utils.GetSafeInt(args, 9) > 0;

            if (!s_allowedMethods.Contains(method))
            {
                throw new ArgumentException("Unknown web request method: " + method);
            }

            await ProcessWebRequest(uri, method, load, onSuccess, onFailure, tracking, contentType, headers, timeoutMs, justFire);

            return(Variable.EmptyInstance);
        }
Пример #5
0
        protected override Variable Evaluate(ParsingScript script)
        {
            string          rest   = script.Rest;
            bool            isList = false;
            List <Variable> args   = Utils.GetArgs(script,
                                                   Constants.START_ARG, Constants.END_ARG, out isList);

            Utils.CheckArgs(args.Count, 1, m_name);
            string source    = Utils.GetSafeString(args, 0);
            string argument  = Utils.GetSafeString(args, 1);
            string parameter = Utils.GetSafeString(args, 2, "case");
            int    startFrom = Utils.GetSafeInt(args, 3, 0);
            int    length    = Utils.GetSafeInt(args, 4, source.Length);

            StringComparison comp = StringComparison.Ordinal;

            if (parameter.Equals("nocase") || parameter.Equals("no_case"))
            {
                comp = StringComparison.OrdinalIgnoreCase;
            }

            switch (m_mode)
            {
            case Mode.CONTAINS:
                return(new Variable(source.IndexOf(argument, comp) >= 0));

            case Mode.STARTS_WITH:
                return(new Variable(source.StartsWith(argument, comp)));

            case Mode.ENDS_WITH:
                return(new Variable(source.EndsWith(argument, comp)));

            case Mode.INDEX_OF:
                return(new Variable(source.IndexOf(argument, startFrom, comp)));

            case Mode.EQUALS:
                return(new Variable(source.Equals(argument, comp)));

            case Mode.REPLACE:
                return(new Variable(source.Replace(argument, parameter)));

            case Mode.UPPER:
                return(new Variable(source.ToUpper()));

            case Mode.LOWER:
                return(new Variable(source.ToLower()));

            case Mode.TRIM:
                return(new Variable(source.Trim()));

            case Mode.SUBSTRING:
                return(new Variable(source.Substring(startFrom, length)));
            }

            return(new Variable(-1));
        }
Пример #6
0
        protected override Variable Evaluate(ParsingScript script)
        {
            List <Variable> args = script.GetFunctionArgs();
            int             port = Utils.GetSafeInt(args, 0, 13337);

            DebuggerServer.StartServer(port);

            DebuggerServer.OnRequest += ProcessRequest;
            return(Variable.EmptyInstance);
        }
Пример #7
0
        protected override Variable Evaluate(ParsingScript script)
        {
            List <Variable> args = script.GetFunctionArgs();

            Utils.CheckArgs(args.Count, 1, m_name);

            int numberDigits = Utils.GetSafeInt(args, 1, 0);

            args[0].Value = Math.Round(args[0].AsDouble(), numberDigits);
            return(args[0]);
        }
Пример #8
0
        protected override Variable Evaluate(ParsingScript script)
        {
            List <Variable> args = script.GetFunctionArgs();

            Utils.CheckArgs(args.Count, 1, m_name);
            CSCS_SQL.CheckConnectionString(script, m_name);

            var  tableName = Utils.GetSafeString(args, 0);
            bool namesOnly = Utils.GetSafeInt(args, 1, 0) == 1;

            return(GetColsData(tableName, namesOnly));
        }
Пример #9
0
        protected override Variable Evaluate(ParsingScript script)
        {
            bool            isList = false;
            List <Variable> args   = Utils.GetArgs(script,
                                                   Constants.START_ARG, Constants.END_ARG, out isList);

            Utils.CheckArgs(args.Count, 1, m_name);
            int numberDigits = Utils.GetSafeInt(args, 1, 0);

            args[0].Value = Math.Round(args[0].Value, numberDigits);
            return(args[0]);
        }
Пример #10
0
        protected override Variable Evaluate(ParsingScript script)
        {
            bool            isList = false;
            List <Variable> args   = Utils.GetArgs(script,
                                                   Constants.START_ARG, Constants.END_ARG, out isList);

            Utils.CheckArgs(args.Count, 2, m_name);

            Variable all     = Utils.GetSafeVariable(args, 0);
            string   varName = Utils.GetSafeString(args, 1);
            int      index   = Utils.GetSafeInt(args, 2);

            var      function = ParserFunction.GetFunction(varName);
            Variable mapVar   = new Variable(Variable.VarType.ARRAY);

            if (all.Tuple == null)
            {
                return(Variable.EmptyInstance);
            }

            string currentValue = "";
            int    currentCount = 0;

            int globalCount = 0;

            for (int i = 0; i < all.Tuple.Count; i++)
            {
                Variable current = all.Tuple[i];
                if (current.Tuple == null || current.Tuple.Count < index)
                {
                    break;
                }
                string newValue = current.Tuple[index].AsString();
                if (currentValue != newValue)
                {
                    currentValue = newValue;
                    currentCount = 0;
                }
                mapVar.Tuple.Add(new Variable(currentCount));
                currentCount++;
                globalCount++;
            }

            ParserFunction.AddGlobalOrLocalVariable(varName,
                                                    new GetVarFunction(mapVar));
            return(mapVar);
        }
Пример #11
0
        protected override Variable Evaluate(ParsingScript script)
        {
            string          res  = "OK";
            List <Variable> args = script.GetFunctionArgs();

            if (m_start)
            {
                int port = Utils.GetSafeInt(args, 0, 13337);
                res = DebuggerServer.StartServer(port);
            }
            else
            {
                DebuggerServer.StopServer();
            }

            return(new Variable(res));
        }
Пример #12
0
        protected override Variable Evaluate(ParsingScript script)
        {
            string res = "OK";
            List<Variable> args = script.GetFunctionArgs();
            if (m_start)
            {
                int port = Utils.GetSafeInt(args, 0, 13337);
                bool allowRemote = Utils.GetSafeInt(args, 1, 0) == 1;
                DebuggerServer.AllowedClients = Utils.GetSafeString(args, 2);

                res = DebuggerServer.StartServer(port, allowRemote);
            }
            else
            {
                DebuggerServer.StopServer();
            }

            return new Variable(res);
        }
Пример #13
0
        protected override Variable Evaluate(ParsingScript script)
        {
            bool            isList = false;
            List <Variable> args   = Utils.GetArgs(script,
                                                   Constants.START_ARG, Constants.END_ARG, out isList);

            Utils.CheckArgs(args.Count, 3, m_name);

            string   varName  = Utils.GetSafeString(args, 0);
            Variable lines    = Utils.GetSafeVariable(args, 1);
            int      fromLine = Utils.GetSafeInt(args, 2);
            string   hash2    = Utils.GetSafeString(args, 3);
            string   sepStr   = Utils.GetSafeString(args, 4, "\t");

            if (sepStr == "\\t")
            {
                sepStr = "\t";
            }
            char[] sep = sepStr.ToCharArray();

            var      function = ParserFunction.GetFunction(varName);
            Variable mapVar   = function != null?function.GetValue(script) :
                                    new Variable(Variable.VarType.ARRAY);

            for (int counter = fromLine; counter < lines.Tuple.Count; counter++)
            {
                Variable lineVar = lines.Tuple[counter];
                Variable toAdd   = new Variable(counter - fromLine);
                string   line    = lineVar.AsString();
                var      tokens  = line.Split(sep);
                string   hash    = tokens[0];
                mapVar.AddVariableToHash(hash, toAdd);
                if (!string.IsNullOrWhiteSpace(hash2) &&
                    !hash2.Equals(hash, StringComparison.OrdinalIgnoreCase))
                {
                    mapVar.AddVariableToHash(hash2, toAdd);
                }
            }

            ParserFunction.AddGlobalOrLocalVariable(varName,
                                                    new GetVarFunction(mapVar));
            return(Variable.EmptyInstance);
        }
Пример #14
0
        protected override Variable Evaluate(ParsingScript script)
        {
            List <Variable> args = script.GetFunctionArgs();

            Utils.CheckArgs(args.Count, 1, m_name);
            CSCS_SQL.CheckConnectionString(script, m_name);

            if (m_mode == Mode.SETUP)
            {
                var      query  = Utils.GetSafeString(args, 0);
                Variable result = new Variable(ExecuteQuery(query));
                return(result);
            }
            else if (m_mode == Mode.NEXT)
            {
                var id = Utils.GetSafeInt(args, 0);
                return(GetNextRecord(id));
            }
            else if (m_mode == Mode.CLOSE)
            {
                var id = Utils.GetSafeInt(args, 0);
                Close(id);
                return(Variable.EmptyInstance);
            }
            else if (m_mode == Mode.CURRENT_ROW)
            {
                var         id     = Utils.GetSafeInt(args, 0);
                SQLQueryObj obj    = GetSQLObject(id);
                Variable    result = new Variable(obj.CurrentRow);
                return(result);
            }

            else if (m_mode == Mode.TOTAL)
            {
                var      id     = Utils.GetSafeInt(args, 0);
                Variable result = new Variable(GetTotalRecords(id));
                return(result);
            }

            return(Variable.EmptyInstance);
        }
Пример #15
0
        protected override Variable Evaluate(ParsingScript script)
        {
            bool            isList = false;
            List <Variable> args   = Utils.GetArgs(script,
                                                   Constants.START_ARG, Constants.END_ARG, out isList);

            Utils.CheckArgs(args.Count, 3, m_name);

            string   varName  = Utils.GetSafeString(args, 0);
            Variable lines    = Utils.GetSafeVariable(args, 1);
            int      fromLine = Utils.GetSafeInt(args, 2);
            string   sepStr   = Utils.GetSafeString(args, 3, "\t");

            if (sepStr == "\\t")
            {
                sepStr = "\t";
            }
            char[] sep = sepStr.ToCharArray();

            var      function     = ParserFunction.GetFunction(varName);
            Variable allTokensVar = new Variable(Variable.VarType.ARRAY);

            for (int counter = fromLine; counter < lines.Tuple.Count; counter++)
            {
                Variable lineVar   = lines.Tuple[counter];
                Variable toAdd     = new Variable(counter - fromLine);
                string   line      = lineVar.AsString();
                var      tokens    = line.Split(sep);
                Variable tokensVar = new Variable(Variable.VarType.ARRAY);
                foreach (string token in tokens)
                {
                    tokensVar.Tuple.Add(new Variable(token));
                }
                allTokensVar.Tuple.Add(tokensVar);
            }

            ParserFunction.AddGlobalOrLocalVariable(varName,
                                                    new GetVarFunction(allTokensVar));

            return(Variable.EmptyInstance);
        }
Пример #16
0
        protected override Variable Evaluate(ParsingScript script)
        {
            List <Variable> args = script.GetFunctionArgs();

            Utils.CheckArgs(args.Count, 1, m_name);
            string source    = Utils.GetSafeString(args, 0);
            string argument  = Utils.GetSafeString(args, 1);
            string parameter = Utils.GetSafeString(args, 2, "case");
            int    startFrom = Utils.GetSafeInt(args, 3, 0);
            int    length    = Utils.GetSafeInt(args, 4, source.Length);

            StringComparison comp = StringComparison.Ordinal;

            if (parameter.Equals("nocase") || parameter.Equals("no_case"))
            {
                comp = StringComparison.OrdinalIgnoreCase;
            }

            source   = source.Replace("\\\"", "\"");
            argument = argument.Replace("\\\"", "\"");

            switch (m_mode)
            {
            case Mode.CONTAINS:
                return(new Variable(source.IndexOf(argument, comp) >= 0));

            case Mode.STARTS_WITH:
                return(new Variable(source.StartsWith(argument, comp)));

            case Mode.ENDS_WITH:
                return(new Variable(source.EndsWith(argument, comp)));

            case Mode.INDEX_OF:
                return(new Variable(source.IndexOf(argument, startFrom, comp)));

            case Mode.EQUALS:
                return(new Variable(source.Equals(argument, comp)));

            case Mode.REPLACE:
                return(new Variable(source.Replace(argument, parameter)));

            case Mode.UPPER:
                return(new Variable(source.ToUpper()));

            case Mode.LOWER:
                return(new Variable(source.ToLower()));

            case Mode.TRIM:
                return(new Variable(source.Trim()));

            case Mode.SUBSTRING:
                startFrom = Utils.GetSafeInt(args, 1, 0);
                length    = Utils.GetSafeInt(args, 2, source.Length);
                length    = Math.Min(length, source.Length - startFrom);
                return(new Variable(source.Substring(startFrom, length)));

            case Mode.BEETWEEN:
            case Mode.BEETWEEN_ANY:
                int index1 = source.IndexOf(argument, comp);
                int index2 = m_mode == Mode.BEETWEEN ? source.IndexOf(parameter, index1 + 1, comp) :
                             source.IndexOfAny(parameter.ToCharArray(), index1 + 1);
                startFrom = index1 + argument.Length;

                if (index1 < 0 || index2 < index1)
                {
                    throw new ArgumentException("Couldn't extract string between [" + argument +
                                                "] and [" + parameter + "] + from " + source);
                }
                string result = source.Substring(startFrom, index2 - startFrom);
                return(new Variable(result));
            }

            return(new Variable(-1));
        }
Пример #17
0
        Variable GetCoreProperty(string propName, ParsingScript script = null)
        {
            Variable result = Variable.EmptyInstance;

            if (m_propertyMap.TryGetValue(propName, out result) ||
                m_propertyMap.TryGetValue(GetRealName(propName), out result))
            {
                return(result);
            }
            else if (propName.Equals(Constants.OBJECT_PROPERTIES, StringComparison.OrdinalIgnoreCase))
            {
                return(new Variable(GetProperties()));
            }
            else if (propName.Equals(Constants.OBJECT_TYPE, StringComparison.OrdinalIgnoreCase))
            {
                return(new Variable((int)Type));
            }
            else if (propName.Equals(Constants.SIZE, StringComparison.OrdinalIgnoreCase))
            {
                return(new Variable(GetSize()));
            }
            else if (propName.Equals(Constants.UPPER, StringComparison.OrdinalIgnoreCase))
            {
                return(new Variable(AsString().ToUpper()));
            }
            else if (propName.Equals(Constants.LOWER, StringComparison.OrdinalIgnoreCase))
            {
                return(new Variable(AsString().ToLower()));
            }
            else if (propName.Equals(Constants.STRING, StringComparison.OrdinalIgnoreCase))
            {
                return(new Variable(AsString()));
            }
            else if (propName.Equals(Constants.FIRST, StringComparison.OrdinalIgnoreCase))
            {
                if (Tuple != null && Tuple.Count > 0)
                {
                    return(Tuple[0]);
                }
                return(AsString().Length > 0 ? new Variable("" + AsString()[0]) : Variable.EmptyInstance);
            }
            else if (propName.Equals(Constants.LAST, StringComparison.OrdinalIgnoreCase))
            {
                if (Tuple != null && Tuple.Count > 0)
                {
                    return(Tuple.Last <Variable>());
                }
                return(AsString().Length > 0 ? new Variable("" + AsString().Last <char>()) : Variable.EmptyInstance);
            }
            else if (script != null && propName.Equals(Constants.INDEX_OF, StringComparison.OrdinalIgnoreCase))
            {
                List <Variable> args = script.GetFunctionArgs();
                Utils.CheckArgs(args.Count, 1, propName);

                string           search    = Utils.GetSafeString(args, 0);
                int              startFrom = Utils.GetSafeInt(args, 1, 0);
                string           param     = Utils.GetSafeString(args, 2, "no_case");
                StringComparison comp      = param.Equals("case", StringComparison.OrdinalIgnoreCase) ?
                                             StringComparison.CurrentCulture : StringComparison.CurrentCultureIgnoreCase;

                return(new Variable(AsString().IndexOf(search, startFrom, comp)));
            }
            else if (script != null && propName.Equals(Constants.SUBSTRING, StringComparison.OrdinalIgnoreCase))
            {
                List <Variable> args = script.GetFunctionArgs();
                Utils.CheckArgs(args.Count, 1, propName);

                int startFrom = Utils.GetSafeInt(args, 0, 0);
                int length    = Utils.GetSafeInt(args, 1, AsString().Length);
                length = Math.Min(length, AsString().Length - startFrom);

                return(new Variable(AsString().Substring(startFrom, length)));
            }
            else if (script != null && propName.Equals(Constants.REVERSE, StringComparison.OrdinalIgnoreCase))
            {
                script.GetFunctionArgs();
                if (Tuple != null)
                {
                    Tuple.Reverse();
                }
                else if (Type == VarType.STRING)
                {
                    char[] charArray = AsString().ToCharArray();
                    Array.Reverse(charArray);
                    String = new string(charArray);
                }

                return(this);
            }
            else if (script != null && propName.Equals(Constants.SORT, StringComparison.OrdinalIgnoreCase))
            {
                script.GetFunctionArgs();
                Sort();

                return(this);
            }
            else if (script != null && propName.Equals(Constants.SPLIT, StringComparison.OrdinalIgnoreCase))
            {
                List <Variable> args   = script.GetFunctionArgs();
                string          sep    = Utils.GetSafeString(args, 0, " ");
                var             option = Utils.GetSafeString(args, 1);

                return(TokenizeFunction.Tokenize(AsString(), sep, option));
            }
            else if (script != null && propName.Equals(Constants.JOIN, StringComparison.OrdinalIgnoreCase))
            {
                List <Variable> args = script.GetFunctionArgs();
                string          sep  = Utils.GetSafeString(args, 0, " ");
                if (Tuple == null)
                {
                    return(new Variable(AsString()));
                }

                var join = string.Join(sep, Tuple);
                return(new Variable(join));
            }
            else if (script != null && propName.Equals(Constants.ADD, StringComparison.OrdinalIgnoreCase))
            {
                List <Variable> args = script.GetFunctionArgs();
                Utils.CheckArgs(args.Count, 1, propName);
                Variable var = Utils.GetSafeVariable(args, 0);
                if (Tuple != null)
                {
                    Tuple.Add(var);
                }
                else if (Type == VarType.NUMBER)
                {
                    Value += var.AsDouble();
                }
                else
                {
                    String += var.AsString();
                }
                return(var);
            }
            else if (script != null && propName.Equals(Constants.AT, StringComparison.OrdinalIgnoreCase))
            {
                List <Variable> args = script.GetFunctionArgs();
                Utils.CheckArgs(args.Count, 1, propName);
                int at = Utils.GetSafeInt(args, 0);

                if (Tuple != null && Tuple.Count > 0)
                {
                    return(Tuple.Count > at ? Tuple[at] : Variable.EmptyInstance);
                }
                string str = AsString();
                return(str.Length > at ? new Variable("" + str[at]) : Variable.EmptyInstance);
            }
            else if (script != null && propName.Equals(Constants.REPLACE, StringComparison.OrdinalIgnoreCase))
            {
                List <Variable> args = script.GetFunctionArgs();
                Utils.CheckArgs(args.Count, 2, propName);
                string oldVal = Utils.GetSafeString(args, 0);
                string newVal = Utils.GetSafeString(args, 1);

                return(new Variable(AsString().Replace(oldVal, newVal)));
            }
            else if (propName.Equals(Constants.EMPTY_WHITE, StringComparison.OrdinalIgnoreCase))
            {
                bool isEmpty = string.IsNullOrWhiteSpace(AsString());
                return(new Variable(isEmpty));
            }
            else if (script != null && propName.Equals(Constants.REPLACE_TRIM, StringComparison.OrdinalIgnoreCase))
            {
                List <Variable> args = script.GetFunctionArgs();
                Utils.CheckArgs(args.Count, 2, propName);
                string currentValue = AsString();

                for (int i = 0; i < args.Count; i += 2)
                {
                    string oldVal = Utils.GetSafeString(args, i);
                    string newVal = Utils.GetSafeString(args, i + 1);
                    currentValue = currentValue.Replace(oldVal, newVal);
                }

                return(new Variable(currentValue.Trim()));
            }
            else if (script != null && propName.Equals(Constants.CONTAINS, StringComparison.OrdinalIgnoreCase))
            {
                List <Variable> args = script.GetFunctionArgs();
                Utils.CheckArgs(args.Count, 1, propName);
                string           val   = Utils.GetSafeString(args, 0);
                string           param = Utils.GetSafeString(args, 1, "no_case");
                StringComparison comp  = param.Equals("case", StringComparison.OrdinalIgnoreCase) ?
                                         StringComparison.CurrentCulture : StringComparison.CurrentCultureIgnoreCase;

                bool contains = false;
                if (Type == Variable.VarType.ARRAY)
                {
                    string lower = val.ToLower();
                    contains = m_dictionary != null && m_dictionary.ContainsKey(lower);
                    if (!contains && Tuple != null)
                    {
                        foreach (var item in Tuple)
                        {
                            if (item.AsString().Equals(val, comp))
                            {
                                contains = true;
                                break;
                            }
                        }
                    }
                }
                else
                {
                    contains = val != "" && AsString().IndexOf(val, comp) >= 0;
                }
                return(new Variable(contains));
            }
            else if (script != null && propName.Equals(Constants.EQUALS, StringComparison.OrdinalIgnoreCase))
            {
                List <Variable> args = script.GetFunctionArgs();
                Utils.CheckArgs(args.Count, 1, propName);
                string           val   = Utils.GetSafeString(args, 0);
                string           param = Utils.GetSafeString(args, 1, "no_case");
                StringComparison comp  = param.Equals("case", StringComparison.OrdinalIgnoreCase) ?
                                         StringComparison.CurrentCulture : StringComparison.CurrentCultureIgnoreCase;

                return(new Variable(AsString().Equals(val, comp)));
            }
            else if (script != null && propName.Equals(Constants.STARTS_WITH, StringComparison.OrdinalIgnoreCase))
            {
                List <Variable> args = script.GetFunctionArgs();
                Utils.CheckArgs(args.Count, 1, propName);
                string           val   = Utils.GetSafeString(args, 0);
                string           param = Utils.GetSafeString(args, 1, "no_case");
                StringComparison comp  = param.Equals("case", StringComparison.OrdinalIgnoreCase) ?
                                         StringComparison.CurrentCulture : StringComparison.CurrentCultureIgnoreCase;

                return(new Variable(AsString().StartsWith(val, comp)));
            }
            else if (script != null && propName.Equals(Constants.ENDS_WITH, StringComparison.OrdinalIgnoreCase))
            {
                List <Variable> args = script.GetFunctionArgs();
                Utils.CheckArgs(args.Count, 1, propName);
                string           val   = Utils.GetSafeString(args, 0);
                string           param = Utils.GetSafeString(args, 1, "no_case");
                StringComparison comp  = param.Equals("case", StringComparison.OrdinalIgnoreCase) ?
                                         StringComparison.CurrentCulture : StringComparison.CurrentCultureIgnoreCase;

                return(new Variable(AsString().EndsWith(val, comp)));
            }
            else if (script != null && propName.Equals(Constants.TRIM, StringComparison.OrdinalIgnoreCase))
            {
                script.GetFunctionArgs();
                return(new Variable(AsString().Trim()));
            }
            else if (propName.Equals(Constants.KEYS, StringComparison.OrdinalIgnoreCase))
            {
                List <Variable> results = GetAllKeys();
                return(new Variable(results));
            }

            return(result);
        }