Exemple #1
0
        public void Visit(SeeElement element)
        {
            if (element is null)
            {
                throw new ArgumentNullException(nameof(element));
            }

            // While Visual Studio only allows referring to other code elements using the <c>cref</c> attribute,
            // linking to external resources (e.g. websites) is supported by as well using the <c>href</c> attribute.
            //
            // When a both attributes are present, the external link is ignored.

            MdSpan span;

            // <seealso /> references another assembly member
            if (element.MemberId != null)
            {
                if (element.Text.IsEmpty)
                {
                    span = m_SpanFactory.GetMdSpan(element.MemberId);
                }
                else
                {
                    var linkText = TextBlockToMarkdownConverter.ConvertToSpan(element.Text, m_SpanFactory);
                    span = m_SpanFactory.CreateLink(element.MemberId, linkText);
                }
            }
            // <seealso /> references an external resource
            else if (element.Target != null)
            {
                if (element.Text.IsEmpty)
                {
                    span = new MdLinkSpan(element.Target.ToString(), element.Target);
                }
                else
                {
                    var linkText = TextBlockToMarkdownConverter.ConvertToSpan(element.Text, m_SpanFactory);
                    span = new MdLinkSpan(linkText, element.Target);
                }
            }
            else
            {
                throw new InvalidOperationException($"Encountered instance of {nameof(SeeElement)} where both {nameof(SeeElement.MemberId)} and {nameof(SeeElement.Target)} were null.");
            }

            AddToCurrentParagraph(span);
        }
Exemple #2
0
        public void Visit(SeeElement element)
        {
            MdSpan span;

            // <seealso /> references another assembly member
            if (element.MemberId != null)
            {
                if (element.Text.IsEmpty)
                {
                    span = m_SpanFactory.GetMdSpan(element.MemberId);
                }
                else
                {
                    var linkText = TextBlockToMarkdownConverter.ConvertToSpan(element.Text, m_SpanFactory);
                    span = m_SpanFactory.CreateLink(element.MemberId, linkText);
                }
            }
            // <seealso /> references an external resource
            else if (element.Target != null)
            {
                if (element.Text.IsEmpty)
                {
                    span = new MdLinkSpan(element.Target.ToString(), element.Target);
                }
                else
                {
                    var linkText = TextBlockToMarkdownConverter.ConvertToSpan(element.Text, m_SpanFactory);
                    span = new MdLinkSpan(linkText, element.Target);
                }
            }
            else
            {
                throw new InvalidOperationException($"Encountered instance of {nameof(SeeElement)} where both {nameof(SeeElement.MemberId)} and {nameof(SeeElement.Target)} were null.");
            }
            Result.Add(span);
        }