示例#1
0
        internal static void ToJson(fastCSharp.emit.jsonSerializer toJsoner, memberMapValue <valueType> value)
        {
            if (value.Value == null)
            {
                fastCSharp.web.ajax.WriteNull(toJsoner.CharStream);
            }
            else
            {
                memberMap memberMap = value.MemberMap;
                if (memberMap == null || memberMap.IsDefault)
                {
                    fastCSharp.emit.jsonSerializer.typeToJsoner <valueType> .ToJson(toJsoner, value.Value);
                }
                else
                {
                    fastCSharp.emit.jsonSerializer.config config = typePool <fastCSharp.emit.jsonSerializer.config> .Pop() ?? new fastCSharp.emit.jsonSerializer.config(), oldConfig = toJsoner.Config;

                    fastCSharp.emit.memberCopyer <fastCSharp.emit.jsonSerializer.config> .Copy(config, oldConfig);

                    (toJsoner.Config = config).MemberMap = memberMap;
                    try
                    {
                        fastCSharp.emit.jsonSerializer.typeToJsoner <valueType> .ToJson(toJsoner, value.Value);
                    }
                    finally
                    {
                        toJsoner.Config  = oldConfig;
                        config.MemberMap = null;
                        typePool <fastCSharp.emit.jsonSerializer.config> .PushNotNull(config);
                    }
                }
            }
        }
示例#2
0
 public static string ToJson <valueType>(this valueType value, fastCSharp.emit.jsonSerializer.config config = null)
 {
     return(fastCSharp.emit.jsonSerializer.ToJson(value, config));
 }
示例#3
0
 public static void ToJson <valueType>(this valueType value, charStream jsonStream, fastCSharp.emit.jsonSerializer.config config = null)
 {
     fastCSharp.emit.jsonSerializer.ToJson(value, jsonStream, config);
 }