Exemplo n.º 1
0
        public static string GetClientArray <T>(IEnumerable <T> eValue, string VarName, bool AddScriptTag)
        {
            List <string> aStmt = new List <string>();

            aStmt.Add("var " + VarName + " = [];");

            int i = -1;

            foreach (T Value in eValue)
            {
                string Quot     = "";
                string ValueNew = "";

                if (CLang.In(typeof(T), typeof(string), typeof(char)))
                {
                    Quot     = "\"";
                    ValueNew = CScript.ReplaceForScriptVariable(Value.ToString());
                }
                else if (typeof(T) == typeof(DateTime))
                {
                    ValueNew = CScript.GetJavaScriptDateTime(Convert.ToDateTime(Value));
                }
                else
                {
                    Quot     = "";
                    ValueNew = Value.ToString();
                }

                aStmt.Add(VarName + "[" + (++i).ToString() + "] = " + Quot + ValueNew + Quot + ";");
            }

            return(CScript.GetScript(aStmt, AddScriptTag));
        }