Exemple #1
0
        private AjaxParam GetParam(XmlNode node)
        {
            AjaxParam p = new AjaxParam();

            p.ParamName = XmlUtil.GetStringAttribute(node, "name", string.Empty);
            p.ParamType = XmlUtil.GetStringAttribute(node, "type", string.Empty);

            return(p);
        }
        private AjaxParam GetParam(XmlNode node)
        {
            AjaxParam p = new AjaxParam();

            p.ParamName = XmlUtil.GetStringAttribute(node, "name", string.Empty);
            p.ParamType = XmlUtil.GetStringAttribute(node, "type", string.Empty);

            return p;
        }
Exemple #3
0
        private static object[] ConstructMethodArgs(List <AjaxParam> ps, string methodJsonArgs)
        {
            ArrayList argsObject;

            try
            {
                if (string.IsNullOrEmpty(methodJsonArgs))
                {
                    argsObject = new ArrayList()
                    {
                        string.Empty
                    }
                }
                ;
                else
                {
                    argsObject = new Kiss.Json.JavaScriptSerializer().Deserialize <ArrayList>(methodJsonArgs);
                }

                for (int i = 0; i < ps.Count; i++)
                {
                    AjaxParam p     = ps[i];
                    string    pType = p.ParamType.ToLower();
                    object    data  = argsObject[i];

                    switch (pType)
                    {
                    case "long":
                        argsObject[i] = Convert.ToInt64(data);
                        break;

                    case "int":
                        argsObject[i] = Convert.ToInt32(data);
                        break;

                    case "double":
                        argsObject[i] = Convert.ToDouble(data);
                        break;

                    case "bool":
                        argsObject[i] = Convert.ToBoolean(data);
                        break;

                    case "string":
                        argsObject[i] = data == null ? string.Empty : data.ToString();
                        break;

                    case "strings":
                        if (data is IList)
                        {
                            List <string> list = new List <string>();
                            foreach (object item in (IList)data)
                            {
                                list.Add(item.ToString());
                            }
                            argsObject[i] = list.ToArray();
                        }
                        break;

                    case "ints":
                        if (data is IList)
                        {
                            List <int> list = new List <int>();
                            foreach (object item in (IList)data)
                            {
                                list.Add(Convert.ToInt32(item));
                            }
                            argsObject[i] = list.ToArray();
                        }
                        break;

                    default:
                        break;
                    }
                }

                return(argsObject.ToArray());
            }
            catch (Exception ex)
            {
                logger.Error("ConstructMethodArgs failed", ex);
                return(null);
            }
        }