Example #1
0
        private static void OutputToHtml(string bd, List <FileDigests> digests, List <CCR> results, PerformanceReport perfReport)
        {
            var xd = XDocument.Load("output.template.html");

            using (var sw = new StreamWriter("output.html", false, System.Text.Encoding.UTF8))
                using (var xw = XmlWriter.Create(sw, new XmlWriterSettings()
                {
                    OmitXmlDeclaration = true,
                    CheckCharacters = false
                }))
                {
                    var js = new JsonSerializer();
                    using (var aw = new StringWriter())
                    {
                        aw.Write("output(");
                        js.Serialize(aw, digests.Select(d => new { path = GetShortPath(bd, d), url = new Uri(d.fi.FullName).ToString() }));
                        aw.Write(",");
                        js.Serialize(aw, results.Select(r => new { r.i, r.j, ccr = r.m }));
                        aw.Write(",");
                        js.Serialize(aw, new { report = perfReport?.ToString() ?? "" });
                        aw.Write(")");

                        xd.Descendants("{http://www.w3.org/1999/xhtml}body").First().SetAttributeValue("onload", aw);
                    }

                    xd.Save(xw);
                }

            Process.Start("output.html");
        }
Example #2
0
        private static void OutputToConsole(string bd, List <FileDigests> digests, List <CCR> results, PerformanceReport perfReport)
        {
            foreach (var d in digests.OrderBy(d => d.fi.FullName, StringComparer.CurrentCultureIgnoreCase))
            {
                Console.WriteLine(GetShortPath(bd, d));
                Console.WriteLine(d.BitmapSourceHash);
            }
            Console.WriteLine();

            Console.WriteLine("Hit any key to continue..");
            Console.ReadKey();

            if (digests.Count > 1)
            {
                foreach (var r in results)
                {
                    var d1 = digests[r.i];
                    var d2 = digests[r.j];
                    Console.WriteLine(GetShortPath(bd, d1));
                    Console.WriteLine(GetShortPath(bd, d2));
                    Console.WriteLine(r.m.ToString("f7"));
                }
            }

            if (perfReport != null)
            {
                Console.WriteLine(perfReport.ToString());
            }

            Console.WriteLine("Hit any key to exit..");
            Console.ReadKey();
        }