public void Can_serialize_null_object_to_Stream() { using (var ms = new MemoryStream()) { JsonSerializer.SerializeToStream((object)null, ms); TypeSerializer.SerializeToStream((object)null, ms); XmlSerializer.SerializeToStream((object)null, ms); } }
public sealed override object DeepCopyObject(object source) { if (source == null) { return(null); } var type = source.GetType(); using (var ms = MemoryStreamManager.GetStream()) { TypeSerializer.SerializeToStream(source, type, ms); ms.Seek(0, System.IO.SeekOrigin.Begin); return(TypeSerializer.DeserializeFromStream(type, ms)); } }
private void SaveToDisk() { using (var iso = IsolatedStorageFile.GetUserStoreForApplication()) { try { if (iso.FileExists(Filename)) { iso.DeleteFile(Filename); } using (var stream = iso.CreateFile(Filename)) { TypeSerializer.SerializeToStream(Cache, stream); } } catch (Exception ex) { // todo: Log this somewhere... } } }
public StreamSerializerDelegate GetStreamSerializer(string contentType) { StreamSerializerDelegate responseWriter; if (this.ContentTypeSerializers.TryGetValue(contentType, out responseWriter)|| this.ContentTypeSerializers.TryGetValue(ContentType.GetRealContentType(contentType), out responseWriter)) { return responseWriter; } var contentTypeAttr = ContentType.GetEndpointAttributes(contentType); switch (contentTypeAttr) { case EndpointAttributes.Xml: return (r, o, s) => XmlSerializer.SerializeToStream(o, s); case EndpointAttributes.Json: return (r, o, s) => JsonDataContractSerializer.Instance.SerializeToStream(o, s); case EndpointAttributes.Jsv: return (r, o, s) => TypeSerializer.SerializeToStream(o, s); } return null; }
public override void ParallelSerialize(object root, Stream stream) { TypeSerializer.SerializeToStream(root, m_primaryType, stream); }
private static void SerializeToStream(IRequestContext requestContext, object dto, Stream stream) { TypeSerializer.SerializeToStream(dto, stream); }
public static void SerializeToStream(object obj, Stream stream) { TypeSerializer.SerializeToStream(obj, obj.GetType(), stream); }
public override void SerializeToStream(IRequest requestContext, object request, Stream stream) { TypeSerializer.SerializeToStream(request, stream); }
// Serialize using TypeSerializer.SerializeToStream(object, Type, Stream) public static string SerializeToStream2(IFoo item) { using var stream = new MemoryStream(); TypeSerializer.SerializeToStream(item, item.GetType(), stream); return(Encoding.UTF8.GetString(stream.GetBuffer(), 0, (int)stream.Length)); }
public override void Serialize(object serializable, Stream outputStream) { TypeSerializer.SerializeToStream(serializable, _primaryType, outputStream); }