Exemplo n.º 1
0
    static T SerializeWire <T>(T original)
    {
        Console.WriteLine("Wire");

        T            copy   = default(T);
        MemoryStream stream = null;

        using (new Measure("Serialize"))
        {
            for (int i = 0; i < Iteration; i++)
            {
                wireSerializer.Serialize(original, stream = new MemoryStream());
            }
        }

        using (new Measure("Deserialize"))
        {
            for (int i = 0; i < Iteration; i++)
            {
                stream.Position = 0;
                copy            = wireSerializer.Deserialize <T>(stream);
            }
        }

        if (!dryRun)
        {
            Console.WriteLine(string.Format("{0,15}   {1}", "Binary Size", ToHumanReadableSize(stream.Position)));
        }

        return(copy);
    }
Exemplo n.º 2
0
 public override object FromBinary(byte[] bytes, Type type)
 {
     using (var ms = new MemoryStream(bytes))
     {
         var res = _seralizer.Deserialize <object>(ms);
         return(res);
     }
 }