本文整理汇总了C#中StreamHandler.WriteBytes方法的典型用法代码示例。如果您正苦于以下问题:C# StreamHandler.WriteBytes方法的具体用法?C# StreamHandler.WriteBytes怎么用?C# StreamHandler.WriteBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StreamHandler
的用法示例。
在下文中一共展示了StreamHandler.WriteBytes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ElementWrite
protected override void ElementWrite(StreamHandler writer, int index)
{
if (index == -5)
{
writer.WriteUInt32(this.Unk);
}
else
{
index = -index - 1;
writer.WriteInt32(this.Data[index].Length);
writer.WriteBytes(this.Data[index]);
}
}
示例2: InternalWriteMetaData
protected unsafe override void InternalWriteMetaData()
{
m_stream.DoAt(m_streamOriginalPosition, () =>
{
var bytes = new byte[MainHeader.Size];
byte[] extraData;
using (var writer = new StreamHandler())
{
var flags = this.ExtraInfoFlags;
if (flags.HasFlag(ExtraDataFlags.HasClientIPv4) ||
flags.HasFlag(ExtraDataFlags.HasClientIPv6))
writer.WriteBytes(this.ClientAddress.GetAddressBytes());
if (flags.HasFlag(ExtraDataFlags.HasServerIPv4) ||
flags.HasFlag(ExtraDataFlags.HasServerIPv6))
writer.WriteBytes(this.ServerAddress.GetAddressBytes());
if (flags.HasFlag(ExtraDataFlags.HasClientPort))
writer.WriteInt32(this.ClientPort);
if (flags.HasFlag(ExtraDataFlags.HasServerPort))
writer.WriteInt32(this.ServerPort);
if (flags.HasFlag(ExtraDataFlags.HasSnifferIdString))
{
byte[] arr = Encoding.UTF8.GetBytes(this.SnifferDesc ?? string.Empty);
writer.WriteInt32(arr.Length);
using (MemoryStream oStream = new MemoryStream())
{
// BUG http://blogs.msdn.com/b/bclteam/archive/2006/05/10/592551.aspx
using (var ds = new DeflateStream(oStream, CompressionMode.Compress, true))
ds.Write(arr, 0, arr.Length);
arr = oStream.ToArray();
}
writer.WriteInt32(arr.Length);
writer.WriteBytes(arr);
}
extraData = writer.ToByteArray();
}
fixed (byte* bytesPtr = bytes)
{
var header = (MainHeader*)bytesPtr;
header->PacketCount = this.Count;
Marshal.Copy(SignatureBytes, 0, new IntPtr(header->Signature), SignatureBytes.Length);
header->StartedOnTicks = this.StartTicks;
header->StartedOnUnix = this.StartTime.ToUnixTime();
header->ExtraDataLength = extraData.Length;
header->ExtraInfoFlags = this.ExtraInfoFlags;
}
m_stream.WriteBytes(bytes);
m_stream.WriteBytes(extraData);
});
}