当前位置: 首页>>代码示例>>C#>>正文


C# StreamHandler.WriteBytes方法代码示例

本文整理汇总了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]);
     }
 }
开发者ID:CarlosX,项目名称:Kamilla.Wow,代码行数:13,代码来源:SetPhaseShift.cs

示例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);
            });
        }
开发者ID:LordJZ,项目名称:Kamilla,代码行数:57,代码来源:Krpd2NetworkLog.cs


注:本文中的StreamHandler.WriteBytes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。