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


C# MemoryStream.ReadStruct方法代码示例

本文整理汇总了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];
		}
开发者ID:ktj007,项目名称:smrr-server,代码行数:16,代码来源:ServerHandler.RemoveElements.cs

示例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];
        }
开发者ID:ktj007,项目名称:smrr-server,代码行数:17,代码来源:ServerHandler.RemoveElements.cs

示例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);
        }
开发者ID:rodrigonh,项目名称:ThomasJepp.SaintsRow,代码行数:18,代码来源:SoundFXObject.cs

示例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];
		}
开发者ID:ktj007,项目名称:smrr-server,代码行数:22,代码来源:ServerHandler.SetElements.cs

示例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;
        }
开发者ID:number1nub,项目名称:VisualThemeEditor2013,代码行数:19,代码来源:ThemeReader.cs

示例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;
		}
开发者ID:soywiz,项目名称:csharputils,代码行数:20,代码来源:MongoClientAsync.cs


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