/// <summary>
    /// 具体数据类型转换为存储的String字符串
    /// </summary>
    /// <param name="value"></param>
    /// <returns></returns>
    public static string ObjectValue2TableString(object value, List <char> arraySplitFormat)
    {
        string res = "";

        if (value == null)
        {
            return(res);
        }

        Type t = value.GetType();

        if (t.IsArray)
        {
            //  PropertyInfo pL= t.GetProperty("Length");
            //int length= (int) pL.GetValue(value, null);
            //  MethodInfo mth= t.GetMethod("GetValue", new Type[] { typeof(int) });
            //  for (int i = 0; i < length; i++)
            //  {
            //      object v = mth.Invoke(value, new object[] { i });
            //      res += SingleData2String(v);
            //      if (i < length - 1)
            //          res += "|";
            //  }
            res = ParseTool.ArrayObject2String(value, arraySplitFormat.ToArray());
        }
        else
        {
            res = SingleData2String(value);
        }

        return(res);
    }
Example #2
0
    public void PaseArray1()
    {
        {
            string arrayStringContent = "mm#123,haha|papa,haha|ko#888";
            char[] arraySplitFormat   = new char[] { ',', '#' };

            Array array = ParseTool.String2Array(FieldType.StringArray, arrayStringContent, arraySplitFormat);
            Debug.Assert(array != null);
            Debug.Log(JsonUtils.ToJson(array));

            string res = ParseTool.ArrayObject2String(array, arraySplitFormat);
            Debug.Log(res);
            Debug.Assert(res == arrayStringContent);
        }
        {
            string arrayStringContent = "NULl";
            char[] arraySplitFormat   = new char[] { ',', '#' };

            Array array = ParseTool.String2Array(FieldType.StringArray, arrayStringContent, arraySplitFormat);
            Debug.Assert(array == null);
            Debug.Log(JsonUtils.ToJson(array));

            string res = ParseTool.ArrayObject2String(array, arraySplitFormat);
            Debug.Log(res);
            Debug.Assert(res == arrayStringContent.ToLower());
        }
    }