-
Notifications
You must be signed in to change notification settings - Fork 34
Open
Description
I have a csharp code and I am not sure if this plugin serialise the object to byte array.
Below example uses Xml.Serialization. how to use jaguar_serializer in same manner of the below csharp code? The object is a class.
So main question is how to use jaguar_serializer plugin to convert below csharp code to dart?
private static readonly Object locker = new Object();
private static byte[] ObjectToByteArray(Object objectToSerialize)
{
MemoryStream ms = new MemoryStream();
//BinaryFormatter formatter = new BinaryFormatter();
System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(objectToSerialize.GetType());
try
{
//Here's the core functionality! One Line!
//To be thread-safe we lock the object
lock (locker)
{
x.Serialize(ms, objectToSerialize);
//formatter.Serialize(fs, objectToSerialize);
}
//return fs.ToArray();
return ms.ToArray();
}
catch (SerializationException se)
{
return null;
}
finally
{
//fs.Close();
ms.Close();
}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels