internal static void Serialize(fastCSharp.emit.dataSerializer serializer, memberMapValue <valueType> value) { if (value.Value == null) { serializer.Stream.Write(fastCSharp.emit.binarySerializer.NullValue); } else { memberMap memberMap = value.MemberMap; if (memberMap == null || memberMap.IsDefault) { fastCSharp.emit.dataSerializer.typeSerializer <valueType> .Serialize(serializer, value.Value); } else { memberMap oldMemberMap = serializer.MemberMap, currentMemberMap = serializer.CurrentMemberMap, jsonMemberMap = serializer.JsonMemberMap; serializer.MemberMap = memberMap; try { fastCSharp.emit.dataSerializer.typeSerializer <valueType> .Serialize(serializer, value.Value); } finally { serializer.MemberMap = oldMemberMap; serializer.CurrentMemberMap = currentMemberMap; serializer.JsonMemberMap = jsonMemberMap; } } } }
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); } } } }
private static void parseJson(fastCSharp.emit.jsonParser parser, ref memberMapValue <valueType> value) { fastCSharp.emit.jsonParser.config config = typePool <fastCSharp.emit.jsonParser.config> .Pop() ?? new fastCSharp.emit.jsonParser.config(), oldConfig = parser.Config; fastCSharp.emit.memberCopyer <fastCSharp.emit.jsonParser.config> .Copy(config, oldConfig); if (value.MemberMap == null) { value.MemberMap = fastCSharp.code.memberMap <valueType> .New(); } (parser.Config = config).MemberMap = value.MemberMap; try { fastCSharp.emit.jsonParser.typeParser <valueType> .Parse(parser, ref value.Value); } finally { parser.Config = oldConfig; config.Null(); typePool <fastCSharp.emit.jsonParser.config> .PushNotNull(config); } }
private static void deSerialize(fastCSharp.emit.dataDeSerializer deSerializer, ref memberMapValue <valueType> value) { if (deSerializer.CheckNull() == 0) { value.Value = default(valueType); } else { memberMap oldMemberMap = deSerializer.MemberMap; deSerializer.MemberMap = value.MemberMap; try { fastCSharp.emit.dataDeSerializer.typeDeSerializer <valueType> .DeSerialize(deSerializer, ref value.Value); } finally { value.MemberMap = deSerializer.MemberMap; deSerializer.MemberMap = oldMemberMap; } } }