示例#1
0
        static void WriteXmlDocParameter(IXmlDocOutput output, XElement xml)
        {
            foreach (var elem in xml.DescendantNodes())
            {
                if (elem is XText)
                {
                    output.Write(XmlDocRenderer.whitespace.Replace(((XText)elem).Value, " "), TextTokenType.XmlDocSummary);
                }
                else if (elem is XElement)
                {
                    var xelem = (XElement)elem;
                    switch (xelem.Name.ToString().ToUpperInvariant())
                    {
                    case "SEE":
                        var cref = xelem.Attribute("cref");
                        if (cref != null)
                        {
                            output.Write(XmlDocRenderer.GetCref((string)cref), TextTokenType.XmlDocToolTipSeeCref);
                        }
                        var langword = xelem.Attribute("langword");
                        if (langword != null)
                        {
                            output.Write(((string)langword).Trim(), TextTokenType.XmlDocToolTipSeeLangword);
                        }
                        break;

                    case "PARAMREF":
                        var nameAttr = xml.Attribute("name");
                        if (nameAttr != null)
                        {
                            output.Write(((string)nameAttr).Trim(), TextTokenType.XmlDocToolTipParamRefName);
                        }
                        break;

                    case "BR":
                    case "PARA":
                        output.WriteNewLine();
                        break;

                    default:
                        break;
                    }
                }
                else
                {
                    output.Write(elem.ToString(), TextTokenType.XmlDocSummary);
                }
            }
        }
示例#2
0
        static void WriteXmlDocParameter(IXmlDocOutput output, XElement xml)
        {
            foreach (var elem in xml.DescendantNodes())
            {
                if (elem is XText)
                {
                    output.Write(XmlDocRenderer.WhitespaceRegex.Replace(((XText)elem).Value, " "), BoxedTextColor.Text);
                }
                else if (elem is XElement xelem)
                {
                    switch (xelem.Name.ToString().ToUpperInvariant())
                    {
                    case "SEE":
                        var cref = (string?)xelem.Attribute("cref");
                        if (cref is not null)
                        {
                            output.Write(XmlDocRenderer.GetCref(cref), BoxedTextColor.Text);
                        }
                        var langword = (string?)xelem.Attribute("langword");
                        if (langword is not null)
                        {
                            output.Write(langword.Trim(), BoxedTextColor.Keyword);
                        }
                        break;

                    case "PARAMREF":
                        var nameAttr = (string?)xml.Attribute("name");
                        if (nameAttr is not null)
                        {
                            output.Write(nameAttr.Trim(), BoxedTextColor.Parameter);
                        }
                        break;

                    case "BR":
                    case "PARA":
                        output.WriteNewLine();
                        break;

                    default:
                        break;
                    }
                }
                else
                {
                    output.Write(elem.ToString(), BoxedTextColor.Text);
                }
            }
        }