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


C# BinaryWriter.WriteSizeEx方法代码示例

本文整理汇总了C#中System.IO.BinaryWriter.WriteSizeEx方法的典型用法代码示例。如果您正苦于以下问题:C# BinaryWriter.WriteSizeEx方法的具体用法?C# BinaryWriter.WriteSizeEx怎么用?C# BinaryWriter.WriteSizeEx使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.BinaryWriter的用法示例。


在下文中一共展示了BinaryWriter.WriteSizeEx方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EncodeInternal

 protected override void EncodeInternal(BinaryWriter output)
 {
     output.WriteOpcode(MarshalOpcode.SubStream);
     var tempMs = new MemoryStream();
     var temp = new BinaryWriter(tempMs);
     temp.Write((byte)0x7E);
     temp.Write((uint)0);
     Data.Encode(temp);
     output.WriteSizeEx((uint)tempMs.Length);
     output.Write(tempMs.ToArray());
 }
开发者ID:stschake,项目名称:eveMarshal,代码行数:11,代码来源:PySubStream.cs

示例2: EncodeInternal

        protected override void EncodeInternal(BinaryWriter output)
        {
            output.WriteOpcode(MarshalOpcode.SubStream);

            var memoryStream = new MemoryStream();
            var binaryWriter = new BinaryWriter(memoryStream);

            binaryWriter.Write(Marshal.Process(Data));

            output.WriteSizeEx((uint)memoryStream.Length);
            output.Write(memoryStream.ToArray());
        }
开发者ID:Reve,项目名称:EVESharp,代码行数:12,代码来源:PySubStream.cs

示例3: EncodeInternal

 protected override void EncodeInternal(BinaryWriter output)
 {
     output.WriteOpcode(MarshalOpcode.IntegerVar);
     output.WriteSizeEx(Raw.Length);
     output.Write(Raw);
 }
开发者ID:VizanArkonin,项目名称:EVEmu-live-packet-editor,代码行数:6,代码来源:PyIntegerVar.cs

示例4: EncodeInternal

 protected override void EncodeInternal(BinaryWriter output)
 {
     output.WriteOpcode(MarshalOpcode.Buffer);
     output.WriteSizeEx(Data.Length);
     output.Write(Data);
 }
开发者ID:VizanArkonin,项目名称:EVEmu-live-packet-editor,代码行数:6,代码来源:PyBuffer.cs

示例5: ZeroCompress

        public static void ZeroCompress(BinaryReader reader, MemoryStream stream, BinaryWriter output)
        {
            MemoryStream newStream = new MemoryStream();
            BinaryWriter newWriter = new BinaryWriter(newStream);

            byte b = reader.ReadByte();

            while(stream.Position < stream.Length)
            {
                ZeroCompressOpcode opcode = new ZeroCompressOpcode(0);
                int opcodeStartShift = 1;

                // Reserve space for opcode
                newWriter.Write(opcode.Value);

                if (b == 0x00)
                {
                    opcode.FirstIsZero = true;
                    int firstLen = -1;

                    while ((b == 0x00) && (firstLen < 7) && (stream.Position < stream.Length))
                    {
                        firstLen++;
                        b = reader.ReadByte();
                    }

                    opcode.FirstLength = (byte)(firstLen);
                }
                else
                {
                    opcode.FirstIsZero = false;
                    opcode.FirstLength = 8;

                    while ((b != 0x00) && (opcode.FirstLength > 0))
                    {
                        opcode.FirstLength--;
                        opcodeStartShift++;

                        newWriter.Write(b);
                        if (stream.Position < stream.Length)
                        {
                            b = reader.ReadByte();
                        }
                        else
                        {
                            break;
                        }
                    }
                }

                if (stream.Position == stream.Length)
                {
                    opcode.SecondIsZero = true;
                    opcode.SecondLength = 0;
                }
                else if (b == 0x00)
                {
                    opcode.SecondIsZero = true;
                    int secondLength = -1;

                    while ((b == 0x00) && (opcode.SecondLength < 7) && (stream.Position < stream.Length))
                    {
                        secondLength++;
                        b = reader.ReadByte();
                    }

                    opcode.SecondLength = (byte)(secondLength);
                }
                else
                {
                    opcode.SecondIsZero = false;
                    opcode.SecondLength = 8;

                    while ((b != 0x00) && (opcode.SecondLength > 0))
                    {
                        opcode.SecondLength--;
                        opcodeStartShift++;

                        newWriter.Write(b);
                        if (stream.Position < stream.Length)
                        {
                            b = reader.ReadByte();
                        }
                        else
                        {
                            break;
                        }
                    }
                }

                newWriter.Seek(-opcodeStartShift, SeekOrigin.Current);
                newWriter.Write(opcode.Value);
                newWriter.Seek(opcodeStartShift - 1, SeekOrigin.Current);
            }

            output.WriteSizeEx((int)(newStream.Length));
            if(newStream.Length > 0)
            {
                output.Write(newStream.ToArray());
            }
//.........这里部分代码省略.........
开发者ID:Reve,项目名称:EVESharp,代码行数:101,代码来源:PyPackedRow.cs

示例6: EncodeInternal

        protected override void EncodeInternal(BinaryWriter output)
        {
            if (ForceUTF8)
            {
                output.WriteOpcode(MarshalOpcode.WStringUTF8);
                output.WriteSizeEx(Raw.Length);
                output.Write(Raw);
                return;
            }

            int idx;
            if (Raw.Length == 0)
                output.WriteOpcode(MarshalOpcode.StringEmpty);
            else if (Raw.Length == 1)
            {
                output.WriteOpcode(MarshalOpcode.StringChar);
                output.Write(Raw[0]);
            }
            else if ((idx = StringTable.Entries.IndexOf(Value)) >= 0)
            {
                output.WriteOpcode(MarshalOpcode.StringTable);
                output.Write((byte)(idx+1));
            }
            else
            {
                /*if (Raw.Length < 0xFF)
                {
                    output.WriteOpcode(MarshalOpcode.StringShort);
                    output.Write((byte)Raw.Length);
                    output.Write(Raw);
                }
                else*/
                {
                    output.WriteOpcode(MarshalOpcode.StringLong);
                    output.WriteSizeEx(Raw.Length);
                    output.Write(Raw);
                }
            }
        }
开发者ID:VizanArkonin,项目名称:EVEmu-live-packet-editor,代码行数:39,代码来源:PyString.cs

示例7: EncodeInternal

 protected override void EncodeInternal(BinaryWriter output)
 {
     output.WriteOpcode(MarshalOpcode.Dict);
     output.WriteSizeEx(Dictionary.Count);
     foreach (var pair in Dictionary)
     {
         pair.Value.Encode(output);
         pair.Key.Encode(output);
     }
 }
开发者ID:stschake,项目名称:eveMarshal,代码行数:10,代码来源:PyDict.cs


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