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


C# Stream.ReadByte方法代码示例

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


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

示例1: Match

        public static long[] Match(Stream source, byte[] pattern, int[] next)
        {
            var result = new List<long>();
            int i = 0, k = 0;
            int currentData = source.ReadByte();
            while (i < source.Length && k < pattern.Length)
            {
                if (k == -1 || currentData == pattern[k])
                {
                    ++i;
                    ++k;
                    currentData = source.ReadByte();
                }
                else
                {
                    k = next[k];
                }

                if (k == pattern.Length)
                {
                    result.Add(i - pattern.Length);
                    k = 0;
                }
            }
            return result.ToArray();
        }
开发者ID:romhackingvn,项目名称:Alpha-Translation,代码行数:26,代码来源:KMP.cs

示例2: Decompress

        /// <summary>
        /// Decompress (if needed) the given stream.
        /// </summary>
        private static Stream Decompress(Stream stream)
        {
            if (stream.Length > 2)
            {
                var id1 = stream.ReadByte();
                var id2 = stream.ReadByte();
                stream.Position -= 2;

                if ((id1 == 0x1F) && (id2 == 0x8B))
                {
                    // GZIP compressed
                    var memStream = new MemoryStream();
                    using (var gzipStream = new GZipStream(stream, CompressionMode.Decompress))
                    {
                        var buffer = new byte[64 * 1024];
                        int len;
                        while ((len = gzipStream.Read(buffer, 0, buffer.Length)) > 0)
                        {
                            memStream.Write(buffer, 0, len);
                        }
                    }
                    memStream.Position = 0;
                    return memStream;
                }
            }

            return stream;
        }
开发者ID:Xtremrules,项目名称:dot42,代码行数:31,代码来源:CompressedXml.cs

示例3: Read

 public override ImageData Read(Stream stream, ImageMetaData info)
 {
     var pixels = new byte[info.Width*info.Height*4];
     stream.Position = 0x18;
     int dst = 0;
     for (uint y = 0; y < info.Height; ++y)
     {
         while (dst < pixels.Length)
         {
             int a = stream.ReadByte();
             if (-1 == a)
                 throw new EndOfStreamException();
             else if (0 == a)
             {
                 int count = stream.ReadByte();
                 if (-1 == count)
                     throw new EndOfStreamException();
                 else if (0 == count)
                     break;
                 dst += count * 4;
             }
             else
             {
                 stream.Read (pixels, dst, 3);
                 pixels[dst + 3] = (byte)a;
                 dst += 4;
             }
         }
     }
     return ImageData.Create (info, PixelFormats.Bgra32, null, pixels);
 }
开发者ID:Casidi,项目名称:GARbro,代码行数:31,代码来源:ImageANT.cs

示例4: MoveStream

 private static Stream MoveStream(Stream stream)
 {
     // HACK: we need this to get the DeflateStream to read properly
     stream.ReadByte();
     stream.ReadByte();
     return stream;
 }
开发者ID:kthompson,项目名称:shard,代码行数:7,代码来源:CompressionStream.cs

示例5: ReadFromStream

        /// <summary>
        /// </summary>
        /// <param name="stream">
        /// </param>
        /// <returns>
        /// </returns>
        public static StatelData ReadFromStream(Stream stream)
        {
            StatelData statel = new StatelData();
            FlatIdentity fi = new FlatIdentity();
            fi.ReadFromStream(stream);
            statel.StatelIdentity = fi.Id;

            // Skip 4, is always 1?
            stream.ReadByte();
            stream.ReadByte();
            stream.ReadByte();
            stream.ReadByte();
            PFCoordHeading pfc = new PFCoordHeading();
            pfc.ReadFromStream(stream);

            statel.X = pfc.Coordinate.X;
            statel.Y = pfc.Coordinate.Y;
            statel.Z = pfc.Coordinate.Z;

            statel.HeadingX = pfc.Heading.X;
            statel.HeadingY = pfc.Heading.Y;
            statel.HeadingZ = pfc.Heading.Z;
            statel.HeadingW = pfc.Heading.W;

            statel.PlayfieldId = pfc.PlayfieldIdentity;

            BinaryReader br = new BinaryReader(stream);
            br.ReadInt32();
            statel.TemplateId = br.ReadInt32();
            int len2 = br.ReadInt32();
            byte[] HighLow = br.ReadBytes(len2);
            MemoryStream ms = new MemoryStream(HighLow);

            BinaryReader br2 = new BinaryReader(ms);
            br2.ReadBytes(8);
            int C1 = IPAddress.NetworkToHostOrder(br2.ReadInt32());
            Debug.Assert(C1 % 0x3f1 == 0, "Wrong 3f1 encountered... stop please");

            int evcount = IPAddress.NetworkToHostOrder(br2.ReadInt32());
            while (evcount > 0)
            {
                int dataType = IPAddress.NetworkToHostOrder(br2.ReadInt32());
                switch (dataType)
                {
                    case 2:
                        HLFlatEvent flatEvent = new HLFlatEvent();
                        flatEvent.ReadFromStream(ms);
                        statel.Events.Add(flatEvent.ToEvents());
                        break;
                    default:

                        // Console.WriteLine("DataType " + dataType + " found... stop please");
                        break;
                }

                evcount--;
            }

            return statel;
        }
开发者ID:gordonc64,项目名称:CellAO.Tools,代码行数:66,代码来源:StatelDataExtractor.cs

示例6: Parse

        public static RequestLine Parse(Stream stream)
        {
            int b = stream.ReadByte();
            while (b == CR || b == LF)
            {
                b = stream.ReadByte();
            }

            var bytes = new LinkedList<byte>();
            bytes.AddLast((byte)b);

            while (true)
            {
                b = stream.ReadByte();
                if (b == CR || b < 0)
                {
                    stream.ReadByte();
                    break;
                }
                bytes.AddLast((byte)b);
            }

            var text = Encoding.Default.GetString(bytes.ToArray());
            var parts = text.Split(' ');

            if (parts.Length == 3)
            {
                return new RequestLine(parts[0], parts[1], parts[2]);
            }

            throw new InvalidRequestException("Invalid Request Line.");
        }
开发者ID:bajtos,项目名称:Nowin,代码行数:32,代码来源:RequestLineParser.cs

示例7: Inflate

        /// <summary>
        /// Inflate the token
        /// NOTE: This operation is not continuable and assumes that the entire token is available in the stream
        /// </summary>
        /// <param name="source">Stream to inflate the token from</param>
        /// <returns>TRUE if inflation is complete</returns>
        public virtual bool Inflate(Stream source)
        {
            // Read column number
            Number = (byte)source.ReadByte();

            // Update offset with the read size
            InflationSize += sizeof(byte);

            // Read table number
            TableNumber = (byte)source.ReadByte();

            // Update offset with the read size
            InflationSize += sizeof(byte);

            // Read status
            Status = (TDSColumnStatus)source.ReadByte();

            // Update offset with the read size
            InflationSize += sizeof(byte);

            // Check if status indicates the table name
            if ((Status & TDSColumnStatus.DifferentName) != 0)
            {
                // Read the length of the table name
                byte tableNameLength = (byte)source.ReadByte();

                // Read table name
                Name = TDSUtilities.ReadString(source, (ushort)(tableNameLength * 2));
            }

            return true;
        }
开发者ID:dotnet,项目名称:corefx,代码行数:38,代码来源:TDSColumnProperty.cs

示例8: LogMessageAttributes

 public LogMessageAttributes(Stream stream)
 {
     Classification = (MessageClass)stream.ReadByte();
     Level = (MessageLevel)stream.ReadByte();
     MessageSuppression = (MessageSuppression)stream.ReadByte();
     Flags = (MessageFlags)stream.ReadByte();
 }
开发者ID:GridProtectionAlliance,项目名称:gsf,代码行数:7,代码来源:LogMessageAttributes.cs

示例9: ReadNextString

 private string ReadNextString(Stream reader, char marker)
 {
     StringBuilder sbuild = new StringBuilder();
     int i = reader.ReadByte();
     while (true)
     {
         if (i == -1 || i == marker)
             break;
         else if (i == '/')
         {
             i = reader.ReadByte();
             if (i == '/')
             {
                 do { i = reader.ReadByte(); } while (i != '\n' && i != -1);
                 i = reader.ReadByte();
             }
             else
                 sbuild.Append('/');
         }
         else
         {
             sbuild.Append((char)i);
             i = reader.ReadByte();
         }       
     }
     return sbuild.ToString();
 }
开发者ID:eriser,项目名称:Cross-Platform-Csharp-Synth-with-OpenAL,代码行数:27,代码来源:SfzReader.cs

示例10: IndefiniteLengthInputStream

 internal IndefiniteLengthInputStream(
     Stream inStream)
     : base(inStream)
 {
     _b1 = inStream.ReadByte();
     _b2 = inStream.ReadByte();
     _eofReached = (_b2 < 0);
 }
开发者ID:hjgode,项目名称:iTextSharpCF,代码行数:8,代码来源:IndefiniteLengthInputStream.cs

示例11: Read

 public static EulaVersion Read(Stream s)
 {
     var eula = new EulaVersion
     {
         Minor = (byte) s.ReadByte(),
         Major = (byte) s.ReadByte()
     };
     return eula;
 }
开发者ID:usagirei,项目名称:3DS-Theme-Editor,代码行数:9,代码来源:EulaVersion.cs

示例12: FromStream

 public static PTableHeader FromStream(Stream stream)
 {
     var type = stream.ReadByte();
     if (type != (int) FileType.PTableFile)
         throw new CorruptIndexException("Corrupted PTable.", new InvalidFileException("Wrong type of PTable."));
     var version = stream.ReadByte();
     if (version == -1)
         throw new CorruptIndexException("Couldn't read version of PTable from header.", new InvalidFileException("Invalid PTable file."));
     return new PTableHeader((byte)version);
 }
开发者ID:thinkbeforecoding,项目名称:EventStore,代码行数:10,代码来源:PTableHeader.cs

示例13: ToInt32

 public static int ToInt32(Stream stream, bool littleEndian)
 {
     return
         ToInt32(
             new[]
             {
                 (byte) stream.ReadByte(), (byte) stream.ReadByte(), (byte) stream.ReadByte(),
                 (byte) stream.ReadByte()
             }, 0, littleEndian);
 }
开发者ID:pharmadata,项目名称:tps-parse-net,代码行数:10,代码来源:BitUtil.cs

示例14: LoadBlockData

 protected override void LoadBlockData(Map map, Stream stream) {
     for (int i = 0; i < map.Volume; i++) {
         map.Blocks[i] = (byte)stream.ReadByte();
         int msb = stream.ReadByte();
         if (msb == 1) {
             map.Blocks[i] = ReduxExtraMapping[map.Blocks[i]];
         }
     }
     map.ConvertBlockTypes(MCSharpMapping);
 }
开发者ID:fragmer,项目名称:fCraft,代码行数:10,代码来源:MapMCF.cs

示例15: Read

        public Id3v2Tag Read(Stream mp3Stream)
        {
            Id3v2Tag tag;

            byte[] b = new byte[3];

            mp3Stream.Read(b, 0, b.Length);
            mp3Stream.Seek(0, SeekOrigin.Begin);

            string ID3 = new string(System.Text.Encoding.ASCII.GetChars(b));

            if (ID3 != "ID3") {
                throw new CannotReadException("Not an ID3 tag");
            }
            //Begins tag parsing ---------------------------------------------
            mp3Stream.Seek(3, SeekOrigin.Begin);
            //----------------------------------------------------------------------------
            //Version du tag ID3v2.xx.xx
            string versionHigh=mp3Stream.ReadByte() +"";
            string versionID3 =versionHigh+ "." + mp3Stream.ReadByte();
            //------------------------------------------------------------------------- ---
            //D?tection de certains flags (A COMPLETER)
            this.ID3Flags = ProcessID3Flags( (byte) mp3Stream.ReadByte() );
            //----------------------------------------------------------------------------

            //			On extrait la taille du tag ID3
            int tagSize = ReadSyncsafeInteger(mp3Stream);
            //System.err.println("TagSize: "+tagSize);

            //			------------------NEWNEWNWENENEWNENWEWN-------------------------------
            //Fill a byte buffer, then process according to correct version
            b = new byte[tagSize+2];
            mp3Stream.Read(b, 0, b.Length);
            ByteBuffer bb = new ByteBuffer(b);

            if (ID3Flags[0]==true) {
                //We have unsynchronization, first re-synchronize
                bb = synchronizer.synchronize(bb);
            }

            if(versionHigh == "2") {
                tag = v23.Read(bb, ID3Flags, Id3v2Tag.ID3V22);
            }
            else if(versionHigh == "3") {
                tag = v23.Read(bb, ID3Flags, Id3v2Tag.ID3V23);
            }
            else if(versionHigh == "4") {
                throw new CannotReadException("ID3v2 tag version "+ versionID3 + " not supported !");
            }
            else {
                throw new CannotReadException("ID3v2 tag version "+ versionID3 + " not supported !");
            }

            return tag;
        }
开发者ID:BackupTheBerlios,项目名称:monopod-svn,代码行数:55,代码来源:Id3v2TagReader.cs


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