コード例 #1
0
        public ZipArchiveProblems Validate(ZipArchiveEntry entry)
        {
            if (entry == null) throw new ArgumentNullException(nameof(entry));

            var problems = ZipArchiveProblems.None;

            using (var stream = entry.Open())
            using (var reader = new BinaryReader(stream, _encoding))
            {
                ShapeFileHeader header = null;
                try
                {
                    header = ShapeFileHeader.Read(reader);
                }
                catch (Exception exception)
                {
                    problems += entry.HasShapeHeaderFormatError(exception);
                }

                if (header != null)
                {
                    using (var records = header.CreateShapeRecordEnumerator(reader))
                    {
                        problems += _recordValidator.Validate(entry, records);
                    }
                }
            }

            return problems;
        }
コード例 #2
0
        public TranslatedChanges Translate(ZipArchiveEntry entry, TranslatedChanges changes)
        {
            if (entry == null)
            {
                throw new ArgumentNullException(nameof(entry));
            }
            if (changes == null)
            {
                throw new ArgumentNullException(nameof(changes));
            }

            using (var stream = entry.Open())
                using (var reader = new BinaryReader(stream, _encoding))
                {
                    var header     = ShapeFileHeader.Read(reader);
                    var enumerator = header.CreateShapeRecordEnumerator(reader);
                    return(_recordTranslator.Translate(entry, enumerator, changes));
                }
        }