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


C# Stream.ReadStruct方法代码示例

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


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

示例1: ReadBallFromStream

        private static Ball ReadBallFromStream(Stream str)
        {
            var ret = new Ball {Header = str.ReadStruct<BallHeader>()};

            if (ret.Header.Mode != BallMode.Rigid)
                ret.ExtraHeader = str.ReadStruct<ExtraBallHeader>();

            if (ret.Header.Flags.HasFlag(BallFlag.IsFree))
                ret.Data = str.ReadStruct<BallData>();

            var reader = new BinaryReader(str);
            ret.FormationId = reader.ReadByte();

            switch (ret.Header.Mode)
            {
                case BallMode.Follow:
                case BallMode.Orbit:
                        ret.FollowState = str.ReadStruct<FollowState>();
                        break;

                case BallMode.Formation:
                        ret.FormationState = str.ReadStruct<FormationState>();
                        break;

                case BallMode.Troll:
                        ret.TrollState = str.ReadStruct<TrollState>();
                        break;

                case BallMode.Missile:
                        ret.MissileState = str.ReadStruct<MissileState>();
                        break;

                case BallMode.Goto:
                        ret.GotoState = str.ReadStruct<GotoState>();
                        break;

                case BallMode.Warp:
                        ret.WarpState = str.ReadStruct<WarpState>();
                        break;

                case BallMode.Mushroom:
                        ret.MushroomState = str.ReadStruct<MushroomState>();
                        break;

                case BallMode.Stop:
                case BallMode.Field:
                case BallMode.Rigid:
                        // no extra data for these
                        break;
            }

            if (ret.Header.Flags.HasFlag(BallFlag.HasMiniBalls))
                ret.MiniBalls = ReadMiniBalls(reader);
            ret.Name = ReadString(reader);

            return ret;
        }
开发者ID:Reve,项目名称:eveDestiny,代码行数:57,代码来源:UpdateReader.cs

示例2: ReadChunk

 public Chunk ReadChunk(Stream Stream)
 {
     var ChunkSize = (uint)Stream.ReadStruct<uint_be>();
     //var ChunkType = (ushort)Stream.ReadStruct<ushort_be>();
     var ChunkStream = Stream.ReadStream(ChunkSize);
     return new Chunk()
     {
         Size = ChunkSize,
         //Type = ChunkType,
         Stream = ChunkStream,
     };
 }
开发者ID:soywiz,项目名称:cspspemu,代码行数:12,代码来源:Pmf.cs

示例3: Load

        public Pmf Load(Stream Stream)
        {
            this.Stream = Stream;
            Header = Stream.ReadStruct<HeaderStruct>();

            var Chunk = ReadChunk(Stream.SliceWithLength(0x50));
            InfoHeader = Chunk.Stream.ReadStruct<InfoHeaderStruct>();
            /*
            Console.WriteLine("0x{0:X}", (ulong)InfoHeader.FirstTimestamp);
            Console.WriteLine("0x{0:X}", (ulong)InfoHeader.LastTimestamp);
            Console.WriteLine("{0}", (ulong)InfoHeader.Width);
            Console.WriteLine("{0}", (ulong)InfoHeader.Height);
            */

            return this;
        }
开发者ID:soywiz,项目名称:cspspemu,代码行数:16,代码来源:Pmf.cs

示例4: ReadHeader

 private void ReadHeader(Stream str)
 {
     Header = str.ReadStruct<Header>();
     if (Header.PacketType != 0 && Header.PacketType != 1)
         throw new InvalidDataException("Unknown packet type; expected 0 or 1, got " + Header.PacketType);
 }
开发者ID:Reve,项目名称:eveDestiny,代码行数:6,代码来源:UpdateReader.cs

示例5: ReadBallFromStream

        private static Ball ReadBallFromStream(Stream str)
        {
            var ret = new Ball {Header = str.ReadStruct<BallHeader>()};

            if (ret.Header.Mode != BallMode.Rigid)
                ret.ExtraHeader = str.ReadStruct<ExtraBallHeader>();

            if (ret.Header.Flags.HasFlag(BallFlag.IsFree))
                ret.Data = str.ReadStruct<BallData>();

            var reader = new BinaryReader(str);
            ret.FormationId = reader.ReadByte();

            switch (ret.Header.Mode)
            {
                case BallMode.Follow:
                case BallMode.Orbit:
                        ret.FollowState = str.ReadStruct<FollowState>();
                        break;

                case BallMode.Formation:
                        ret.FormationState = str.ReadStruct<FormationState>();
                        break;

                case BallMode.Troll:
                        ret.TrollState = str.ReadStruct<TrollState>();
                        break;

                case BallMode.Missile:
                        ret.MissileState = str.ReadStruct<MissileState>();
                        break;

                case BallMode.Goto:
                        ret.GotoState = str.ReadStruct<GotoState>();
                        break;

                case BallMode.Warp:
                        ret.WarpState = str.ReadStruct<WarpState>();
                        break;

                case BallMode.Mushroom:
                        ret.MushroomState = str.ReadStruct<MushroomState>();
                        break;

                case BallMode.Stop:
                case BallMode.Field:
                case BallMode.Rigid:
                        // no extra data for these
                        break;
            }

            if (ret.Header.Flags.HasFlag(BallFlag.HasMiniBalls))
                ret.MiniBalls = ReadMiniBalls(reader);

            // Crucible:
            // no more names in destiny data
            // most of them were invalid anyway, and slimitems have the name, so sensible change for CCP
            //ret.Name = ReadString(reader);

            return ret;
        }
开发者ID:Reve,项目名称:EVESharp,代码行数:61,代码来源:UpdateReader.cs


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