Beispiel #1
0
        /// <summary>
        /// Gets a list of source files used to create this PAR2 file.
        /// </summary>
        /// <returns>A collection of <see cref="SourceFile"/> objects.</returns>
        public IEnumerable <SourceFile> GetSourceList()
        {
            var yieldedFiles = new List <FileID>();

            using (var reader = new ParReader(StreamFactory.GetContentStreamAsync(Location).Result))
            {
                while (reader.BaseStream.Position < reader.BaseStream.Length)
                {
                    var fd = reader.ReadPacket(Packet.DefaultFactory.GetPacketType <FileDescriptionPacket>()) as FileDescriptionPacket;

                    if (fd == null)
                    {
                        break;
                    }

                    if (yieldedFiles.Contains(fd.FileID))
                    {
                        continue;
                    }

                    yield return(fd.ToSourceFile());
                }
            }
        }
Beispiel #2
0
 /// <summary>
 /// Gets the content as an asynchronous operation.
 /// </summary>
 /// <returns>A <see cref="Stream"/> object.</returns>
 /// <exception cref="System.InvalidOperationException">
 /// <see cref="Location"/> is not an absolute URI.
 /// </exception>
 public async Task <Stream> GetContentAsync()
 {
     return(await StreamFactory.GetContentStreamAsync(Location));
 }