本文整理汇总了C#中IRecord.Serialize方法的典型用法代码示例。如果您正苦于以下问题:C# IRecord.Serialize方法的具体用法?C# IRecord.Serialize怎么用?C# IRecord.Serialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRecord
的用法示例。
在下文中一共展示了IRecord.Serialize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Packet
internal Packet(RequestHeader header, ReplyHeader replyHeader, IRecord request, IRecord response, byte[] data, ZooKeeper.WatchRegistration watchRegistration, string serverPath, string clientPath)
{
this.header = header;
this.replyHeader = replyHeader;
this.request = request;
this.response = response;
this.serverPath = serverPath;
this.clientPath = clientPath;
if (data != null)
{
this.data = data;
}
else
{
try
{
MemoryStream ms = new MemoryStream();
using (EndianBinaryWriter writer = new EndianBinaryWriter(EndianBitConverter.Big, ms, Encoding.UTF8))
{
BinaryOutputArchive boa = BinaryOutputArchive.getArchive(writer);
boa.WriteInt(-1, "len"); // We'll fill this in later
if(header != null)
{
header.Serialize(boa, "header");
}
if (request != null)
{
request.Serialize(boa, "request");
}
ms.Position = 0;
int len = Convert.ToInt32(ms.Length); // now we have the real length
writer.Write(len - 4); // update the length info
this.data = ms.ToArray();
}
}
catch (IOException e)
{
LOG.Warn("Ignoring unexpected exception", e);
}
}
this.watchRegistration = watchRegistration;
}
示例2: Write
public void Write(IRecord r)
{
r.Serialize(archive, "");
}