本文整理汇总了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());
}
示例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());
}
示例3: EncodeInternal
protected override void EncodeInternal(BinaryWriter output)
{
output.WriteOpcode(MarshalOpcode.IntegerVar);
output.WriteSizeEx(Raw.Length);
output.Write(Raw);
}
示例4: EncodeInternal
protected override void EncodeInternal(BinaryWriter output)
{
output.WriteOpcode(MarshalOpcode.Buffer);
output.WriteSizeEx(Data.Length);
output.Write(Data);
}
示例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());
}
//.........这里部分代码省略.........
示例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);
}
}
}
示例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);
}
}