Пример #1
0
 private T ReadObjectHelper <T>(Type type, BinaryReader reader)
 {
     if (context.IsReservedType(type))
     {
         return((T)ReadReservedType(type, reader));
     }
     else
     {
         var instance = (IPortableObject)Activator.CreateInstance(type);
         instance.Deserialize(new PofReader(context, SlotSourceFactory.CreateFromBinaryReader(reader)));
         return((T)instance);
     }
 }
Пример #2
0
 private void WriteObjectWithoutTypeDescription(BinaryWriter writer, object value, Type valueType)
 {
     if (context.IsReservedType(valueType))
     {
         WriteReservedType(writer, value, valueType);
     }
     else
     {
         var slotDestination = new SlotDestination();
         var pofWriter       = new PofWriter(context, slotDestination);
         ((IPortableObject)value).Serialize(pofWriter);
         slotDestination.WriteToWriter(writer);
     }
 }
Пример #3
0
 private void WriteObjectWithoutTypeDescription <T>(BinaryWriter writer, T value)
 {
     if (context.IsReservedType(typeof(T)))
     {
         WriteReservedType(writer, value);
     }
     else
     {
         var slotDestination = new SlotDestination();
         var pofWriter       = new PofWriter(context, slotDestination);
         pofWriter.WriteToSlots((IPortableObject)value);
         slotDestination.WriteToWriter(writer);
     }
 }
Пример #4
0
 private object ReadObjectWithoutTypeDescription(Type type, BinaryReader reader)
 {
     if (context.IsReservedType(type))
     {
         return(ReadReservedType(type, reader));
     }
     else
     {
         var instance = context.CreateInstance(type);
         instance.Deserialize(new PofReader(context, slotSourceFactory.CreateFromBinaryReader(reader)));
         if (instance is SpecialTypes.Base)
         {
             return(((SpecialTypes.Base)instance).Unwrap());
         }
         else
         {
             return(instance);
         }
     }
 }