Esempio n. 1
0
        private void RenderReference(ReferenceSpan referenceSpan, XmlElement container)
        {
            if (referenceSpan.ResolutionException == null)
            {
                XmlElement referenceContainer = container.OwnerDocument.CreateElement("reference");
                container.AppendChild(referenceContainer);

                switch (referenceSpan.Kind)
                {
                    case ReferenceSpanKind.Link:
                        referenceContainer.SetAttribute("kind", "link");
                        break;

                    case ReferenceSpanKind.Image:
                        referenceContainer.SetAttribute("kind", "image");
                        break;
                }

                referenceContainer.SetAttribute("to", referenceSpan.Reference);

                if (referenceSpan.ChildSpan != null)
                {
                    RenderSpanInto(referenceSpan.ChildSpan, referenceContainer);
                }
            }
            else
            {
                XmlElement referenceContainer = container.OwnerDocument.CreateElement("reference-exception");
                container.AppendChild(referenceContainer);

                referenceContainer.SetAttribute("to", referenceSpan.Reference);
                referenceContainer.SetAttribute("message", referenceSpan.ResolutionException.Message);

                if (referenceSpan.ResolutionException is AdornedReferenceResolutionException)
                {
                    AdornedReferenceResolutionException ex =
                        referenceSpan.ResolutionException as AdornedReferenceResolutionException;

                    if (ex.ConsoleOutput != null)
                    {
                        string consoleText = ex.ConsoleOutput;

                        XmlElement consoleOutput = container.OwnerDocument.CreateElement("console-output");
                        referenceContainer.AppendChild(consoleOutput);

                        foreach (string line in consoleText.Split('\n'))
                        {
                            XmlElement lineElement = container.OwnerDocument.CreateElement("console-output-line");
                            consoleOutput.AppendChild(lineElement);

                            lineElement.AppendChild(container.OwnerDocument.CreateTextNode(line.TrimEnd()));
                        }
                    }
                }
            }
        }
Esempio n. 2
0
 public virtual void VisitReferenceSpan(ReferenceSpan referenceSpan)
 {
 }