示例#1
0
        private void Logger(string message, Severity severity, Likeliness repairability)
        {
            if (!controller.Dispatcher.CheckAccess())
            {
                controller.Dispatcher.Invoke
                (
                    new Action <string, Severity, Likeliness> ((m, s, r) => Logger(m, s, r)),
                    new object[] { message, severity, repairability }
                );
                return;
            }

            string prefix;

            if (severity == Severity.NoIssue)
            {
                prefix = String.Empty;
            }
            else if (severity <= Severity.Trivia || (severity <= Severity.Advisory && !String.IsNullOrEmpty(modelBind.CurrentFile)))
            {
                prefix = "  ";
            }
            else if (severity <= Severity.Advisory)
            {
                prefix = "+ ";
            }
            else
            {
                prefix = severity <= Severity.Warning? "- " : "* ";
            }

            if (!fileShown)
            {
                fileShown = true;

                if (!String.IsNullOrEmpty(controller.consoleBox.Text))
                {
                    if (modelBind.Scope < Granularity.Verbose)
                    {
                        controller.consoleBox.AppendText("\n-- -- -- -- -- -- -- --\n");
                    }
                    else if (!dirShown)
                    {
                        controller.consoleBox.AppendText("\n");
                    }
                }

                if (!dirShown)
                {
                    dirShown = true;

                    if (!String.IsNullOrEmpty(modelBind.CurrentDirectory))
                    {
                        controller.consoleBox.AppendText(modelBind.CurrentDirectory);
                        if (!modelBind.CurrentDirectory.EndsWith(Path.DirectorySeparatorChar.ToString()))
                        {
                            controller.consoleBox.AppendText(Path.DirectorySeparatorChar.ToString());
                        }
                    }
                    controller.consoleBox.AppendText("\n");
                }

                controller.consoleBox.AppendText(modelBind.CurrentFile);
                controller.consoleBox.AppendText("\n");
            }

            if (message != null)
            {
                controller.consoleBox.AppendText(prefix);
                if (!String.IsNullOrEmpty(modelBind.CurrentFile) && severity >= Severity.Warning)
                {
                    controller.consoleBox.AppendText(Enum.GetName(typeof(Severity), severity) + ": ");
                }
                controller.consoleBox.AppendText(message);
                controller.consoleBox.AppendText("\n");
            }

            controller.consoleBox.ScrollToEnd();
        }
示例#2
0
        private void Logger(string message, Severity severity, Likeliness repairability)
        {
            string prefix;

            if (severity == Severity.NoIssue)
            {
                prefix = String.Empty;
            }
            else if (severity <= Severity.Trivia || (severity <= Severity.Advisory && !String.IsNullOrEmpty(modelBind.CurrentFile)))
            {
                prefix = "  ";
            }
            else if (severity <= Severity.Advisory)
            {
                prefix = "+ ";
            }
            else
            {
                prefix = severity <= Severity.Warning? "- " : "* ";
            }
            if (!String.IsNullOrEmpty(modelBind.CurrentFile) && severity >= Severity.Warning)
            {
                prefix += Enum.GetName(typeof(Severity), severity) + ": ";
            }

            if (isProgressLast)
            {
                Console.Error.Write(ProgressEraser);
                isProgressLast = false;
            }

            if (!fileShown)
            {
                fileShown = true;

                if (totalFilesReported != 0)
                {
                    if (modelBind.Scope < Granularity.Verbose)
                    {
                        Trace.WriteLine(String.Empty); Trace.WriteLine(controller.DetailSeparator);
                    }
                    else if (!dirShown)
                    {
                        Trace.WriteLine(String.Empty);
                    }
                }

                if (!dirShown)
                {
                    dirShown = true;

                    if (modelBind.CurrentDirectory.Length > 0)
                    {
                        Trace.Write(modelBind.CurrentDirectory);
                        if (modelBind.CurrentDirectory[modelBind.CurrentDirectory.Length - 1] != Path.DirectorySeparatorChar)
                        {
                            Trace.Write(Path.DirectorySeparatorChar);
                        }
                    }
                    Trace.WriteLine(String.Empty);
                }

                Trace.WriteLine(modelBind.CurrentFile);
            }

            if (message != null)
            {
                if (prefix != null)
                {
                    Trace.Write(prefix);
                }
                Trace.WriteLine(message);
            }
            else if (controller.NotifyEvery != 0 && modelBind.TotalFiles % controller.NotifyEvery == 0)
            {
                WriteChecked();
            }

            ++totalFilesReported;
        }