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


C# EndianBinaryReader.ReadBytes方法代码示例

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


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

示例1: Update

        public bool Update()
        {
            var bitStream = downloader.DownloadStream;
            var reader = new EndianBinaryReader(EndianBitConverter.Big, bitStream);

            if(bitStream != null)
            {
                var stream = new StreamReader(bitStream);
                {
                    reader.ReadBytes(3); //"FLV"
                    reader.ReadBytes(6); //Other starter shit

                    while (true)
                    {
                        try
                        {
                            var footer = reader.ReadUInt32();
                            var tag = new FlvTag();
                            tag.Load(reader);

                            AddedTag(tag);

                        }
                        catch (Exception)
                        {
                            reader.Close();
                            //End of stream
                            return false;
                        }
                    }
                }
            }

            return true;
        }
开发者ID:Austech,项目名称:RTMP-CSharp,代码行数:35,代码来源:VideoClient.cs

示例2: ConvertOgg

        public static Stream ConvertOgg(string inputFile)
        {
            if (needsConversion(inputFile))
            {
                var platform = getPlatform(inputFile);
                EndianBitConverter bitConverter = platform.GetBitConverter();

                using (var outputFileStream = new MemoryStream())
                using (var inputFileStream = File.Open(inputFile, FileMode.Open))
                using (var writer = new EndianBinaryWriter(bitConverter, outputFileStream))
                using (var reader = new EndianBinaryReader(bitConverter, inputFileStream))
                {
                    writer.Write(reader.ReadBytes(4));
                    UInt32 fileSize = reader.ReadUInt32();
                    fileSize -= 8; // We're removing data, so update the size in the header
                    writer.Write(fileSize);
                    writer.Write(reader.ReadBytes(8));
                    writer.Write(66); reader.ReadUInt32(); // New fmt size is 66
                    writer.Write(reader.ReadBytes(16));
                    writer.Write((ushort)48); reader.ReadUInt16(); // New cbSize is 48
                    writer.Write(reader.ReadBytes(6));
                    reader.BaseStream.Seek(8, SeekOrigin.Current); // Skip ahead 8 bytes, we don't want the vorb chunk
                    writer.Write(reader.ReadBytes((int)reader.BaseStream.Length - (int)reader.BaseStream.Position));

                    return new MemoryStream(outputFileStream.GetBuffer(), 0, (int)outputFileStream.Length);
                }
            }

            return File.OpenRead(inputFile);
        }
开发者ID:joshsten,项目名称:rocksmith-custom-song-toolkit,代码行数:30,代码来源:OggFile.cs

示例3: readAmfFile

        private AmfFile readAmfFile(EndianBinaryReader reader)
        {
            validateFile(reader);

            ushort width = BitConverter.ToUInt16(reader.ReadBytes(2), 0);
            debugLine("width: " + width);
            ushort height = BitConverter.ToUInt16(reader.ReadBytes(2), 0);
            debugLine("width: " + height);
            AmfFile file = new AmfFile(width, height);
            readPixels(reader, width, height, file);

            return file;
        }
开发者ID:Celludriel,项目名称:L3DT_Filemanager,代码行数:13,代码来源:AmfManager.cs

示例4: readDmfFile

        private DmfFile readDmfFile(EndianBinaryReader reader)
        {
            validateFile(reader);

            ushort width = BitConverter.ToUInt16(reader.ReadBytes(2), 0);
            debugLine("width: " + width);
            ushort height = BitConverter.ToUInt16(reader.ReadBytes(2), 0);
            debugLine("width: " + height);
            byte wrapFlag = reader.ReadByte();
            DmfFile file = new DmfFile(width, height, wrapFlag == 1 ? true : false);
            readPixels(reader, width, height, file);
            return file;
        }
开发者ID:Celludriel,项目名称:L3DT_Filemanager,代码行数:13,代码来源:DmfManager.cs

示例5: Load

 public void Load(MemoryStream memory)
 {
     var reader = new EndianBinaryReader(EndianBitConverter.Big, memory);
     switch (Format)
     {
         case BasicHeader.HeaderFormats.F0: //11 bytes
             {
                 var timeStampByte = new byte[4] {0x00, reader.ReadByte(), reader.ReadByte(), reader.ReadByte()};
                 TimeStamp = EndianBitConverter.Big.ToInt32(timeStampByte, 0);
                 var lengthByte = new byte[4] {0x00, reader.ReadByte(), reader.ReadByte(), reader.ReadByte()};
                 MessageLength = EndianBitConverter.Big.ToInt32(lengthByte, 0);
                 MessageType = reader.ReadByte();
                 var messageStreamBytes = reader.ReadBytes(4);
                 MessageStreamId = EndianBitConverter.Little.ToInt32(messageStreamBytes, 0);
             }
             break;
         case BasicHeader.HeaderFormats.F1: //7 bytes
             {
                 var timeStampByte = new byte[4] {0x00, reader.ReadByte(), reader.ReadByte(), reader.ReadByte()};
                 TimeStamp = EndianBitConverter.Big.ToInt32(timeStampByte, 0);
                 var lengthByte = new byte[4] {0x00, reader.ReadByte(), reader.ReadByte(), reader.ReadByte()};
                 MessageLength = EndianBitConverter.Big.ToInt32(lengthByte, 0);
                 MessageType = reader.ReadByte();
             }
             break;
         case BasicHeader.HeaderFormats.F2: //3 bytes
             {
                 var timeStampByte = new byte[4] {0x00, reader.ReadByte(), reader.ReadByte(), reader.ReadByte()};
                 TimeStamp = EndianBitConverter.Big.ToInt32(timeStampByte, 0);
             }
             break;
         case BasicHeader.HeaderFormats.F3: //No bytes
             break;
     }
 }
开发者ID:Austech,项目名称:RtmpSharp2,代码行数:35,代码来源:MessageHeader.cs

示例6: read

		public void read(EndianBinaryReader r) {
			Solo = r.ReadByte();
			Disparity = r.ReadByte();
			Ignore = r.ReadByte();
			Padding = r.ReadByte();
			MaxDifficulty = r.ReadInt32();
			PhraseIterationLinks = r.ReadInt32();
			Name = r.ReadBytes(32);
		}
开发者ID:aequitas,项目名称:rocksmith-custom-song-toolkit,代码行数:9,代码来源:Sng2014HSL.cs

示例7: LoadData

 private void LoadData(Stream inStream)
 {
     var converter = new BigEndianBitConverter();
     using (var endianReader = new EndianBinaryReader(converter, inStream))
     {
         Destination = new I2PDestination(endianReader);
         PrivateKey = endianReader.ReadBytesOrThrow(PrivateKeyLength);
         SigningPrivateKey = endianReader.ReadBytes(8192); //enough i think
     }
 }
开发者ID:z0rg1nc,项目名称:SamHelperLib,代码行数:10,代码来源:SamHelper.cs

示例8: FromByteArray

 public void FromByteArray(ref byte[] datagram)
 {
     using (MemoryStream buffer = new MemoryStream(datagram))
     {
         using (EndianBinaryReader br = new EndianBinaryReader(new LittleEndianBitConverter(), buffer))
         {
             action = br.ReadInt32();
             transaction_id = br.ReadInt32();
             error = Encoding.UTF8.GetString(br.ReadBytes(datagram.Length - 8));
         }
     }
 }
开发者ID:Dozey,项目名称:Distribution2,代码行数:12,代码来源:UdpErrorResponsePacket.cs

示例9: STAG

 public STAG(EndianBinaryReader er)
 {
     Signature = er.ReadString(Encoding.ASCII, 4);
     if (Signature != "STAG") throw new SignatureNotCorrectException(Signature, "STAG", er.BaseStream.Position - 4);
     Unknown1 = er.ReadUInt16();
     NrLaps = er.ReadInt16();
     Unknown2 = er.ReadByte();
     FogEnabled = er.ReadByte() == 1;
     FogTableGenMode = er.ReadByte();
     FogSlope = er.ReadByte();
     UnknownData1 = er.ReadBytes(0x8);
     FogDensity = er.ReadFx32();
     FogColor = Color.FromArgb((int)GFXUtil.ConvertColorFormat(er.ReadUInt16(), ColorFormat.XBGR1555, ColorFormat.ARGB8888));
     FogAlpha = er.ReadUInt16();
     KclColor1 = Color.FromArgb((int)GFXUtil.ConvertColorFormat(er.ReadUInt16(), ColorFormat.XBGR1555, ColorFormat.ARGB8888));
     KclColor2 = Color.FromArgb((int)GFXUtil.ConvertColorFormat(er.ReadUInt16(), ColorFormat.XBGR1555, ColorFormat.ARGB8888));
     KclColor3 = Color.FromArgb((int)GFXUtil.ConvertColorFormat(er.ReadUInt16(), ColorFormat.XBGR1555, ColorFormat.ARGB8888));
     KclColor4 = Color.FromArgb((int)GFXUtil.ConvertColorFormat(er.ReadUInt16(), ColorFormat.XBGR1555, ColorFormat.ARGB8888));
     FrustumFar = er.ReadFx32();
     UnknownData2 = er.ReadBytes(0x4);
 }
开发者ID:Ermelber,项目名称:EveryFileExplorer,代码行数:21,代码来源:STAG.cs

示例10: Read

        internal static HandshakeMessage Read(TlsState state, byte[] body)
        {
            using (var stream = new MemoryStream(body))
            {
                var reader = new EndianBinaryReader(EndianBitConverter.Big, stream);

                var version = reader.ReadVersion();
                var randomBytes = reader.ReadBytes(32);
                var sessionId = reader.ReadBytesVariable(1, 0, 32);

                var cipherSuites = reader.ReadUInt16Variable<CipherSuite>(2, 2, 0xFFFE);
                var compressionMethods = reader.ReadBytesVariable<CompressionMethod>(1, 1, 0xFF).ToArray();

                var extensions = new List<HelloExtension>();

                // extensions don't have to be included
                if (stream.Length != stream.Position)
                {
                    var extsLength = reader.ReadUInt16();

                    while (extsLength > 0)
                    {
                        extsLength -= 4;

                        var extType = reader.ReadUInt16();
                        var extLength = reader.ReadUInt16();
                        extsLength -= extLength;

                        var extBuffer = reader.ReadBytes(extLength);

                        extensions.Add(new HelloExtension(extType, extBuffer));
                    }
                }

                return new ClientHelloMessage(version, randomBytes, sessionId, extensions.ToArray(), cipherSuites, compressionMethods);
            }
        }
开发者ID:will14smith,项目名称:Crypto,代码行数:37,代码来源:ClientHelloMessage.cs

示例11: FromByteArray

        public void FromByteArray(ref byte[] datagram)
        {
            using (MemoryStream buffer = new MemoryStream(datagram))
            {
                using (EndianBinaryReader br = new EndianBinaryReader(new BigEndianBitConverter(), buffer))
                {
                    action = br.ReadInt32();
                    transaction_id = br.ReadInt32();
                    interval = br.ReadInt32();
                    leechers = br.ReadInt32();
                    seeders = br.ReadInt32();

                    peers = new UdpPeer[((datagram.Length - 20) / 6)];

                    for (int i = 0; i < peers.Length; i++)
                        peers[i] = new UdpPeer(new IPAddress(br.ReadBytes(4)), br.ReadUInt16());
                }
            }
        }
开发者ID:Dozey,项目名称:Distribution2,代码行数:19,代码来源:UdpAnnounceResponsePacket.cs

示例12: Update

        public virtual void Update()
        {
            if (CanReceiveData())
            {
                var data = ReceivedData();
                var memory = new MemoryStream(data);
                var reader = new EndianBinaryReader(EndianBitConverter.Big, memory);

                while (memory.Position < memory.Length)
                {
                    switch (CurrentState)
                    {
                        case ClientStates.Handshake_WaitForS0:
                            {
                                reader.ReadByte();
                                CurrentState = ClientStates.Handshake_WaitForS1;
                            }
                            break;
                            case ClientStates.Handshake_WaitForS1:
                            {
                                var s1Chunk = reader.ReadBytes(Globals.Handshake_Length);
                                SendData(Handshake.GenerateC2(s1Chunk));
                                CurrentState = ClientStates.Handshake_WaitForS2;
                            }
                            break;
                            case ClientStates.Handshake_WaitForS2:
                            {
                                var s2Chunk = reader.ReadBytes(Globals.Handshake_Length);
                                CurrentState = ClientStates.Handshake_Done;
                            }
                            break;
                            case ClientStates.Handshake_Done:
                            {
                                var chunk = new Chunk();
                                chunk.Load(memory);
                                ParseChunk(chunk);
                            }
                            break;
                    }
                }
            }
        }
开发者ID:Austech,项目名称:RtmpSharp2,代码行数:42,代码来源:ClientBase.cs

示例13: Read

        public HandshakeMessage Read(Record record)
        {
            SecurityAssert.SAssert(record.Type == RecordType.Handshake);

            using (var ms = new MemoryStream(record.Data))
            {
                var msReader = new EndianBinaryReader(EndianBitConverter.Big, ms);

                var type = msReader.ReadHandshakeType();
                var length = msReader.ReadUInt24();

                if (record.Length - 4 < length) { throw new NotImplementedException("Record fragmentation"); }

                var body = msReader.ReadBytes((int)length);
                
                UpdateVerify(type, length, body);

                return Read(type, body);
            }
        }
开发者ID:will14smith,项目名称:Crypto,代码行数:20,代码来源:HandshakeReader.cs

示例14: PaletteFile

        public PaletteFile(string filename)
        {
            EndianBinaryReader reader = new EndianBinaryReader(EndianBitConverter.Big, File.Open(filename, FileMode.Open));

            while (true)
            {
                int blockLength = 0;
                PaletteBlockType blockType = (PaletteBlockType)reader.ReadInt32();
                blockLength = reader.ReadInt32();

                switch (blockType)
                {
                    case PaletteBlockType.Attributes:

                        //contains name of palette and some attributes
                        //we dont care about this
                        reader.Seek(blockLength, SeekOrigin.Current);
                        break;

                    case PaletteBlockType.PixelData:
                        int entryCount = reader.ReadInt32();
                        int bytesPerEntry = reader.ReadInt32();
                        _paletteData = reader.ReadBytes(entryCount * bytesPerEntry);

                        break;

                    case PaletteBlockType.Null:
                        break;

                    default:
                        reader.Seek(blockLength, SeekOrigin.Current);
                        break;
                }
                if (reader.BaseStream.Position == reader.BaseStream.Length)
                    break;
            }

            reader.Close();
        }
开发者ID:sikora507,项目名称:OpenC1,代码行数:39,代码来源:PaletteFile.cs

示例15: Load

        public void Load(Stream stream)
        {
            var reader = new EndianBinaryReader(EndianBitConverter.Big, stream);

            //Header
            reader.ReadBytes(3); // "FLV"
            Version = reader.ReadByte();
            Bitmask = (BitmaskTypes) reader.ReadByte();
            HeaderSize = reader.ReadUInt32();

            //Start reading tags
            while(stream.Position < stream.Length)
            {
                var footer = reader.ReadUInt32();
                if(stream.Position >= stream.Length)
                {
                    break;
                }
                var tag = new FlvTag();

                tag.Load(reader);
                Tags.Add(tag);
            }
        }
开发者ID:Austech,项目名称:RTMP-CSharp,代码行数:24,代码来源:Flv.cs


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