|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using NetSerializer;
namespace Test
{
class MemStreamTest : IMemStreamTest
{
MessageBase[] m_received;
MemoryStream m_stream;
public string Framework { get { return "NetSerializer"; } }
public void Prepare(int numMessages)
{
m_received = new MessageBase[numMessages];
m_stream = new MemoryStream();
}
public long Serialize(MessageBase[] msgs)
{
int numMessages = msgs.Length;
m_stream.Position = 0;
foreach (var msg in msgs)
Serializer.Serialize(m_stream, msg);
m_stream.Flush();
return m_stream.Position;
}
public MessageBase[] Deserialize()
{
int numMessages = m_received.Length;
m_stream.Position = 0;
for (int i = 0; i < numMessages; ++i)
m_received[i] = (MessageBase)Serializer.Deserialize(m_stream);
return m_received;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.