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


C# BinaryReader.ReadByte方法代码示例

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


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

示例1: MapInfo

        public MapInfo(BinaryReader reader)
        {
            Index = reader.ReadInt32();
            FileName = reader.ReadString();
            Title = reader.ReadString();
            MiniMap = reader.ReadUInt16();
            Light = (LightSetting) reader.ReadByte();
            if (Envir.LoadVersion >= 3) BigMap = reader.ReadUInt16();
            if (Envir.LoadVersion >= 10) reader.ReadByte();

            int count = reader.ReadInt32();
            for (int i = 0; i < count; i++)
                SafeZones.Add(new SafeZoneInfo(reader) { Info = this });

            count = reader.ReadInt32();
            for (int i = 0; i < count; i++)
                Respawns.Add(new RespawnInfo(reader));

            count = reader.ReadInt32();
            for (int i = 0; i < count; i++)
                NPCs.Add(new NPCInfo(reader));

            count = reader.ReadInt32();
            for (int i = 0; i < count; i++)
                Movements.Add(new MovementInfo(reader));
        }
开发者ID:xiaofengzhiyu,项目名称:CSharpMir,代码行数:26,代码来源:MapInfo.cs

示例2: LoadHeaderInternal

        static Map LoadHeaderInternal( [NotNull] Stream stream ) {
            if( stream == null ) throw new ArgumentNullException( "stream" );
            BinaryReader bs = new BinaryReader( stream );

            // Read in the magic number
            if( bs.ReadByte() != 0xbe || bs.ReadByte() != 0xee || bs.ReadByte() != 0xef ) {
                throw new MapFormatException( "MinerCPP map header is incorrect." );
            }

            // Read in the map dimesions
            // Saved in big endian for who-know-what reason.
            // XYZ(?)
            int width = IPAddress.NetworkToHostOrder( bs.ReadInt16() );
            int height = IPAddress.NetworkToHostOrder( bs.ReadInt16() );
            int length = IPAddress.NetworkToHostOrder( bs.ReadInt16() );

            // ReSharper disable UseObjectOrCollectionInitializer
            Map map = new Map( null, width, length, height, false );
            // ReSharper restore UseObjectOrCollectionInitializer

            // Read in the spawn location
            // XYZ(?)
            map.Spawn = new Position {
                X = IPAddress.NetworkToHostOrder( bs.ReadInt16() ),
                Z = IPAddress.NetworkToHostOrder( bs.ReadInt16() ),
                Y = IPAddress.NetworkToHostOrder( bs.ReadInt16() ),
                R = bs.ReadByte(),
                L = bs.ReadByte()
            };

            // Skip over the block count, totally useless
            bs.ReadInt32();

            return map;
        }
开发者ID:fragmer,项目名称:fCraft,代码行数:35,代码来源:MapMinerCPP.cs

示例3: check

        protected override void check(object sender, EventArgs e) {
            int read_width = 0;
            int read_height = 0;
            int read_cwidth = 0;
            int read_cheight = 0;
            int read_quality = 0;
            int read_samples = 0;

            using (Stream stream = new FileStream(outPath, FileMode.Open, FileAccess.Read, FileShare.Read)) {
                using (BinaryReader reader = new BinaryReader(stream, Encoding.Default)) {
                    read_width = reader.ReadUInt16();
                    read_height = reader.ReadUInt16();
                    read_cwidth = reader.ReadUInt16();
                    read_cheight = reader.ReadUInt16();
                    read_quality = reader.ReadByte();
                    read_samples = reader.ReadByte();
                }
            }

            System.Windows.Forms.MessageBox.Show(
                "image width: " + inC1.imageWidth + " = " + read_width +
                "\nimage height: " + inC1.imageHeight + " = " + read_height +
                "\nchannel width: " + inC1.channelWidth + " = " + read_cwidth +
                "\nchannel height: " + inC1.channelHeight + " = " + read_cheight +
                "\nquality: " + inC1.quantizeQuality + " = " + read_quality +
                "\nsamples: " + inC1.samplingMode + " = " + (DataBlob.Samples)read_samples
                , "File Information");
        }
开发者ID:JoePelz,项目名称:NodeShop,代码行数:28,代码来源:WriteMulti2Channel.cs

示例4: Receive

        public void Receive(DataPackage pkgData)
        {
            //收到上报参数
            ReportedParameterItem reportParameterItem = new ReportedParameterItem();

            byte[] dataBuffer = pkgData.PureData;

            using (MemoryStream ms = new MemoryStream(dataBuffer))
            {
                using (BinaryReader br = new BinaryReader(ms))
                {
                    reportParameterItem.StateInterval = br.ReadInt16();
                    reportParameterItem.ThuEnable = br.ReadByte();
                    reportParameterItem.TempInterval = br.ReadByte();
                    reportParameterItem.HumiInterval = br.ReadByte();
                    reportParameterItem.GPIOEnable = br.ReadByte();
                    //br.ReadBytes(6);
                }
            }

            if (OnDataChanged != null)
            {
                DataHandlerEventArgs eventArgs = new DataHandlerEventArgs();
                eventArgs.CMD_ID = pkgData.CtrlHead.CMD_ID;
                eventArgs.Value = reportParameterItem;
                OnDataChanged(this, eventArgs);
            }
        }
开发者ID:kupkup,项目名称:DMProject,代码行数:28,代码来源:ReportedParameterHandler.cs

示例5: readSettings

		void readSettings (BinaryReader inStream)
		{
			setColor (readInt (inStream));
			setTransparency (inStream.ReadByte ());
			setReflectivity (inStream.ReadByte ());
			setFlat (inStream.ReadBoolean ());
		}
开发者ID:VirtualReality,项目名称:Libs,代码行数:7,代码来源:warp_Material.cs

示例6: ByteArraySegmentedStream_ReadByteTest

        public void ByteArraySegmentedStream_ReadByteTest()
        {
            var arr = new byte[100];
            for (byte i = 0; i < 100; i++)
                arr[i] = i;

            var segments = new List<ArraySegment<byte>>();
            

            var stream = new ByteArraySegmentedStream(true);
            stream.AddSegment(new ArraySegment<byte>(arr, 0, 5));
            stream.AddSegment(new ArraySegment<byte>(arr, 2, 5));
            stream.AddSegment(new ArraySegment<byte>(arr, 10, 10));

            var reader = new BinaryReader(stream);

            for (byte i = 0; i < 5; i++)
                Assert.AreEqual(i, reader.ReadByte());

            for (byte i = 0; i < 5; i++)
                Assert.AreEqual(i + 2, reader.ReadByte());

            for (byte i = 0; i < 10; i++)
                Assert.AreEqual(i + 10, reader.ReadByte());
        }
开发者ID:MarkusSintonen,项目名称:Masi.MsgPack.Rpc,代码行数:25,代码来源:ByteArraySegmentedStreamTests.cs

示例7: PlayerInfo

 private void PlayerInfo(BinaryReader gr)
 {
     AppendFormatLine("FreePoints: {0}", gr.ReadUInt32());
     var speccount=gr.ReadByte();
     AppendFormatLine("SpectsCount: {0}", speccount);
     AppendFormatLine("ActiveSpec: {0}", gr.ReadByte());
     if (speccount > 0)
     {
         for (int id = 0; id < 1; id++)
         {
             var talidcount = gr.ReadByte();
             AppendFormatLine("TalentIDCount: {0}", talidcount);
             for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 12; j++)
               {
                   AppendFormatLine("TalentID {0}", gr.ReadUInt32());
                     AppendFormatLine("CurRanc: {0}", gr.ReadByte());
                 }
             }
             var GLYPHMAX = gr.ReadByte();
             AppendFormatLine("GLYPHMAX: {0}", GLYPHMAX);
           for (int g = 0; g < GLYPHMAX; g++)
             {
                 AppendFormatLine("GLYPID: {0}", gr.ReadUInt16());
             }
         }
     }
 }
开发者ID:a1ien,项目名称:WoWPacketViewer,代码行数:29,代码来源:SMSG_TALENTS_INFO.cs

示例8: Parse

        /// <summary> Parses the Replay.Messages.Events file. </summary>
        /// <param name="buffer"> Buffer containing the contents of the replay.messages.events file. </param>
        /// <returns> A list of chat messages parsed from the buffer. </returns>
        public static void Parse(Replay replay, byte[] buffer)
        {
            using (var stream = new MemoryStream(buffer))
            {
                using (var reader = new BinaryReader(stream))
                {
                    int totalTime = 0;
                    while (reader.BaseStream.Position < reader.BaseStream.Length)
                    {
                        // While not EOF
                        var message = new ChatMessage();

                        var time = ParseTimestamp(reader);

                        // sometimes we only have a header for the message
                        if (reader.BaseStream.Position >= reader.BaseStream.Length) 
                            break;

                        message.PlayerId = reader.ReadByte();

                        // I believe this 'PlayerId' is an index for this client list, which can include observers
                        // var player = replay.ClientList[message.PlayerId];

                        totalTime += time;
                        var opCode = reader.ReadByte();

                        if (opCode == 0x80)
                            reader.ReadBytes(4);
                        else if (opCode == 0x83)
                            reader.ReadBytes(8);
                        else if (opCode == 2 && message.PlayerId <= 10)
                        {
                            if (message.PlayerId == 80)
                                continue;

                            message.MessageTarget = (ChatMessageTarget)(opCode & 7);
                            var length = reader.ReadByte();

                            if ((opCode & 8) == 8)
                                length += 64;

                            if ((opCode & 16) == 16)
                                length += 128;

                            message.Message = Encoding.UTF8.GetString(reader.ReadBytes(length));
                        }
                        else
                        {
                            
                        }

                        if (message.Message != null)
                        {
                            message.Timestamp = new TimeSpan(0, 0, (int)Math.Round(totalTime / 16.0));
                            replay.ChatMessages.Add(message);
                        }
                    }
                }
            }
        }
开发者ID:Clsmap,项目名称:Heroes.ReplayParser,代码行数:63,代码来源:ReplayMessageEvents.cs

示例9: PaletteMap

        public PaletteMap(IffChunk Chunk)
            : base(Chunk)
        {
            MemoryStream MemStream = new MemoryStream(Chunk.Data);
            BinaryReader Reader = new BinaryReader(MemStream);

            //Reader.BaseStream.Position = INDEX_PALTID;
            /*m_ID = (uint)numPalettes++;
            m_ID = Reader.ReadUInt32();*/

            //m_Colors = new int[256];
            m_Colors = new Color[256];

            Reader.BaseStream.Position = 16;
            /*if (Reader.BaseStream.ReadByte() == 0)
                Reader.BaseStream.Position = 80;
            else
                Reader.BaseStream.Position = 16;*/

            for (int i = 0; i < 256; i++)
            {
                //Reader.BaseStream.Position += 3;
                byte[] colors = new byte[] {};
                if ((Reader.BaseStream.Length - Reader.BaseStream.Position) >= 3)
                    m_Colors[i] = Color.FromArgb(Reader.ReadByte(), Reader.ReadByte(), Reader.ReadByte());
                else
                    m_Colors[i] = Color.FromArgb(255, 0x80, 0x80, 0x80);
            }

            Reader.Close();
        }
开发者ID:Dannysimsonline,项目名称:Project-Dollhouse,代码行数:31,代码来源:PaletteMap.cs

示例10: ReadMessage

 public static Message ReadMessage(Stream input)
 {
     var buffer = new BinaryReader(input);
     Message msg = new Message();
     msg.ProtocolVersion = buffer.ReadByte();
     msg.MessageType = buffer.ReadByte();
     // read kv
     IDictionary<string, object> dict = new Dictionary<string, object>();
     short headerType = buffer.ReadInt16();
     while (headerType != MessageType.HeaderType.EndOfHeaders)
     {
         if (headerType == MessageType.HeaderType.Custom)
             dict.Add(ReadCountedString(buffer), ReadCustomValue(buffer));
         else if (headerType == MessageType.HeaderType.StatusCode)
             msg.StatusCode = buffer.ReadInt32();
         else if (headerType == MessageType.HeaderType.StatusPhrase)
             msg.StatusPhase = ReadCountedString(buffer);
         else if (headerType == MessageType.HeaderType.Flag)
             msg.Flag = buffer.ReadInt32();
         else if (headerType == MessageType.HeaderType.Token)
             msg.Token = ReadCountedString(buffer);
         headerType = buffer.ReadInt16();
     }
     msg.Content = dict;
     return msg;
 }
开发者ID:fengxianqi,项目名称:Youbang,代码行数:26,代码来源:MessageIO.cs

示例11: Read

 public void Read(BinaryReader reader, float CoordZ, float scale)
 {
     Position = new float[3];
     for (int i = 0; i < Position.Length; i++)
     {
         Position[i] = BitConverter.ToSingle(reader.ReadBytes(4), 0) * scale;
     }
     NormalVector = new float[3];
     for (int i = 0; i < NormalVector.Length; i++)
     {
         NormalVector[i] = BitConverter.ToSingle(reader.ReadBytes(4), 0);
     }
     UV = new float[2];
     for (int i = 0; i < UV.Length; i++)
     {
         UV[i] = BitConverter.ToSingle(reader.ReadBytes(4), 0);
     }
     BoneNum = new WORD[2];
     for (int i = 0; i < BoneNum.Length; i++)
     {
         BoneNum[i] = BitConverter.ToUInt16(reader.ReadBytes(2), 0);
     }
     BoneWeight = reader.ReadByte();
     NonEdgeFlag = reader.ReadByte();
     Position[2] *= CoordZ;
     NormalVector[2] *= CoordZ;
 }
开发者ID:furaga,项目名称:SimpleMMDImporter,代码行数:27,代码来源:ModelVertex.cs

示例12: ReadContentFrom

 protected override void ReadContentFrom(BinaryReader reader)
 {
     //USHORT 	version 	Version number (0 or 1).
     //USHORT 	numRecs 	Number of VDMX groups present
     //USHORT 	numRatios 	Number of aspect ratio groupings
     //Ratio 	ratRange[numRatios] 	Ratio ranges (see below for more info)
     //USHORT 	offset[numRatios] 	Offset from start of this table to the VDMX group for this ratio range.
     //Vdmx 	groups 	The actual VDMX groupings (documented below)
     //Ratio Record Type 	Name 	Description
     //BYTE 	bCharSet 	Character set (see below).
     //BYTE 	xRatio 	Value to use for x-Ratio
     //BYTE 	yStartRatio 	Starting y-Ratio value.
     //BYTE 	yEndRatio 	Ending y-Ratio value.
     ushort version = reader.ReadUInt16();
     ushort numRecs = reader.ReadUInt16();
     ushort numRatios = reader.ReadUInt16();
     ratios = new Ratio[numRatios];
     for (int i = 0; i < numRatios; ++i)
     {
         ratios[i] = new Ratio(
             reader.ReadByte(),
             reader.ReadByte(),
             reader.ReadByte(),
             reader.ReadByte());
     }
     short[] offsets = Utils.ReadInt16Array(reader, numRatios);
     //------
     //actual vdmx group
     //TODO: implement this
 }
开发者ID:prepare,项目名称:HTML-Renderer,代码行数:30,代码来源:VerticalDeviceMatrics.cs

示例13: Decode

 public override void Decode()
 {
     using (var br = new BinaryReader(new MemoryStream(GetData())))
     {
         m_vAccountId = br.ReadInt64WithEndian();
         m_vPassToken = br.ReadScString();
         m_vClientMajorVersion = br.ReadInt32WithEndian();
         m_vClientContentVersion = br.ReadInt32WithEndian();
         m_vClientBuild = br.ReadInt32WithEndian();
         m_vResourceSha = br.ReadScString();
         m_vUDID = br.ReadScString();
         m_vOpenUDID = br.ReadScString();
         m_vMacAddress = br.ReadScString();
         m_vDevice = br.ReadScString();
         br.ReadInt32WithEndian();//00 1E 84 81, readDataReference for m_vPreferredLanguage
         m_vPreferredDeviceLanguage = br.ReadScString();
         //unchecked
         m_vPhoneId = br.ReadScString();
         m_vGameVersion = br.ReadScString();
         br.ReadByte();//01
         br.ReadInt32WithEndian();//00 00 00 00
         m_vSignature2 = br.ReadScString();
         m_vSignature3 = br.ReadScString();
         br.ReadByte();//01
         m_vSignature4 = br.ReadScString();
         m_vClientSeed = br.ReadUInt32WithEndian();
         Debugger.WriteLine("[M] Client with user id " + m_vAccountId + " accessing with " + m_vDevice);
         if(GetMessageVersion() >=7 )//7.200
         {
             br.ReadByte();
             br.ReadUInt32WithEndian();
             br.ReadUInt32WithEndian();
         }
     }
 }
开发者ID:KaskidFoundations,项目名称:ucs,代码行数:35,代码来源:LoginMessage.cs

示例14: DeserializeObject

        public override ISqlObject DeserializeObject(Stream stream)
        {
            var reader = new BinaryReader(stream);

            var type = reader.ReadByte();

            if (type == 1) {
                var state = reader.ReadByte();
                if (state == 0)
                    return SqlDayToSecond.Null;

                var length = reader.ReadInt32();
                var bytes = reader.ReadBytes(length);
                return new SqlDayToSecond(bytes);
            }
            if (type == 2) {
                var state = reader.ReadByte();
                if (state == 0)
                    return SqlYearToMonth.Null;

                var months = reader.ReadInt32();
                return new SqlYearToMonth(months);
            }

            return base.DeserializeObject(stream);
        }
开发者ID:deveel,项目名称:deveeldb,代码行数:26,代码来源:IntervalType.cs

示例15: UOExtPacket

        public void UOExtPacket(IClientPeer peer, byte header, byte[] buffer, int offset, short length)
        {
            MemoryStream ms = new MemoryStream(buffer, offset, length);
            BinaryReader br = new BinaryReader(ms);

            byte sequence = br.ReadByte();

            switch (sequence)
            {
                case (0x00):
                    byte version = br.ReadByte();
                    byte[] uoextmd5 = br.ReadBytes(16);
                    byte[] uoextguimd5 = br.ReadBytes(16);
                    if (version != 0)
                    {
                        peer.Close();
                    }
                    else
                    {

                        if (!ByteArrayCompare(uoextmd5, Dll.UOExt.MD5))
                        {
                            peer.Send(new Handshake(0x01));
                            peer.Send(Dll.UOExt.SimpleHeader);
                            foreach (DllContent dc in Dll.UOExt.Content)
                            {
                                peer.Send(dc);
                            }
                            return;
                        }
                        else if (!ByteArrayCompare(uoextguimd5, Dll.UOExtGUI.MD5))
                        {
                            peer.Send(new Handshake(0x02));
                            peer.Send(Dll.UOExtGUI.SimpleHeader);
                            foreach (DllContent dc in Dll.UOExtGUI.Content)
                            {
                                peer.Send(dc);
                            }
                        }
                        else
                        {
                            peer.Send(new Handshake(0x00));
                        }
                        peer.Send(m_libraryList);
                        peer.Send(m_pluginsList);
                    }
                    break;
                case (0x03):
                    for (short i = 0; i < Dll.Dlls.Length; i++)
                    {
                        peer.Send(Dll.Dlls[i].Header);
                        foreach (DllContent dc in Dll.Dlls[i].Content)
                        {
                            peer.Send(dc);
                        }
                    }
                    peer.Send(m_initComplete);
                    break;
            }
        }
开发者ID:WildGenie,项目名称:uo-ext,代码行数:60,代码来源:Core.cs


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