Skip to content

how to use jaguar_serializer plugin to convert below csharp code to dart? #175

@NTMS2017

Description

@NTMS2017

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();
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions