Пример #1
0
        private static bool SerializeValue(IJsonSerializerStrategy jsonSerializerStrategy, object value, StringBuilder builder)
        {
            bool   flag = true;
            string text = value as string;

            if (text != null)
            {
                flag = SimpleJsonTool.SerializeString(text, builder);
            }
            else
            {
                IDictionary <object, object> dictionary = value as IDictionary <object, object>;
                if (dictionary != null)
                {
                    flag = SimpleJsonTool.SerializeObject(jsonSerializerStrategy, dictionary.Keys, dictionary.Values, builder);
                }
                else
                {
                    //UnityEngine.Debug.Log("===>>IEnumerable");
                    IEnumerable enumerable = value as IEnumerable;
                    if (enumerable != null)
                    {
                        flag = SimpleJsonTool.SerializeArray(jsonSerializerStrategy, enumerable, builder);
                    }
                    else if (SimpleJsonTool.IsNumeric(value))
                    {
                        flag = SimpleJsonTool.SerializeNumber(value, builder);
                    }
                    else if (value is bool)
                    {
                        builder.Append((!(bool)value) ? "false" : "true");
                    }
                    else if (value == null)
                    {
                        builder.Append("null");
                    }
                    else
                    {
                        object value2;
                        flag = jsonSerializerStrategy.TrySerializeNonPrimitiveObject(value, out value2);
                        if (flag)
                        {
                            SimpleJsonTool.SerializeValue(jsonSerializerStrategy, value2, builder);
                        }
                    }
                }
            }
            return(flag);
        }