本文整理汇总了C#中System.IO.BinaryWriter.WriteNumberMostlyBelow255方法的典型用法代码示例。如果您正苦于以下问题:C# BinaryWriter.WriteNumberMostlyBelow255方法的具体用法?C# BinaryWriter.WriteNumberMostlyBelow255怎么用?C# BinaryWriter.WriteNumberMostlyBelow255使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.BinaryWriter
的用法示例。
在下文中一共展示了BinaryWriter.WriteNumberMostlyBelow255方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveArray
private static void SaveArray(IList list, BinaryWriter writer)
{
writer.WriteNumberMostlyBelow255(list.Count);
if (list.Count == 0)
return;
if (AreAllElementsTheSameType(list))
SaveArrayWhenAllElementsAreTheSameType(list, writer);
else
SaveArrayWhenAllElementsAreNotTheSameType(list, writer);
}
示例2: GetTestBytesWithLengthHeader
public static byte[] GetTestBytesWithLengthHeader(int numberOfWishedTestBytes)
{
var data = new MemoryStream();
var writer = new BinaryWriter(data);
writer.WriteNumberMostlyBelow255(numberOfWishedTestBytes);
writer.Write(false);
for (int num = 0; num < numberOfWishedTestBytes; num++)
writer.Write((byte)(100 + num));
return data.ToArray();
}
示例3: SaveDictionary
private static void SaveDictionary(IDictionary data, BinaryWriter writer)
{
writer.WriteNumberMostlyBelow255(data.Count);
if (data.Count == 0)
return;
if (AreAllDictionaryValuesTheSameType(data))
SaveDictionaryWhenAllValuesAreTheSameType(data, writer);
else
SaveDictionaryWhenAllValuesAreNotTheSameType(data, writer);
}
示例4: SaveCharArray
private static void SaveCharArray(object data, BinaryWriter writer)
{
writer.WriteNumberMostlyBelow255(((char[])data).Length);
writer.Write((char[])data);
}
示例5: SaveMemoryStream
private static void SaveMemoryStream(object data, BinaryWriter writer)
{
var stream = data as MemoryStream;
writer.WriteNumberMostlyBelow255((int)stream.Length);
writer.Write(stream.ToArray());
}
示例6: WriteAndReadNumberMostlyBelow255WithANumberOver255
public void WriteAndReadNumberMostlyBelow255WithANumberOver255()
{
var data = new MemoryStream();
var writer = new BinaryWriter(data);
const int NumberOver255 = 123456;
writer.WriteNumberMostlyBelow255(NumberOver255);
data.Position = 0;
var reader = new BinaryReader(data);
Assert.AreEqual(NumberOver255, reader.ReadNumberMostlyBelow255());
}
示例7: ToByteArrayWithLengthHeader
public static byte[] ToByteArrayWithLengthHeader(byte[] messageData, bool dataIsCompressed)
{
using (var total = new MemoryStream())
using (var writer = new BinaryWriter(total))
{
writer.WriteNumberMostlyBelow255(messageData.Length);
writer.Write(dataIsCompressed);
writer.Write(messageData);
return total.ToArray();
}
}