Beispiel #1
0
 /// <summary>
 /// 对象序列化
 /// </summary>
 /// <param name="serializer">二进制数据序列化</param>
 /// <param name="value">数据对象</param>
 internal static void ClassSerialize(Serializer serializer, valueType value)
 {
     if (DefaultSerializer == null)
     {
         if (serializer.CheckPoint(value))
         {
             if (serializer.Config.IsRealType)
             {
                 Type type = value.GetType();
                 if (type != typeof(valueType))
                 {
                     if (serializer.CheckPoint(value))
                     {
                         serializer.Stream.Write(Serializer.RealTypeValue);
                         SerializeMethodCache.GetRealSerializer(type)(serializer, value);
                     }
                     return;
                 }
             }
             if (Emit.Constructor <valueType> .New == null)
             {
                 serializer.Stream.Write(Serializer.NullValue);
             }
             else
             {
                 MemberSerialize(serializer, value);
             }
         }
     }
     else
     {
         DefaultSerializer(serializer, value);
     }
 }
Beispiel #2
0
 /// <summary>
 /// 找不到构造函数
 /// </summary>
 /// <param name="serializer">二进制数据序列化</param>
 /// <param name="value">数据对象</param>
 private static void noConstructor(Serializer serializer, valueType value)
 {
     if (serializer.CheckPoint(value))
     {
         if (serializer.Config.IsRealType)
         {
             Type type = value.GetType();
             if (type == typeof(valueType))
             {
                 serializer.Stream.Write(Serializer.NullValue);
             }
             else
             {
                 SerializeMethodCache.GetRealSerializer(type)(serializer, value);
             }
         }
         else
         {
             serializer.Stream.Write(Serializer.NullValue);
         }
     }
 }