コード例 #1
0
        /// <summary>
        /// Render a line as final markup
        /// </summary>
        /// <param name="report">Report source</param>
        /// <param name="line">The current line to format</param>
        /// <returns>final string including markup</returns>
        public virtual string SetMarkUp(DebugReport report, DebugReport.ReportLine line)
        {
            if (HasHint(line, "H1"))
            {
                line.TextMarkUp = MakeLineMulti(line, new object[] {"", "=========================================", line.Text, "=========================================" });
                return line.TextMarkUp;
            }

            if (HasHint(line, "H2"))
            {
                line.TextMarkUp = MakeLineMulti(line, new object[] { "", "----------------------------------------------------------------------------", line.Text, "----------------------------------------------------------------------------" });
                return line.TextMarkUp;
            }

            if (HasHint(line, "H3"))
            {
                line.TextMarkUp = MakeLine(line, "====== {0} ======", line.Text);
                return line.TextMarkUp;
            }

            if (HasHint(line, "H4"))
            {
                line.TextMarkUp = MakeLine(line, "---- {0} ----", line.Text);
                return line.TextMarkUp;
            }

            if (HasHint(line, "LI"))
            {
                line.TextMarkUp = MakeLine(line, "{0} o {1}", indent, line.Text);
                return line.TextMarkUp;
            }

            if (HasHint(line, "LB"))
            {
                line.TextMarkUp = MakeLine(line, line.Text);
                return line.TextMarkUp;
            }

            if (HasHint(line, "W"))
            {
                line.TextMarkUp = MakeLine(line, "*** WARNING *** {0}", line.Text);
                return line.TextMarkUp;
            }

            return MakeLine(line, line.Text);
        }
コード例 #2
0
 /// <summary>
 /// Append an existing nested report, and the current depth.
 /// </summary>
 /// <param name="nested">Nexted report to append</param>
 public void Append(DebugReport nested)
 {
     foreach(ReportLine nestedLine in nested.Report)
     {
         ReportLine newLine = new ReportLine();
         newLine.Text = nestedLine.Text;
         newLine.Depth = currentDepth + nestedLine.Depth;
         newLine.Hints = nestedLine.Hints;
         newLine.TextMarkUp = null;
         report.Add(newLine);
     }
 }
コード例 #3
0
 /// <summary>
 /// Content block (markup) at the top of the report
 /// </summary>
 /// <param name="report">context</param>
 /// <returns>markup</returns>
 public virtual string Header(DebugReport report)
 {
     return string.Empty;
 }
コード例 #4
0
        /// <summary>
        /// Helper funcation
        /// </summary>
        /// <param name="reportLine">line in question</param>
        /// <param name="parm">a numer of lines to add as a single line</param>
        /// <returns>markup text</returns>
        string MakeLineMulti(DebugReport.ReportLine reportLine,  object [] parm)
        {
            StringBuilder sb = new StringBuilder();
            foreach(object line in parm)
            {
                // Add indent
                for (int cc = 0; cc < reportLine.Depth; cc++) sb.Append(indent);

                // Add text
                if (line != null) sb.Append(line.ToString());

                // Add linebreak
                //if (parm.Length > 0 && line != parm[parm.Length-1])

                sb.Append(Environment.NewLine);

            }
            return sb.ToString();
        }
コード例 #5
0
 /// <summary>
 /// Helper function
 /// </summary>
 /// <param name="reportLine">line in question</param>
 /// <param name="format">string.format literal</param>
 /// <param name="args">parameters</param>
 /// <returns>markup text</returns>
 string MakeLine(DebugReport.ReportLine reportLine, string format, params  object [] args)
 {
     return MakeLineMulti(reportLine, format == null ? new object[] { "" } : new object[] { string.Format(format, args) } );
 }
コード例 #6
0
 /// <summary>
 /// Helper Method. Is there an additional 'hint' to provide information outside of the scope of the simple debug report content model.
 /// </summary>
 /// <param name="line"></param>
 /// <param name="hint">apply a string.IndexOf(...)</param>
 /// <returns></returns>
 protected bool HasHint(DebugReport.ReportLine line, string hint)
 {
     if (line == null) return false;
     if (line.Hints == null) return false;
     return line.Hints.IndexOf(hint) >= 0;
 }