Beispiel #1
0
        public void ReplayTo(ILogPrinter anotherPrinter)
        {
            Debug.Assert(anotherPrinter != null && anotherPrinter != this);

            foreach (Log.LogEntry entry in log.Entries())
            {
                if (entry.ErrorCode == 0)
                {
                    if (entry.Message.Length == 0)
                    {
                        anotherPrinter.Separate();
                        continue;
                    }
                    else if (entry.Message == IndentMarker)
                    {
                        anotherPrinter.Indent();
                        continue;
                    }
                    else if (entry.Message == UnindentMarker)
                    {
                        anotherPrinter.Unindent();
                        continue;
                    }
                }

                // ordinary entry
                anotherPrinter.PrintEntry(entry.Severity, entry.ErrorCode, entry.Message);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Prints preview of all methods under the specified node to the provided printers according to the current settings.
        /// </summary>
        private void PrintMethodPreview(TreeNode node, ICodePrinter printer, ILogPrinter logPrinter, bool printDefs, bool defsFirst)
        {
            // this can take some time - try to not appear hung
            int    tick_count1     = Environment.TickCount;
            int    tick_count2     = unchecked (tick_count1 + 1);
            Cursor original_cursor = Cursor.Current;

            // this is a node representing a type - get signatures of all its methods
            ILogPrinter mem_log = new LogMemoryPrinter();
            bool        first   = true;

            try
            {
                foreach (TreeNode child in node.Nodes)
                {
                    MethodDescriptor method_descr = child.Tag as MethodDescriptor;
                    if (method_descr != null)
                    {
                        if (!first)
                        {
                            codePrinter.PrintLn();
                            codePrinter.PrintLn();
                        }
                        else
                        {
                            first = false;
                        }

                        // print no messages and no definitions
                        PrintMethod(method_descr, codePrinter, mem_log, printDefs, defsFirst);

                        int ticks = Environment.TickCount;
                        if (ticks != tick_count1 && ticks != tick_count2)
                        {
                            // it's taking too long
                            tick_count1 = Environment.TickCount;
                            tick_count2 = unchecked (tick_count1 + 1);

                            Application.DoEvents();

                            // re-set the selection on rich text box controls because DoEvents may have
                            // included some undesired user input
                            richTextBoxCode.Select(richTextBoxCode.TextLength, 0);
                            richTextBoxMessages.Select(richTextBoxMessages.TextLength, 0);

                            Cursor.Current = Cursors.WaitCursor;
                        }
                    }
                }
            }
            finally
            {
                Cursor.Current = original_cursor;
            }

            logPrinter.PrintEntry(
                Severity.Info, 0,
                "Please select an individual method in the tree to view additional information.");
        }
Beispiel #3
0
        public void Print(ILogPrinter printer, string messagePrefix)
        {
            Debug.Assert(printer != null);

            foreach (LogEntry entry in Entries())
            {
                if (!String.IsNullOrEmpty(messagePrefix))
                {
                    printer.PrintEntry(entry.Severity, entry.ErrorCode,
                                       String.Format("{0}: {1}", messagePrefix, entry.Message));
                }
                else
                {
                    printer.PrintEntry(entry.Severity, entry.ErrorCode, entry.Message);
                }
            }
        }
Beispiel #4
0
        public void Print(ILogPrinter printer, string messagePrefix)
        {
            if (printer == null) throw new ArgumentNullException(nameof(printer));

            foreach (LogEntry entry in Entries())
            {
                if (!String.IsNullOrEmpty(messagePrefix))
                {
                    printer.PrintEntry(entry.Severity, entry.ErrorCode,
                        String.Format("{0}: {1}", messagePrefix, entry.Message));
                }
                else
                {
                    printer.PrintEntry(entry.Severity, entry.ErrorCode, entry.Message);
                }
            }
        }
Beispiel #5
0
        public void ReplayTo(ILogPrinter anotherPrinter)
        {
            Debug.Assert(anotherPrinter != null && anotherPrinter != this);

            foreach (Log.LogEntry entry in log.Entries())
            {
                if (entry.ErrorCode == 0)
                {
                    if (entry.Message.Length == 0)
                    {
                        anotherPrinter.Separate();
                        continue;
                    }
                    else if (entry.Message == IndentMarker)
                    {
                        anotherPrinter.Indent();
                        continue;
                    }
                    else if (entry.Message == UnindentMarker)
                    {
                        anotherPrinter.Unindent();
                        continue;
                    }
                }

                // ordinary entry
                anotherPrinter.PrintEntry(entry.Severity, entry.ErrorCode, entry.Message);
            }
        }
Beispiel #6
0
        public void Print(ILogPrinter printer, string messagePrefix)
        {
            Debug.Assert(printer != null);

            foreach (LogEntry entry in Entries())
            {
                if (!String.IsNullOrEmpty(messagePrefix))
                {
                    printer.PrintEntry(entry.Severity, entry.ErrorCode,
                        String.Format("{0}: {1}", messagePrefix, entry.Message));
                }
                else
                {
                    printer.PrintEntry(entry.Severity, entry.ErrorCode, entry.Message);
                }
            }
        }
Beispiel #7
0
 public void PrintTo(ILogPrinter logPrinter, params object[] args)
 {
     Debug.Assert(logPrinter != null);
     logPrinter.PrintEntry(Severity, ErrorCode, String.Format(Message, args));
 }
Beispiel #8
0
 public void PrintTo(ILogPrinter logPrinter, object arg1, object arg2, object arg3)
 {
     Debug.Assert(logPrinter != null);
     logPrinter.PrintEntry(Severity, ErrorCode, String.Format(Message, arg1, arg2, arg3));
 }
Beispiel #9
0
 public void PrintTo(ILogPrinter logPrinter)
 {
     Debug.Assert(logPrinter != null);
     logPrinter.PrintEntry(Severity, ErrorCode, Message);
 }
Beispiel #10
0
 public void PrintTo(ILogPrinter logPrinter, params object[] args)
 {
     if (logPrinter == null) throw new ArgumentNullException(nameof(logPrinter));
     logPrinter.PrintEntry(Severity, ErrorCode, String.Format(Message, args));
 }
Beispiel #11
0
 public void PrintTo(ILogPrinter logPrinter)
 {
     if (logPrinter == null) throw new ArgumentNullException(nameof(logPrinter));
     logPrinter.PrintEntry(Severity, ErrorCode, Message);
 }