예제 #1
0
        private async void checkDigests_Click(object sender, EventArgs _)
        {
            validateResult.Text        = "Checking PKG digests...";
            listView1.Enabled          = false;
            checkDigestsButton.Enabled = false;
            var validator = new PkgValidator(pkg);

            CloseFileView();
            listView1.Items.Clear();
            await Task.Run(() =>
            {
                using (var s = pkgFile.GetStream())
                {
                    foreach (var v in validator.Validate(s).OrderBy((a) => a.Item1.Location))
                    {
                        var item = new ListViewItem(v.Item1.Name);
                        if (v.Item2)
                        {
                            item.BackColor = Color.LightGreen;
                        }
                        else
                        {
                            item.BackColor = Color.LightSalmon;
                        }
                        item.Tag = v;
                        listView1.BeginInvoke((Action)(() => listView1.Items.Add(item)));
                    }
                }
            });

            listView1.Enabled          = true;
            checkDigestsButton.Enabled = true;
            validateResult.Text        = "Done!";
            ReopenFileView();
        }
예제 #2
0
        private void checkDigests_Click(object sender, EventArgs _)
        {
            validateResult.Text = "Checking PKG digests...";
            Action <string> errorHandler = e => validateResult.Text += Environment.NewLine + $"Digest mismatch: {e}";
            var             validator    = new PkgValidator(pkg, errorHandler);

            CloseFileView();
            using (var s = pkgFile.GetStream())
            {
                var errors = validator.Validate(s);
                if (errors.Count == 0)
                {
                    validateResult.Text += Environment.NewLine + "PKG Successfully validated";
                }
                else
                {
                    validateResult.Text += Environment.NewLine + $"PKG Validation Failed: {errors.Count} hashes did not match";
                }
            }
            ReopenFileView();
        }
예제 #3
0
        private async void checkDigests_Click(object sender, EventArgs _)
        {
            validateResult.Text        = "Checking PKG digests...";
            listView1.Enabled          = false;
            checkDigestsButton.Enabled = false;
            var validator = new PkgValidator(pkg);

            listView1.Items.Clear();
            await Task.Run(() =>
            {
                using (var s = pkgFile.CreateViewStream())
                {
                    foreach (var v in validator.Validate(s).OrderBy((a) => a.Item1.Location))
                    {
                        var item = new ListViewItem(v.Item1.Name);
                        if (v.Item2 == PkgValidator.ValidationResult.Ok)
                        {
                            item.BackColor = Color.LightGreen;
                        }
                        else if (v.Item2 == PkgValidator.ValidationResult.Fail)
                        {
                            item.BackColor = Color.LightSalmon;
                        }
                        item.Tag = v;
                        listView1.BeginInvoke((Action)(() => listView1.Items.Add(item)));
                    }
                }
            });

            listView1.Enabled          = true;
            checkDigestsButton.Enabled = true;
            validateResult.Text        = "Done!";
            foreach (ListViewItem x in listView1.Items)
            {
                if (x.BackColor == Color.LightSalmon)
                {
                    validateResult.Text += Environment.NewLine + "Failed: " + x.Text;
                }
            }
        }