Пример #1
0
        public ZipFileTreeItem(ZipFile zipFile, String name = null)
            : base(zipFile.GetArchiveName(name))
        {
            var sw = new Stopwatch {
            };

            sw.Start();

            var maxIndex  = zipFile.Count - 1;
            var lastIndex = 0L;
            var timeTaken = 0L;

            var oldProgress = ArchiveExplorer.RegisterProgress(async(ProgressBar barProgress) =>
            {
                barProgress.Maximum = maxIndex;
                barProgress.Value   = lastIndex;

                await ArchiveExplorer.UpdateStatus($"Loading file {lastIndex:#,##0}/{maxIndex:#,##0} from archive");

                await Task.CompletedTask;
            });

            var entryList = new List <ZipEntry> {
            };

            foreach (ZipEntry entry in zipFile)
            {
                entryList.Add(entry);
            }

            foreach (var entry in entryList)
            {
                this.AddStream(entry.Name, () => zipFile.GetInputStream(entry), entry.DateTime.ToUniversalTime(), entry.Size);

                lastIndex = entry.ZipFileIndex;
            }

            sw.Stop();

            timeTaken = sw.ElapsedMilliseconds;

            ArchiveExplorer.RegisterProgress(oldProgress);

            ArchiveExplorer.UpdateStatus($"Loaded {this.Text} in {timeTaken:#,000}ms").Wait();
        }
Пример #2
0
        public DataForgeTreeItem(IStreamTreeItem node, unforge.DataForge dataForge)
            : base(node.Title, () => dataForge.GetStream(), node.LastModifiedUtc, dataForge.OuterXML.Length)
        {
            var sw = new Stopwatch {
            };

            sw.Start();

            var maxIndex  = dataForge.Length - 1;
            var lastIndex = 0L;

            var oldProgress = ArchiveExplorer.RegisterProgress(async(ProgressBar barProgress) =>
            {
                barProgress.Maximum = maxIndex;
                barProgress.Value   = lastIndex;

                await ArchiveExplorer.UpdateStatus($"Deserializing file {lastIndex:#,##0}/{maxIndex:#,##0} from dataforge");

                await Task.CompletedTask;
            });

            foreach ((String FileName, XmlDocument XmlDocument)entry in dataForge)
            {
                this.AddStream(
                    entry.FileName,
                    () => entry.XmlDocument.GetStream(),
                    node.LastModifiedUtc,
                    entry.XmlDocument.OuterXml.Length);

                lastIndex++;
            }

            sw.Stop();

            ArchiveExplorer.RegisterProgress(oldProgress);

            ArchiveExplorer.UpdateStatus($"Deserialized {this.Text} in {sw.ElapsedMilliseconds:#,000}ms").Wait();
        }