Example #1
0
        /// <inheritdoc/>
        public string FormatToLink(TypeWithComment thisType, PropertyInfoWithComment property, string?displayFormat = null, string?anchorFormat = null)
        {
            string?fmt = anchorFormat ?? PropertyAnchorDefaultFormat;

            TypeWithComment declaringType = property.GetDeclaringTypeInfo();

            if (object.Equals(thisType, declaringType) || property.Info.DeclaringType.IsAssignableFrom(thisType.Info) || declaringType.Comment.IsEmpty)
            {
                string anchor = property.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), ".", property.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))));
                }
            }
        }
Example #2
0
        /// <inheritdoc/>
        public string FormatToAnchor(PropertyInfoWithComment property, string?format = null)
        {
            var fmt = format ?? PropertyAnchorDefaultFormat;

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