本文整理汇总了C#中System.IO.MemoryStream.ReadStruct方法的典型用法代码示例。如果您正苦于以下问题:C# MemoryStream.ReadStruct方法的具体用法?C# MemoryStream.ReadStruct怎么用?C# MemoryStream.ReadStruct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.MemoryStream
的用法示例。
在下文中一共展示了MemoryStream.ReadStruct方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandlePacket_RemoveElements
private byte[] HandlePacket_RemoveElements(byte[] RequestContent)
{
var RequestContentStream = new MemoryStream(RequestContent);
var RequestHeader = RequestContentStream.ReadStruct<RequestHeaderStruct>();
{
var RequestEntries = RequestContentStream.ReadStructVectorUntilTheEndOfStream<RequestEntryStruct>();
var Index = ServerManager.ServerIndices[RequestHeader.RankingIndexId];
foreach (var RequestEntry in RequestEntries)
{
Index.Tree.Remove(Index.GetUserScore(RequestEntry.UserId));
}
}
return new byte[0];
}
示例2: HandlePacketAsync_RemoveElements
async private Task<byte[]> HandlePacketAsync_RemoveElements(byte[] RequestContent)
{
var RequestContentStream = new MemoryStream(RequestContent);
var RequestHeader = RequestContentStream.ReadStruct<RequestHeaderStruct>();
await EnqueueTaskAsync((uint)RequestHeader.RankingIndexId, () =>
{
var RequestEntries = RequestContentStream.ReadStructVectorUntilTheEndOfStream<RequestEntryStruct>();
var Index = ServerManager.ServerIndices[RequestHeader.RankingIndexId];
foreach (var RequestEntry in RequestEntries)
{
Index.Tree.Remove(Index.GetUserScore(RequestEntry.UserId));
}
});
return new byte[0];
}
示例3: SoundFXObject
public SoundFXObject(byte[] data)
{
Data = data;
using (MemoryStream s = new MemoryStream(data))
{
Header = s.ReadStruct<SoundFXHeader>();
if (Header.IsStreamed != 0)
{
WemOffset = s.ReadUInt32();
WemLength = s.ReadUInt32();
}
}
UInt32 temp = Header.AudioFileId % 0x32;
Console.WriteLine("SoundFX ID: {0:X8} AudioFileID: {1:X8} SourceId: {2:X8} temp {3:X8}", Header.ID, Header.AudioFileId, Header.SourceId, temp);
}
示例4: HandlePacket_SetElements
private byte[] HandlePacket_SetElements(byte[] RequestContent)
{
var RequestContentStream = new MemoryStream(RequestContent);
var RequestHeader = RequestContentStream.ReadStruct<SetElements_RequestHeaderStruct>();
var RequestEntries = RequestContentStream.ReadStructVectorUntilTheEndOfStream<SetElements_RequestEntryStruct>();
{
var Index = ServerManager.ServerIndices[RequestHeader.RankingId];
foreach (var Request in RequestEntries)
{
Index.UpdateUserScore(
UserId: Request.UserId,
ScoreTimeStamp: Request.ScoreTimeStamp,
ScoreValue: Request.ScoreValue
);
}
}
return new byte[0];
}
示例5: UnpackColorCategory
private static Category UnpackColorCategory(byte[] data)
{
var category = new Category();
using (var ms = new MemoryStream(data))
using (var reader = new BinaryReader(ms))
{
category.Header = ms.ReadStruct<CategoryHeader>();
for (var i = 0; i < category.Header.ColorCount; i++)
{
var colorRecord = UnpackColorRecord(reader);
category.ColorRecords.Add(colorRecord);
}
//var alignCheck = reader.ReadInt32();
//Debug.Assert( alignCheck == category.Header.CategoryDataSize, "The header (and color reads) alignment is not correct." );
}
return category;
}
示例6: ReadReplyFromMemory
protected async Task<IEnumerable<BsonDocument>> ReadReplyFromMemory(MemoryStream PacketStream)
{
var PacketStreamReader = new BinaryReader(PacketStream);
var MsgHeader = PacketStream.ReadStruct<MsgHeader>();
var ResponseFlags = PacketStreamReader.ReadUInt32();
var CursorID = PacketStreamReader.ReadUInt64();
var StartingFrom = PacketStreamReader.ReadUInt32();
var NumberReturned = PacketStreamReader.ReadUInt32();
var Results = new List<BsonDocument>();
for (int n = 0; n < NumberReturned; n++)
{
Results.Add(BsonSerializer.Deserialize<BsonDocument>(PacketStream));
}
return Results;
}