本文整理汇总了C#中IMessage.Serialize方法的典型用法代码示例。如果您正苦于以下问题:C# IMessage.Serialize方法的具体用法?C# IMessage.Serialize怎么用?C# IMessage.Serialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMessage
的用法示例。
在下文中一共展示了IMessage.Serialize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MessageCommit
public MessageCommit(IMessage msg)
{
Body = msg.Serialize();
Hash = GenerateHash(msg);
MessageId = msg.Id;
CommittedAt = DateTime.UtcNow;
}
示例2: Serialize
public override void Serialize(IMessage message, Stream stream)
{
PlainMessage msg = message as PlainMessage;
StringBuilder str = new StringBuilder();
str.Append(msg.Name);
str.Append("\r\n");
byte[] nameBytes = MessageEncoding.GetBytes(str.ToString());
stream.Write(nameBytes, 0, nameBytes.Length);
message.Serialize(stream, MessageEncoding);
stream.Flush();
}
示例3: Serialize
public byte[] Serialize(ISession session, IMessage message)
{
// serialize the data into a bytestream
Serializer serializer = new Serializer();
message.Serialize(serializer);
// postprocessing...
byte[] compressed = this.compressor.Compress(serializer.GetBytes());
byte[] encrypted = this.encryptor.Encrypt(compressed);
return encrypted;
}
示例4: AsyncSend
/// <summary>
/// Asynchronously send a message instance.
/// </summary>
/// <param name="m">Message instance.</param>
/// <param name="ev">Synchronisation event used by the calling thread.</param>
public void AsyncSend(IMessage m, ManualResetEvent ev) {
this.AsyncSend(m.Serialize(), ev);
}
示例5: Send
/// <summary>
/// Send a message instance.
/// </summary>
/// <param name="m">Message instance.</param>
public void Send(IMessage m) {
this.Send(m.Serialize());
}