public object Deserialize(ISerializedContainer container, Type type) { var psc = container as ProtobufSerializedContainer; if (psc == null) { throw new ArgumentException("Invalid container type. Use the GenerateContainer method."); } return(Deserialize(psc.Stream, type)); }
public void Serialize(ISerializedContainer container, object value, Type type) { var jTokenContainer = container as JArrayContainer; if (jTokenContainer == null) { throw new ArgumentException("Invalid container. Use the GenerateContainer method."); } using (var writer = jTokenContainer.Array.CreateWriter()) _serializer.Serialize(writer, value, type); }
public void Serialize(ISerializedContainer container, object value, Type type) { var psc = container as ProtobufSerializedContainer; if (psc == null) { throw new ArgumentException("Invalid container type. Use the GenerateContainer method."); } Serialize(psc.Stream, value, type); psc.Count++; }
public void Serialize(ISerializedContainer container, object value, Type type) { var psc = container as MsgPackSerializedContainer; if (psc == null) { throw new ArgumentException("Invalid container type. Use the GenerateContainer method."); } var bytes = _context.GetSerializer(type).PackSingleObject(value); // TODO: use recyclable memory pool psc.Queue.Enqueue(bytes); }
public object Deserialize(ISerializedContainer container, Type type) { var psc = container as MsgPackSerializedContainer; if (psc == null) { throw new ArgumentException("Invalid container type. Use the GenerateContainer method."); } byte[] bytes; if (!psc.Queue.TryDequeue(out bytes)) { throw new InvalidDataException("No data available in the container."); } return(_context.GetSerializer(type).UnpackSingleObject(bytes)); }
public object Deserialize(ISerializedContainer container, Type type) { var jTokenContainer = container as JArrayContainer; if (jTokenContainer == null) { throw new ArgumentException("Invalid container. Use the GenerateContainer method."); } if (jTokenContainer.Array.HasValues) { var first = jTokenContainer.Array.First; first.Remove(); using (var reader = first.CreateReader()) return(_serializer.Deserialize(reader, type)); } return(null); }
public void Serialize(ISerializedContainer container, object value, Type type) { var psc = container as ProtobufSerializedContainer; if (psc == null) { throw new ArgumentException("Invalid container type. Use the GenerateContainer method."); } #if DNX451 || NET45 using (var stream = _streamManager.GetStream("ProtobufSerialize")) #else using (var stream = new MemoryStream()) #endif { Serialize(stream, value, type); psc.Queue.Enqueue(stream.ToArray()); } }
public object Deserialize(ISerializedContainer container, Type type) { var psc = container as ProtobufSerializedContainer; if (psc == null) { throw new ArgumentException("Invalid container type. Use the GenerateContainer method."); } byte[] bytes; if (!psc.Queue.TryDequeue(out bytes)) { throw new InvalidDataException("No data available in the container."); } #if DNX451 || NET45 using (var ms = _streamManager.GetStream("ProtobufDeserialize", bytes, 0, bytes.Length)) #else using (var ms = new MemoryStream(bytes, false)) #endif return(Deserialize(ms, type)); }
public void Serialize <T>(ISerializedContainer container, T value) { Serialize(container, value, typeof(T)); }
public T Deserialize <T>(ISerializedContainer container) { return((T)Deserialize(container, typeof(T))); }