Beispiel #1
0
        /// <inheritdoc/>
        public string FormatToLink(TypeWithComment thisType, MethodInfoWithComment method, string?displayFormat = null, string?anchorFormat = null)
        {
            string?fmt = anchorFormat ?? MethodAnchorDefaultFormat;

            TypeWithComment declaringType = method.GetDeclaringTypeInfo();

            if (object.Equals(thisType, declaringType) || method.Info.DeclaringType.IsAssignableFrom(thisType.Info) || declaringType.Comment.IsEmpty)
            {
                string anchor = method.Info.FormatToReadableSignature();

                string displayText;

                if (string.IsNullOrEmpty(displayFormat))
                {
                    displayText = System.Web.HttpUtility.HtmlEncode(anchor);
                }
                else
                {
                    displayText = ZString.Format(displayFormat, System.Web.HttpUtility.HtmlEncode(anchor));
                }

                if (string.IsNullOrEmpty(fmt))
                {
                    return(ZString.Format("[{0}](#{1})", displayText, ToAnchor(anchor)));
                }
                else
                {
                    return(ZString.Format("[{0}](#{1})", displayText, ToAnchor(ZString.Format(fmt, anchor))));
                }
            }
            else
            {
                string anchor = ZString.Concat(declaringType.Info.FormatToReadableTypeName(false), ".", method.Info.FormatToReadableSignature());

                string displayText;

                if (string.IsNullOrEmpty(displayFormat))
                {
                    displayText = System.Web.HttpUtility.HtmlEncode(anchor);
                }
                else
                {
                    displayText = ZString.Format(displayFormat, System.Web.HttpUtility.HtmlEncode(anchor));
                }

                string typeLink = ZString.Format("../{1}/{2}.md", FormatToReadableName(declaringType, false), declaringType.Namespace, declaringType.Name);

                if (string.IsNullOrEmpty(fmt))
                {
                    return(ZString.Format("[{0}]({1}#{2})", displayText, typeLink, ToAnchor(anchor)));
                }
                else
                {
                    return(ZString.Format("[{0}]({1}#{2})", displayText, typeLink, ToAnchor(ZString.Format(fmt, anchor))));
                }
            }
        }
Beispiel #2
0
        /// <inheritdoc/>
        public string FormatToAnchor(MethodInfoWithComment method, string?format = null)
        {
            var fmt = format ?? MethodAnchorDefaultFormat;

            if (string.IsNullOrEmpty(fmt))
            {
                return(FormatToReadableSignature(method));
            }
            else
            {
                return(ZString.Format(fmt, FormatToReadableSignature(method)));
            }
        }
Beispiel #3
0
 /// <inheritdoc/>
 public string FormatToReadableSignature(MethodInfoWithComment method)
 {
     return(System.Web.HttpUtility.HtmlEncode(method.Info.FormatToReadableSignature()));
 }