示例#1
0
        protected string[] ConvertValues(object[] values)
        {
            if (values == null || values.Length == 1 && values[0] == null)
            {
                return(null);
            }

            //check if paramters are incorrectly picked up as object[]{int[]} and if so, fix this
            if (values.Length == 1 && values[0].GetType().IsArray)
            {
                var tmpList = new List <object>();
                foreach (object o in (IEnumerable)values[0])
                {
                    tmpList.Add(o);
                }
                values = tmpList.ToArray();
            }

            string[] ret = new string[values.Length];

            for (int i = 0; i < ret.Length; i++)
            {
                string convVal = null;

                if (values[i] != null)
                {
                    if (values[i] is int)
                    {
                        convVal = CultureDataFormatter.EncodeInt((int)values[i]);
                    }
                    else if (values[i] is DateTime)
                    {
                        convVal = CultureDataFormatter.EncodeDateTime((DateTime)values[i]);
                    }
                    else if (values[i] is double)
                    {
                        convVal = CultureDataFormatter.EncodeDouble((double)values[i]);
                    }
                    else if (values[i] is string)
                    {
                        convVal = (string)values[i];
                    }
                    else
                    {
                        convVal = CultureDataFormatter.Encode(values[i]);
                    }
                }

                ret[i] = convVal;
            }
            return(ret);
        }