Exemple #1
0
        /*--------------------------------------------------------------------------------------------*/
        private string AddParamInner(IWeaverQueryVal pValue)
        {
            string p = "_P" + Params.Keys.Count;

            Params.Add(p, pValue);
            return(p);
        }
Exemple #2
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        public static string[] GetScriptAndParamJson(string pScript,
                                                     IDictionary <string, IWeaverQueryVal> pParams)
        {
            string q = JsonUnquote(pScript);

            if (pParams == null || pParams.Keys.Count == 0)
            {
                return(new [] { q });
            }

            const string end = @"(?=$|[^\d])";
            var          sb  = new StringBuilder();

            foreach (string key in pParams.Keys)
            {
                sb.Append((sb.Length > 0 ? "," : "") + "\"" + JsonUnquote(key) + "\":");
                IWeaverQueryVal qv = pParams[key];

                if (qv.IsString)
                {
                    sb.Append("\"" + JsonUnquote(qv.FixedText) + "\"");
                    continue;
                }

                sb.Append(qv.FixedText);

                //Explicitly cast certain parameter types
                //See: https://github.com/tinkerpop/rexster/issues/295

                if (qv.Original is int)
                {
                    q = Regex.Replace(q, key + end, key + ".toInteger()");
                }
                else if (qv.Original is byte)
                {
                    q = Regex.Replace(q, key + end, key + ".byteValue()");
                }
                else if (qv.Original is float)
                {
                    q = Regex.Replace(q, key + end, key + ".toFloat()");
                }
            }

            return(new [] { q, "{" + sb + "}" });
        }
Exemple #3
0
 /*--------------------------------------------------------------------------------------------*/
 public string AddParam(IWeaverQueryVal pValue)
 {
     return(AddParamInner(pValue));
 }