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


C# Stream.ReadAll方法代码示例

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


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

示例1: LoadFromStream

        public void LoadFromStream(Stream stream)
        {
            int lengthToFill = (int)(stream.Length - stream.Position);

            while (m_buffer.Data.Length < lengthToFill)
               m_buffer.Grow();

            m_buffer.Position = 0;
            m_length = lengthToFill;
            stream.ReadAll(m_buffer.Data, 0, lengthToFill);

            Reset();
        }
开发者ID:GridProtectionAlliance,项目名称:gsf,代码行数:13,代码来源:MeasurementStreamFileReading.cs

示例2: Read

 private void Read(Stream stream)
 {
     byte[] bytes = new byte[9];
     stream.ReadAll(bytes, 0, bytes.Length);
     Left = BitConverter.ToUInt16(bytes, 0);
     Top = BitConverter.ToUInt16(bytes, 2);
     Width = BitConverter.ToUInt16(bytes, 4);
     Height = BitConverter.ToUInt16(bytes, 6);
     byte packedFields = bytes[8];
     HasLocalColorTable = (packedFields & 0x80) != 0;
     Interlace = (packedFields & 0x40) != 0;
     IsLocalColorTableSorted = (packedFields & 0x20) != 0;
     LocalColorTableSize = 1 << ((packedFields & 0x07) + 1);
 }
开发者ID:danieldeb,项目名称:WpfAnimatedGif,代码行数:14,代码来源:GifImageDescriptor.cs

示例3: ReadColorTable

 public static GifColor[] ReadColorTable(Stream stream, int size)
 {
     int length = 3 * size;
     byte[] bytes = new byte[length];
     stream.ReadAll(bytes, 0, length);
     GifColor[] colorTable = new GifColor[size];
     for (int i = 0; i < size; i++)
     {
         byte r = bytes[3 * i];
         byte g = bytes[3 * i + 1];
         byte b = bytes[3 * i + 2];
         colorTable[i] = new GifColor(r, g, b);
     }
     return colorTable;
 }
开发者ID:danieldeb,项目名称:WpfAnimatedGif,代码行数:15,代码来源:GifHelpers.cs

示例4: ReadColorTable

 public static GifColor[] ReadColorTable(Stream stream, int size)
 {
     var length = 3*size;
     var bytes = new byte[length];
     stream.ReadAll(bytes, 0, length);
     var colorTable = new GifColor[size];
     for (var i = 0; i < size; i++)
     {
         var r = bytes[3*i];
         var g = bytes[3*i + 1];
         var b = bytes[3*i + 2];
         colorTable[i] = new GifColor(r, g, b);
     }
     return colorTable;
 }
开发者ID:x-skywalker,项目名称:CodeMask,代码行数:15,代码来源:GifHelpers.cs

示例5: Read

        private void Read(Stream stream)
        {
            // Note: at this point, the label (0xFF) has already been read

            byte[] bytes = new byte[12];
            stream.ReadAll(bytes, 0, bytes.Length);
            BlockSize = bytes[0]; // should always be 11
            if (BlockSize != 11)
                throw GifHelpers.InvalidBlockSizeException("Application Extension", 11, BlockSize);

            ApplicationIdentifier = Encoding.ASCII.GetString(bytes, 1, 8);
            byte[] authCode = new byte[3];
            Array.Copy(bytes, 9, authCode, 0, 3);
            AuthenticationCode = authCode;
            Data = GifHelpers.ReadDataBlocks(stream, false);
        }
开发者ID:danieldeb,项目名称:WpfAnimatedGif,代码行数:16,代码来源:GifApplicationExtension.cs

示例6: Read

        private void Read(Stream stream)
        {
            // Note: at this point, the label (0xF9) has already been read

            byte[] bytes = new byte[6];
            stream.ReadAll(bytes, 0, bytes.Length);
            BlockSize = bytes[0]; // should always be 4
            if (BlockSize != 4)
                throw GifHelpers.InvalidBlockSizeException("Graphic Control Extension", 4, BlockSize);
            byte packedFields = bytes[1];
            DisposalMethod = (packedFields & 0x1C) >> 2;
            UserInput = (packedFields & 0x02) != 0;
            HasTransparency = (packedFields & 0x01) != 0;
            Delay = BitConverter.ToUInt16(bytes, 2) * 10; // milliseconds
            TransparencyIndex = bytes[4];
        }
开发者ID:danieldeb,项目名称:WpfAnimatedGif,代码行数:16,代码来源:GifGraphicControlExtension.cs

示例7: Load

        public virtual void Load(Stream FileStream)
        {
            FileStream = new MemoryStream(FileStream.ReadAll());

            this.FileStream = FileStream;

            this.Header = FileStream.ReadStruct<Elf.HeaderStruct>();
            if (this.Header.Magic != Elf.HeaderStruct.MagicEnum.ExpectedValue)
            {
                throw(new InvalidProgramException("Not an ELF File"));
            }

            if (this.Header.Machine != Elf.HeaderStruct.MachineEnum.ALLEGREX)
            {
                throw (new InvalidProgramException("Invalid Elf.Header.Machine"));
            }

            this.ProgramHeaders = FileStream.ReadStructVectorAt<Elf.ProgramHeader>(Header.ProgramHeaderOffset, Header.ProgramHeaderCount, Header.ProgramHeaderEntrySize);
            this.SectionHeaders = FileStream.ReadStructVectorAt<Elf.SectionHeader>(Header.SectionHeaderOffset, Header.SectionHeaderCount, Header.SectionHeaderEntrySize);

            this.NamesSectionHeader = this.SectionHeaders[Header.SectionHeaderStringTable];
            this.StringTable = FileStream.SliceWithLength(this.NamesSectionHeader.Offset, this.NamesSectionHeader.Size).ReadAll();

            this.SectionHeadersByName = new Dictionary<string, Elf.SectionHeader>();
            foreach (var SectionHeader in this.SectionHeaders)
            {
                var SectionHeaderName = GetStringFromStringTable(SectionHeader.Name);
                this.SectionHeadersByName[SectionHeaderName] = SectionHeader;
            }

            Console.WriteLine("ProgramHeaders:{0}", this.ProgramHeaders.Length);
            foreach (var ProgramHeader in ProgramHeaders)
            {
                Console.WriteLine("{0}", ProgramHeader.ToStringDefault());
            }

            Console.WriteLine("SectionHeaders:{0}", this.SectionHeaders.Length);
            foreach (var SectionHeader in SectionHeaders)
            {
                Console.WriteLine("{0}:{1}", GetStringFromStringTable(SectionHeader.Name), SectionHeader.ToStringDefault());
            }

            if (NeedsRelocation && this.ProgramHeaders.Length > 1)
            {
                //throw (new NotImplementedException("Not implemented several ProgramHeaders yet using relocation"));
            }
        }
开发者ID:mrcmunir,项目名称:cspspemu,代码行数:47,代码来源:ElfLoader.cs

示例8: ReadDataBlocks

 public static byte[] ReadDataBlocks(Stream stream, bool discard)
 {
     MemoryStream ms = discard ? null : new MemoryStream();
     using (ms)
     {
         int len;
         while ((len = stream.ReadByte()) > 0)
         {
             byte[] bytes = new byte[len];
             stream.ReadAll(bytes, 0, len);
             if (ms != null)
                 ms.Write(bytes, 0, len);
         }
         if (ms != null)
             return ms.ToArray();
         return null;
     }
 }
开发者ID:danieldeb,项目名称:WpfAnimatedGif,代码行数:18,代码来源:GifHelpers.cs

示例9: Read

        private void Read(Stream stream)
        {
            byte[] bytes = new byte[7];
            stream.ReadAll(bytes, 0, bytes.Length);

            Width = BitConverter.ToUInt16(bytes, 0);
            Height = BitConverter.ToUInt16(bytes, 2);
            byte packedFields = bytes[4];
            HasGlobalColorTable = (packedFields & 0x80) != 0;
            ColorResolution = ((packedFields & 0x70) >> 4) + 1;
            IsGlobalColorTableSorted = (packedFields & 0x08) != 0;
            GlobalColorTableSize = 1 << ((packedFields & 0x07) + 1);
            BackgroundColorIndex = bytes[5];
            PixelAspectRatio =
                bytes[5] == 0
                    ? 0.0
                    : (15 + bytes[5]) / 64.0;
        }
开发者ID:eric-seekas,项目名称:ErrorControlSystem,代码行数:18,代码来源:GifLogicalScreenDescriptor.cs

示例10: Read

        private void Read(Stream stream, IEnumerable<GifExtension> controlExtensions, bool metadataOnly)
        {
            // Note: at this point, the label (0x01) has already been read

            byte[] bytes = new byte[13];
            stream.ReadAll(bytes,0, bytes.Length);

            BlockSize = bytes[0];
            if (BlockSize != 12)
                throw GifHelpers.InvalidBlockSizeException("Plain Text Extension", 12, BlockSize);

            Left = BitConverter.ToUInt16(bytes, 1);
            Top = BitConverter.ToUInt16(bytes, 3);
            Width = BitConverter.ToUInt16(bytes, 5);
            Height = BitConverter.ToUInt16(bytes, 7);
            CellWidth = bytes[9];
            CellHeight = bytes[10];
            ForegroundColorIndex = bytes[11];
            BackgroundColorIndex = bytes[12];

            var dataBytes = GifHelpers.ReadDataBlocks(stream, metadataOnly);
            Text = Encoding.ASCII.GetString(dataBytes);
            Extensions = controlExtensions.ToList().AsReadOnly();
        }
开发者ID:danieldeb,项目名称:WpfAnimatedGif,代码行数:24,代码来源:GifPlainTextExtension.cs

示例11: LoadModule

        public HleModuleGuest LoadModule(Stream FileStream, Stream MemoryStream, MemoryPartition MemoryPartition, HleModuleManager ModuleManager, String GameTitle, string ModuleName, bool IsMainModule)
        {
            this.HleModuleGuest = new HleModuleGuest(PspEmulatorContext);

            this.ElfLoader = new ElfLoader();
            this.ModuleManager = ModuleManager;

            var Magic = FileStream.SliceWithLength(0, 4).ReadString(4);
            Logger.Info("Magic: '{0}'", Magic);
            if (Magic == "~PSP")
            {
                try
                {
                    var DecryptedData = new EncryptedPrx().Decrypt(FileStream.ReadAll(), true);
                    File.WriteAllBytes("last_decoded_prx.bin", DecryptedData);
                    FileStream = new MemoryStream(DecryptedData);
                }
                catch (Exception Exception)
                {
                    Logger.Error(Exception);
                    throw (Exception);
                }
            }

            this.ElfLoader.Load(FileStream, ModuleName);

            PspEmulatorContext.PspConfig.InfoExeHasRelocation = this.ElfLoader.NeedsRelocation;

            if (this.ElfLoader.NeedsRelocation)
            {
                var DummyPartition = MemoryPartition.Allocate(
                    0x4000,
                    Name: "Dummy"
                );
                BaseAddress = MemoryPartition.ChildPartitions.OrderByDescending(Partition => Partition.Size).First().Low;
                Logger.Info("BASE ADDRESS (Try    ): 0x{0:X}", BaseAddress);
                BaseAddress = MathUtils.NextAligned(BaseAddress, 0x1000);
                Logger.Info("BASE ADDRESS (Aligned): 0x{0:X}", BaseAddress);
            }
            else
            {
                BaseAddress = 0;
            }

            PspEmulatorContext.PspConfig.RelocatedBaseAddress = BaseAddress;
            PspEmulatorContext.PspConfig.GameTitle = GameTitle;

            this.ElfLoader.AllocateAndWrite(MemoryStream, MemoryPartition, BaseAddress);

            if (this.ElfLoader.NeedsRelocation)
            {
                RelocateFromHeaders();
            }

            if (!ElfLoader.SectionHeadersByName.ContainsKey(".rodata.sceModuleInfo"))
            {
                throw(new Exception("Can't find segment '.rodata.sceModuleInfo'"));
            }

            HleModuleGuest.ModuleInfo = ElfLoader.SectionHeaderFileStream(ElfLoader.SectionHeadersByName[".rodata.sceModuleInfo"]).ReadStruct<ElfPsp.ModuleInfo>(); ;

            //Console.WriteLine(this.ModuleInfo.ToStringDefault());

            HleModuleGuest.InitInfo = new InitInfoStruct()
            {
                PC = ElfLoader.Header.EntryPoint + BaseAddress,
                GP = HleModuleGuest.ModuleInfo.GP + BaseAddress,
            };

            UpdateModuleImports();
            UpdateModuleExports();

            ModuleManager.LoadedGuestModules.Add(HleModuleGuest);

            return HleModuleGuest;
        }
开发者ID:e-COS,项目名称:cspspemu,代码行数:76,代码来源:ElfPspLoader.cs

示例12: ReadString

 public static string ReadString(Stream stream, int length)
 {
     byte[] bytes = new byte[length];
     stream.ReadAll(bytes, 0, length);
     return Encoding.ASCII.GetString(bytes);
 }
开发者ID:danieldeb,项目名称:WpfAnimatedGif,代码行数:6,代码来源:GifHelpers.cs

示例13: ReadContent

        /// <summary>
        /// Reads the content.
        /// </summary>
        /// <param name="stream">The stream.</param>
        /// <returns></returns>
        public byte[] ReadContent(Stream stream)
        {
            int? contentLength = null;
            IList<string> literalContentLength;
            if (Headers.TryGetValue("Content-Length", out literalContentLength))
            {
                int fContentLength;
                if (int.TryParse(literalContentLength.First(), out fContentLength))
                    contentLength = fContentLength;
            }

            if (!contentLength.HasValue)
            {
                using (var memoryStream = new MemoryStream())
                {
                    stream.CopyTo(memoryStream);
                    return memoryStream.ToArray();
                }
            }

            var contentBytes = new byte[contentLength.Value];
            stream.ReadAll(contentBytes, 0, contentBytes.Length);
            return contentBytes;
        }
开发者ID:systemmetaphor,项目名称:BlueDwarf,代码行数:29,代码来源:HttpResponse.cs

示例14: ParseUrlEncoded

 /// <summary>
 /// Builds a FormData from the specified input stream, 
 /// which is assumed to be in x-www-form-urlencoded format.
 /// </summary>
 /// <param name="stream">the input stream</param>
 /// <returns>a populated FormData object</returns>
 public static Task<FormData> ParseUrlEncoded(Stream stream) {
     var form = new FormData();
     string input = stream.ReadAll();
     var pairs = input.Split(UrlSplitTokens, StringSplitOptions.RemoveEmptyEntries);
     foreach (var pair in pairs) {
         var nameValue = pair.Split('=');
         form[nameValue[0]] = UrlHelper.Decode(nameValue[1]);
     }
     return TaskHelper.Completed(form);
 }
开发者ID:xamele0n,项目名称:Simple.Owin,代码行数:16,代码来源:FormData.cs


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