コード例 #1
0
 internal XNodeReader(XNode node, XmlNameTable nameTable, ReaderOptions options)
 {
     this.source = node;
     this.root = node;
     this.nameTable = (nameTable != null) ? nameTable : CreateNameTable();
     this.omitDuplicateNamespaces = (options & ReaderOptions.OmitDuplicateNamespaces) != ReaderOptions.None;
 }
コード例 #2
0
ファイル: XNodeReader.cs プロジェクト: svcgany1/corefx
 internal XNodeReader(XNode node, XmlNameTable nameTable, ReaderOptions options)
 {
     _source = node;
     _root = node;
     _nameTable = nameTable != null ? nameTable : CreateNameTable();
     _omitDuplicateNamespaces = (options & ReaderOptions.OmitDuplicateNamespaces) != 0 ? true : false;
 }
コード例 #3
0
        public static BarcodeResult[] GetBarcode(Bitmap bitmap, Int64 format, string strSessionID)
        {
            BarcodeReader reader = new BarcodeReader();
            ReaderOptions options = new ReaderOptions();
            options.MaxBarcodesToReadPerPage = 100;
            options.BarcodeFormats = (BarcodeFormat)format;

            reader.ReaderOptions = options;
            reader.LicenseKeys = "<input barcode reader license here>";
            return reader.DecodeBitmap(bitmap);
        }
コード例 #4
0
        private void GetSevenZipData(string filename, DumpEntity dump)
        {
            var readerOptions = new ReaderOptions
            {
                LookForHeader = true
            };

            var archive = SevenZipArchive.Open(filename, readerOptions);

            foreach (SevenZipArchiveEntry entry in archive.Entries)
            {
                var blob = new BlobEntity
                {
                    Name = entry.Key,
                    Size = (ulong)entry.Size
                };

                blob.Hashes.Add("crc32", entry.Crc.ToString("x8"));

                dump.Blobs.Add(blob);
            }
        }
コード例 #5
0
        protected async Task <List <CompressFileUploadOutput> > ArchiveStreamRead(Stream stream,
                                                                                  ReaderOptions readerOptions = null, string compressFolder = null)
        {
            var allFileInfo = new List <CompressFileUploadOutput>();

            using (var archive = ArchiveFactory.Open(stream, readerOptions))
            {
                foreach (var entry in archive.Entries)
                {
                    if (entry.IsDirectory)
                    {
                        continue;
                    }

                    var entryFileInfos = await ArchiveEntryRead(entry, readerOptions, compressFolder);

                    allFileInfo.AddRange(entryFileInfos);
                }
            }

            return(allFileInfo);
        }
コード例 #6
0
        public void Read_from_offset_in_second_chunk()
        {
            DataSet ds = DataSetGenerator.Generate(15);
            var     wo = new WriterOptions {
                RowGroupsSize = 5
            };
            var ro = new ReaderOptions {
                Offset = 5, Count = 2
            };

            var ms = new MemoryStream();

            ParquetWriter.Write(ds, ms, CompressionMethod.None, null, wo);

            ms.Position = 0;
            DataSet ds1 = ParquetReader.Read(ms, null, ro);

            Assert.Equal(15, ds1.TotalRowCount);
            Assert.Equal(2, ds1.RowCount);
            Assert.Equal(5, ds1[0][0]);
            Assert.Equal(6, ds1[1][0]);
        }
コード例 #7
0
ファイル: ArchiveFactory.cs プロジェクト: LinasBushina/repo
 /// <summary>
 /// Opens an Archive for random access
 /// </summary>
 /// <param name="stream"></param>
 /// <param name="readerOptions"></param>
 /// <returns></returns>
 public static IArchive Open(Stream stream, ReaderOptions readerOptions = null)
 {
     stream.CheckNotNull("stream");
     if (!stream.CanRead || !stream.CanSeek)
     {
         throw new ArgumentException("Stream should be readable and seekable");
     }
     readerOptions = readerOptions ?? new ReaderOptions();
     if (ZipArchive.IsZipFile(stream, null))
     {
         stream.Seek(0, SeekOrigin.Begin);
         return(ZipArchive.Open(stream, readerOptions));
     }
     stream.Seek(0, SeekOrigin.Begin);
     if (SevenZipArchive.IsSevenZipFile(stream))
     {
         stream.Seek(0, SeekOrigin.Begin);
         return(SevenZipArchive.Open(stream, readerOptions));
     }
     stream.Seek(0, SeekOrigin.Begin);
     if (GZipArchive.IsGZipFile(stream))
     {
         stream.Seek(0, SeekOrigin.Begin);
         return(GZipArchive.Open(stream, readerOptions));
     }
     stream.Seek(0, SeekOrigin.Begin);
     if (RarArchive.IsRarFile(stream, readerOptions))
     {
         stream.Seek(0, SeekOrigin.Begin);
         return(RarArchive.Open(stream, readerOptions));
     }
     stream.Seek(0, SeekOrigin.Begin);
     if (TarArchive.IsTarFile(stream))
     {
         stream.Seek(0, SeekOrigin.Begin);
         return(TarArchive.Open(stream, readerOptions));
     }
     throw new InvalidOperationException("Cannot determine compressed stream type. Supported Archive Formats: Zip, GZip, Tar, Rar, 7Zip, LZip");
 }
コード例 #8
0
 public static bool TryOpen(FileInfo fileInfo, ReaderOptions options, ArchiveTypeMask archiveTypes, out IArchive archive)
 {
     fileInfo.CheckNotNull("fileInfo");
     options = options ?? new ReaderOptions {
         LeaveStreamOpen = false
     };
     using (var stream = fileInfo.OpenRead())
     {
         if (archiveTypes.HasFlag(ArchiveTypeMask.Zip) && ZipArchive.IsZipFile(stream, null))
         {
             archive = ZipArchive.Open(fileInfo, options);
         }
         stream.Seek(0, SeekOrigin.Begin);
         if (archiveTypes.HasFlag(ArchiveTypeMask.SevenZip) && SevenZipArchive.IsSevenZipFile(stream))
         {
             archive = SevenZipArchive.Open(fileInfo, options);
         }
         stream.Seek(0, SeekOrigin.Begin);
         if (archiveTypes.HasFlag(ArchiveTypeMask.GZip) && GZipArchive.IsGZipFile(stream))
         {
             archive = GZipArchive.Open(fileInfo, options);
             return(true);
         }
         stream.Seek(0, SeekOrigin.Begin);
         if (archiveTypes.HasFlag(ArchiveTypeMask.Rar) && RarArchive.IsRarFile(stream, options))
         {
             archive = RarArchive.Open(fileInfo, options);
             return(true);
         }
         stream.Seek(0, SeekOrigin.Begin);
         if (archiveTypes.HasFlag(ArchiveTypeMask.Tar) && TarArchive.IsTarFile(stream))
         {
             archive = TarArchive.Open(fileInfo, options);
             return(true);
         }
     }
     archive = null;
     return(false);
 }
コード例 #9
0
        internal static IEnumerable <RarVolume> GetParts(FileInfo fileInfo, ReaderOptions options)
        {
            FileInfoRarArchiveVolume part = new FileInfoRarArchiveVolume(fileInfo, options);

            yield return(part);

            if (!part.ArchiveHeader.ArchiveHeaderFlags.HasFlag(ArchiveFlags.VOLUME))
            {
                yield break; //if file isn't volume then there is no reason to look
            }
            ArchiveHeader ah = part.ArchiveHeader;

            fileInfo = GetNextFileInfo(ah, part.FileParts.FirstOrDefault() as FileInfoRarFilePart);
            //we use fileinfo because rar is dumb and looks at file names rather than archive info for another volume
            while (fileInfo != null && fileInfo.Exists)
            {
                part = new FileInfoRarArchiveVolume(fileInfo, options);

                fileInfo = GetNextFileInfo(ah, part.FileParts.FirstOrDefault() as FileInfoRarFilePart);
                yield return(part);
            }
        }
コード例 #10
0
            public Cursor(ParquetLoader parent, Func <int, bool> predicate, IRandom rand)
                : base(parent._host)
            {
                Ch.AssertValue(predicate);
                _loader             = parent;
                _fileStream         = parent._parquetStream;
                _parquetConversions = new ParquetConversions(Ch);
                _rand = rand;

                // Create Getter delegates
                Utils.BuildSubsetMaps(Schema.ColumnCount, predicate, out _actives, out _colToActivesIndex);
                _readerOptions = new ReaderOptions
                {
                    Count   = _loader._columnChunkReadSize,
                    Columns = _loader._columnsLoaded.Select(i => i.Name).ToArray()
                };

                // The number of blocks is calculated based on the specified rows in a block (defaults to 1M).
                // Since we want to shuffle the blocks in addition to shuffling the rows in each block, checks
                // are put in place to ensure we can produce a shuffle order for the blocks.
                var numBlocks = MathUtils.DivisionCeiling((long)parent.GetRowCount(), _readerOptions.Count);

                if (numBlocks > int.MaxValue)
                {
                    throw _loader._host.ExceptParam(nameof(Arguments.ColumnChunkReadSize), "Error due to too many blocks. Try increasing block size.");
                }
                var blockOrder = CreateOrderSequence((int)numBlocks);

                _blockEnumerator = blockOrder.GetEnumerator();

                _dataSetEnumerator = Enumerable.Empty <int>().GetEnumerator();
                _columnValues      = new IList[_actives.Length];
                _getters           = new Delegate[_actives.Length];
                for (int i = 0; i < _actives.Length; ++i)
                {
                    int columnIndex = _actives[i];
                    _getters[i] = CreateGetterDelegate(columnIndex);
                }
            }
コード例 #11
0
        private static async Task <Tuple <bool, string> > UnarchiveByFilePath(string fileFullPath, string password = "")
        {
            using (var stream = await FileSystem.OpenAppPackageFileAsync(fileFullPath))
            {
                ReaderOptions readerOptions = null;

                if (!string.IsNullOrEmpty(password))
                {
                    readerOptions = new ReaderOptions()
                    {
                        Password = password
                    };
                }
                try
                {
                    using (var reader = ReaderFactory.Open(stream, readerOptions))
                    {
                        while (reader.MoveToNextEntry())
                        {
                            if (!reader.Entry.IsDirectory)
                            {
                                Console.WriteLine(reader.Entry.Key);
                                reader.WriteEntryToDirectory(FileSystem.AppDataDirectory, new ExtractionOptions()
                                {
                                    ExtractFullPath = true,
                                    Overwrite       = true
                                });
                            }
                        }
                        return(new Tuple <bool, string>(true, string.Empty));
                    }
                }
                catch (CryptographicException cryptographicException)
                {
                    System.Diagnostics.Debug.WriteLine(cryptographicException.Message);
                    return(new Tuple <bool, string>(false, "解壓縮密碼錯誤"));
                }
            }
        }
コード例 #12
0
ファイル: ZipRepertory.cs プロジェクト: hepra/My_Helper
        public VlcStream GetVideoStream(string path, string password)
        {
            var stream = File.OpenRead(path);
            var option = new ReaderOptions
            {
                Password        = password,
                LeaveStreamOpen = true,
                ArchiveEncoding = new ArchiveEncoding()
                {
                    Default = Encoding.UTF8
                }
            };
            var       archive = ZipArchive.Open(stream, option);
            VlcStream temp    = new VlcStream();

            temp.Stream     = archive;
            temp.ZipPath    = path;
            temp.Option     = option;
            temp.check      = entity => IsVideo(Path.GetExtension(entity.Key));
            temp.fileStream = stream;
            return(temp);
        }
コード例 #13
0
 /// <summary>
 /// Constructor with a FileInfo object to an existing file.
 /// </summary>
 /// <param name="fileInfo"></param>
 /// <param name="options"></param>
 public static IArchive Open(FileInfo fileInfo, ReaderOptions options = null)
 {
     fileInfo.CheckNotNull("fileInfo");
     options = options ?? new ReaderOptions();
     using (var stream = fileInfo.OpenRead())
     {
         if (ZipArchive.IsZipFile(stream, null))
         {
             stream.Dispose();
             return(ZipArchive.Open(fileInfo, options));
         }
         stream.Seek(0, SeekOrigin.Begin);
         if (SevenZipArchive.IsSevenZipFile(stream))
         {
             stream.Dispose();
             return(SevenZipArchive.Open(fileInfo, options));
         }
         stream.Seek(0, SeekOrigin.Begin);
         if (GZipArchive.IsGZipFile(stream))
         {
             stream.Dispose();
             return(GZipArchive.Open(fileInfo, options));
         }
         stream.Seek(0, SeekOrigin.Begin);
         if (RarArchive.IsRarFile(stream, options))
         {
             stream.Dispose();
             return(RarArchive.Open(fileInfo, options));
         }
         stream.Seek(0, SeekOrigin.Begin);
         if (TarArchive.IsTarFile(stream))
         {
             stream.Dispose();
             return(TarArchive.Open(fileInfo, options));
         }
         throw new InvalidOperationException("Cannot determine compressed stream type. Supported Archive Formats: Zip, GZip, Tar, Rar, 7Zip");
     }
 }
コード例 #14
0
                //[Variation(Priority = 0, Desc = "XDocument - ReaderOptions.None", Params = new object[] { typeof(XDocument), "simple.xml", ReaderOptions.None })]
                //[Variation(Priority = 0, Desc = "XDocument - ReaderOptions.OmitDuplicateNamespaces", Params = new object[] { typeof(XDocument), "simple.xml", ReaderOptions.OmitDuplicateNamespaces })]
                //[Variation(Priority = 0, Desc = "XElement - ReaderOptions.None", Params= new object [] {typeof(XElement), "simple.xml", ReaderOptions.None })]
                //[Variation(Priority = 0, Desc = "XElement - ReaderOptions.OmitDuplicateNamespaces", Params = new object[] { typeof(XElement), "simple.xml", ReaderOptions.OmitDuplicateNamespaces })]
                public void ReaderOptionsSmoke()
                {
                    Type          t        = CurrentChild.Params[0] as Type;
                    string        fileName = Path.Combine(s_MyPath, CurrentChild.Params[1] as string);
                    ReaderOptions ro       = (ReaderOptions)CurrentChild.Params[2];

                    var original = GetContainer(fileName, t).DescendantNodes().ToArray();
                    var clone    = GetContainer(fileName, t).DescendantNodes().ToArray();

                    TestLog.Compare(original.Length, clone.Length, "original.Length != clone.Length"); // assert
                    Action <XmlReader, XmlReader> compareDelegate = ro == ReaderOptions.None ? (Action <XmlReader, XmlReader>)ReaderDiff.Compare : (Action <XmlReader, XmlReader>)ReaderDiffNSAware.CompareNamespaceAware;

                    foreach (int i in Enumerable.Range(0, original.Length))
                    {
                        // no annotation
                        compareDelegate(original[i].CreateReader(), clone[i].CreateReader(ro));

                        // annotation on self
                        foreach (SaveOptions so in new SaveOptions[] { SaveOptions.None, SaveOptions.OmitDuplicateNamespaces })
                        {
                            clone[i].AddAnnotation(so);
                            compareDelegate(original[i].CreateReader(), clone[i].CreateReader(ro));
                            clone[i].RemoveAnnotations(typeof(object));
                        }

                        // annotation on parents
                        foreach (SaveOptions so in new SaveOptions[] { SaveOptions.None, SaveOptions.OmitDuplicateNamespaces })
                        {
                            foreach (XNode anc in clone[i].Ancestors())
                            {
                                anc.AddAnnotation(so);

                                compareDelegate(original[i].CreateReader(), clone[i].CreateReader(ro));
                                anc.RemoveAnnotations(typeof(object));
                            }
                        }
                    }
                }
コード例 #15
0
        /// <summary>
        /// 解压文件,自动检测压缩包类型
        /// </summary>
        /// <param name="compressedFile">rar文件</param>
        /// <param name="dir">解压到...</param>
        /// <param name="ignoreEmptyDir">忽略空文件夹</param>
        public static void Decompress(string compressedFile, string dir = "", bool ignoreEmptyDir = true)
        {
            if (string.IsNullOrEmpty(dir))
            {
                dir = Path.GetDirectoryName(compressedFile);
            }

            using (Stream stream = File.OpenRead(compressedFile))
            {
                ReaderOptions options = new ReaderOptions();
                options.ArchiveEncoding.Default = Encoding.GetEncoding("GB2312");//中文解压的话 要这个 不然 会乱码的
                using (var reader = ReaderFactory.Open(stream, options))
                {
                    while (reader.MoveToNextEntry())
                    {
                        if (ignoreEmptyDir)
                        {
                            reader.WriteEntryToDirectory(dir, new ExtractionOptions()
                            {
                                ExtractFullPath = true,
                                Overwrite       = true
                            });
                        }
                        else
                        {
                            if (!reader.Entry.IsDirectory)
                            {
                                reader.WriteEntryToDirectory(dir, new ExtractionOptions()
                                {
                                    ExtractFullPath = true,
                                    Overwrite       = true
                                });
                            }
                        }
                    }
                }
            }
        }
コード例 #16
0
        /// <summary>
        /// Opens an Archive for random access
        /// </summary>
        /// <param name="stream"></param>
        /// <param name="readerOptions"></param>
        /// <returns></returns>
        public static IArchive Open(Stream stream, ReaderOptions readerOptions = null)
        {
            stream.CheckNotNull(nameof(stream));
            if (!stream.CanRead || !stream.CanSeek)
            {
                throw new ArgumentException("Stream should be readable and seekable");
            }
            if (readerOptions == null)
            {
                readerOptions = new ReaderOptions();
            }

            ArchiveType?type;

            IsArchive(stream, out type); //test and reset stream position

            if (type != null)
            {
                switch (type.Value)
                {
                case ArchiveType.Zip:
                    return(ZipArchive.Open(stream, readerOptions));

                case ArchiveType.SevenZip:
                    return(SevenZipArchive.Open(stream, readerOptions));

                case ArchiveType.GZip:
                    return(GZipArchive.Open(stream, readerOptions));

                case ArchiveType.Rar:
                    return(RarArchive.Open(stream, readerOptions));

                case ArchiveType.Tar:
                    return(TarArchive.Open(stream, readerOptions));
                }
            }
            throw new InvalidOperationException("Cannot determine compressed stream type. Supported Archive Formats: Zip, GZip, Tar, Rar, 7Zip, LZip");
        }
コード例 #17
0
        /// <summary>
        /// Opens a TarReader for Non-seeking usage with a single volume
        /// </summary>
        /// <param name="stream"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        public static TarReader Open(Stream stream, ReaderOptions options = null)
        {
            stream.CheckNotNull(nameof(stream));
            options = options != null ? options: new ReaderOptions();
            RewindableStream rewindableStream = new RewindableStream(stream);

            rewindableStream.StartRecording();
            if (GZipArchive.IsGZipFile(rewindableStream))
            {
                rewindableStream.Rewind(false);
                GZipStream testStream = new GZipStream(rewindableStream, CompressionMode.Decompress);
                if (TarArchive.IsTarFile(testStream))
                {
                    rewindableStream.Rewind(true);
                    return(new TarReader(rewindableStream, options, CompressionType.GZip));
                }
                throw new InvalidFormatException("Not a tar file.");
            }

            rewindableStream.Rewind(false);
            rewindableStream.Rewind(true);
            return(new TarReader(rewindableStream, options, CompressionType.None));
        }
コード例 #18
0
        /// <summary>
        /// Constructor with a FileInfo object to an existing file.
        /// </summary>
        /// <param name="fileInfo"></param>
        /// <param name="options"></param>
        public static IArchive Open(FileInfo fileInfo, ReaderOptions options = null)
        {
            fileInfo.CheckNotNull(nameof(fileInfo));
            options = options != null ?options: new ReaderOptions {
                LeaveStreamOpen = false
            };
            using (var stream = fileInfo.OpenRead())
            {
                stream.Seek(0, SeekOrigin.Begin);
                if (GZipArchive.IsGZipFile(stream))
                {
                    return(GZipArchive.Open(fileInfo, options));
                }
                stream.Seek(0, SeekOrigin.Begin);

                stream.Seek(0, SeekOrigin.Begin);
                if (TarArchive.IsTarFile(stream))
                {
                    return(TarArchive.Open(fileInfo, options));
                }
                throw new InvalidOperationException("Cannot determine compressed stream type. Supported Archive Formats: Zip, GZip, Tar, Rar, 7Zip");
            }
        }
コード例 #19
0
ファイル: ArchiveTests.cs プロジェクト: Erior/sharpcompress
 protected void ArchiveOpenStreamRead(ReaderOptions readerOptions, IEnumerable <string> testArchives)
 {
     using (var archive = ArchiveFactory.Open(testArchives.Select(f => new FileInfo(f)), null))
     {
         try
         {
             foreach (var entry in archive.Entries.Where(entry => !entry.IsDirectory))
             {
                 entry.WriteToDirectory(SCRATCH_FILES_PATH,
                                        new ExtractionOptions()
                 {
                     ExtractFullPath = true,
                     Overwrite       = true
                 });
             }
         }
         catch (IndexOutOfRangeException)
         {
             throw;
         }
     }
     VerifyFiles();
 }
コード例 #20
0
        protected void ArchiveFileRead(IEnumerable <string> testArchives, ReaderOptions readerOptions = null)
        {
            foreach (var path in testArchives)
            {
                using (var archive = ArchiveFactory.Open(path, readerOptions))
                {
                    //archive.EntryExtractionBegin += archive_EntryExtractionBegin;
                    //archive.FilePartExtractionBegin += archive_FilePartExtractionBegin;
                    //archive.CompressedBytesRead += archive_CompressedBytesRead;

                    foreach (var entry in archive.Entries.Where(entry => !entry.IsDirectory))
                    {
                        entry.WriteToDirectory(SCRATCH_FILES_PATH,
                                               new ExtractionOptions()
                        {
                            ExtractFullPath = true,
                            Overwrite       = true
                        });
                    }
                }
                VerifyFiles();
            }
        }
コード例 #21
0
 protected void ArchiveStreamRead(ReaderOptions readerOptions, IEnumerable <string> testArchives)
 {
     foreach (var path in testArchives)
     {
         ResetScratch();
         using (var stream = new NonDisposingStream(File.OpenRead(path), true))
             using (var archive = ArchiveFactory.Open(stream, readerOptions))
             {
                 try
                 {
                     foreach (var entry in archive.Entries.Where(entry => !entry.IsDirectory))
                     {
                         entry.WriteToDirectory(SCRATCH_FILES_PATH,
                                                new ExtractionOptions()
                         {
                             ExtractFullPath = true,
                             Overwrite       = true
                         });
                     }
                 }
                 catch (InvalidFormatException)
                 {
                     //rar SOLID test needs this
                     stream.ThrowOnDispose = false;
                     throw;
                 }
                 catch (IndexOutOfRangeException)
                 {
                     //SevenZipArchive_BZip2_Split test needs this
                     stream.ThrowOnDispose = false;
                     throw;
                 }
                 stream.ThrowOnDispose = false;
             }
         VerifyFiles();
     }
 }
コード例 #22
0
ファイル: ArchiveTests.cs プロジェクト: Erior/sharpcompress
        protected void ArchiveOpenEntryVolumeIndexTest(int[][] results, ReaderOptions readerOptions, IEnumerable <string> testArchives)
        {
            string[] src = testArchives.ToArray();
            using (var archive = ArchiveFactory.Open(testArchives.Select(f => new FileInfo(f)), null))
            {
                try
                {
                    int idx = 0;
                    foreach (var entry in archive.Entries.Where(entry => !entry.IsDirectory))
                    {
                        Assert.Equal(entry.VolumeIndexFirst, results[idx][0]);
                        Assert.Equal(entry.VolumeIndexLast, results[idx][1]);
                        Assert.Equal(src[entry.VolumeIndexFirst], archive.Volumes.First(a => a.Index == entry.VolumeIndexFirst).FileName);
                        Assert.Equal(src[entry.VolumeIndexLast], archive.Volumes.First(a => a.Index == entry.VolumeIndexLast).FileName);

                        idx++;
                    }
                }
                catch (IndexOutOfRangeException)
                {
                    throw;
                }
            }
        }
コード例 #23
0
 /// <summary>
 /// Constructor expects a filepath to an existing file.
 /// </summary>
 /// <param name="filePath"></param>
 /// <param name="readerOptions"></param>
 public static TarArchive Open(string filePath, ReaderOptions readerOptions = null)
 {
     filePath.CheckNotNullOrEmpty("filePath");
     return(Open(new FileInfo(filePath), readerOptions ?? new ReaderOptions()));
 }
コード例 #24
0
 /// <summary>
 /// Takes multiple seekable Streams for a multi-part archive
 /// </summary>
 /// <param name="stream"></param>
 /// <param name="readerOptions"></param>
 internal TarArchive(Stream stream, ReaderOptions readerOptions)
     : base(ArchiveType.Tar, stream, readerOptions)
 {
 }
コード例 #25
0
 /// <summary>
 /// Takes a seekable Stream as a source
 /// </summary>
 /// <param name="stream"></param>
 /// <param name="options"></param>
 public static RarArchive Open(Stream stream, ReaderOptions options = null)
 {
     stream.CheckNotNull(nameof(stream));
     return Open(stream.AsEnumerable(), options ?? new ReaderOptions());
 }
コード例 #26
0
 /// <summary>
 /// Constructor with a FileInfo object to an existing file.
 /// </summary>
 /// <param name="fileInfo"></param>
 /// <param name="options"></param>
 public static RarArchive Open(FileInfo fileInfo, ReaderOptions options = null)
 {
     fileInfo.CheckNotNull(nameof(fileInfo));
     return new RarArchive(fileInfo, options ?? new ReaderOptions());
 }
コード例 #27
0
 /// <summary>
 /// Constructor with a FileInfo object to an existing file.
 /// </summary>
 /// <param name="filePath"></param>
 /// <param name="options"></param>
 public static RarArchive Open(string filePath, ReaderOptions options = null)
 {
     filePath.CheckNotNullOrEmpty(nameof(filePath));
     return new RarArchive(new FileInfo(filePath), options ?? new ReaderOptions());
 }
コード例 #28
0
 /// <summary>
 /// Takes multiple seekable Streams for a multi-part archive
 /// </summary>
 /// <param name="streams"></param>
 /// <param name="options"></param>
 internal RarArchive(IEnumerable<Stream> streams, ReaderOptions options)
     : base(ArchiveType.Rar, streams, options)
 {
 }
コード例 #29
0
ファイル: ParsingTests.cs プロジェクト: slorion/nlight
		public void ParsingTest(string data, int? bufferSize, ReaderOptions? options, char? delimiter, char? quote, char? comment, string expectedColumnHeaders, IEnumerable<string> expectedRecords)
		{
			using (var reader = new DelimitedRecordReader(new StringReader(data), bufferSize.HasValue ? bufferSize.Value : DelimitedRecordReader.DefaultBufferSize))
			{
				if (options != null)
				{
					reader.AdvancedEscapingEnabled = (options & ReaderOptions.AdvancedEscaping) != 0;
					reader.DoubleQuoteEscapingEnabled = (options & ReaderOptions.NoDoubleQuoteEscaping) == 0;
					reader.SkipEmptyLines = (options & ReaderOptions.NoSkipEmptyLines) == 0;
					reader.TrimWhiteSpaces = (options & ReaderOptions.NoTrim) == 0;
				}

				if (comment != null)
					reader.CommentCharacter = comment.Value;

				if (delimiter != null)
					reader.DelimiterCharacter = delimiter.Value;

				if (quote != null)
					reader.QuoteCharacter = quote.Value;

				string[] headers = null;

				if (!string.IsNullOrEmpty(expectedColumnHeaders))
				{
					reader.DynamicColumnCount = false;
					Assert.AreEqual(ReadResult.Success, reader.ReadColumnHeaders());

					headers = expectedColumnHeaders.Split('|');

					Assert.AreEqual(headers.Length, reader.Columns.Count);

					for (int i = 0; i < headers.Length; i++)
						Assert.AreEqual(headers[i], reader.Columns[i].Name);
				}

				foreach (var record in expectedRecords)
				{
					Assert.AreEqual(ReadResult.Success, reader.Read());

					string[] values = record.Split('|');

					if (headers != null)
						Assert.AreEqual(headers.Length, values.Length);

					Assert.AreEqual(values.Length, reader.Columns.Count);

					for (int columnIndex = 0; columnIndex < values.Length; columnIndex++)
						Assert.AreEqual(values[columnIndex], reader[columnIndex]);

					if (headers != null)
					{
						for (int columnIndex = 0; columnIndex < values.Length; columnIndex++)
							Assert.AreEqual(values[columnIndex], reader[headers[columnIndex]]);
					}
				}

				Assert.AreEqual(ReadResult.EndOfFile, reader.Read());
			}
		}
コード例 #30
0
 private void btnRead_Click(object sender, EventArgs e)
 {
     if (imageViewer.Image != null)
     {
         //Rectangle rect = new Rectangle();
         BarcodeReader reader = new Dynamsoft.Barcode.BarcodeReader();
         try
         {
             ReaderOptions ro = new ReaderOptions();
             ro.BarcodeFormats = GetFormats();
             ro.MaxBarcodesToReadPerPage = int.Parse(tbMaximumNum.Text);
             reader.ReaderOptions = ro;
             reader.LicenseKeys = "<Input your license key here>";
             DateTime beforeRead = DateTime.Now;
             BarcodeResult[] barcodes = reader.DecodeFile(filePath);
             DateTime afterRead = DateTime.Now;
             int timeElapsed = (afterRead - beforeRead).Milliseconds;
             ShowBarcodeResults(barcodes, timeElapsed);
         }
         catch (Exception exp)
         {
             MessageBox.Show(exp.Message, "Barcode Reader Demo", MessageBoxButtons.OK);
         }
         finally
         {
             reader.Dispose();
         }
     }
 }
コード例 #31
0
ファイル: OrcFile.cs プロジェクト: CurtHagenlocher/OrcSharp
 /**
  * Create an ORC file reader.
  * @param fs file system
  * @param path file name to read from
  * @return a new ORC file reader.
  * @
  */
 public static Reader createReader(Func<Stream> file, string path)
 {
     ReaderOptions opts = new ReaderOptions(new Configuration());
     // opts.filesystem(fs);
     return new ReaderImpl(file, path, opts);
 }
コード例 #32
0
ファイル: OrcFile.cs プロジェクト: CurtHagenlocher/OrcSharp
 public static Reader createReader(string path, ReaderOptions options)
 {
     return new ReaderImpl(() => File.OpenRead(path), path, options);
 }
コード例 #33
0
ファイル: XNode.cs プロジェクト: user277/mono
		public XmlReader CreateReader (ReaderOptions readerOptions)
		{
			var r = new XNodeReader (this);
			if ((readerOptions & ReaderOptions.OmitDuplicateNamespaces) != 0)
				r.OmitDuplicateNamespaces = true;
			
			return r;
		}
コード例 #34
0
 /// <summary>
 /// Constructor with a FileInfo object to an existing file.
 /// </summary>
 /// <param name="fileInfo"></param>
 /// <param name="readerOptions"></param>
 public static TarArchive Open(FileInfo fileInfo, ReaderOptions readerOptions = null)
 {
     fileInfo.CheckNotNull("fileInfo");
     return(new TarArchive(fileInfo, readerOptions ?? new ReaderOptions()));
 }
コード例 #35
0
 /// <summary>
 /// Constructor with a FileInfo object to an existing file.
 /// </summary>
 /// <param name="fileInfo"></param>
 /// <param name="options"></param>
 internal RarArchive(FileInfo fileInfo, ReaderOptions options)
     : base(ArchiveType.Rar, fileInfo, options)
 {
 }
コード例 #36
0
 /// <summary>
 /// Takes a seekable Stream as a source
 /// </summary>
 /// <param name="stream"></param>
 /// <param name="readerOptions"></param>
 public static TarArchive Open(Stream stream, ReaderOptions readerOptions = null)
 {
     stream.CheckNotNull("stream");
     return(new TarArchive(stream, readerOptions ?? new ReaderOptions()));
 }
コード例 #37
0
 /// <summary>
 /// Constructor with a FileInfo object to an existing file.
 /// </summary>
 /// <param name="fileInfo"></param>
 /// <param name="readerOptions"></param>
 internal TarArchive(FileInfo fileInfo, ReaderOptions readerOptions)
     : base(ArchiveType.Tar, fileInfo, readerOptions)
 {
 }
コード例 #38
0
 internal StreamRarArchiveVolume(Stream stream, ReaderOptions options)
     : base(StreamingMode.Seekable, stream, options)
 {
 }
コード例 #39
0
ファイル: XNode.cs プロジェクト: er0dr1guez/corefx
 /// <summary>
 /// Creates an <see cref="XmlReader"/> for the node.
 /// </summary>
 /// <param name="readerOptions">
 /// Options to be used for the returned reader. These override the default usage of annotations from the tree.
 /// </param>
 /// <returns>An <see cref="XmlReader"/> that can be used to read the node and its descendants.</returns>
 public XmlReader CreateReader(ReaderOptions readerOptions)
 {
     return new XNodeReader(this, null, readerOptions);
 }