Exemplo n.º 1
0
        /// <inheritdoc/>
        public string FormatToLink(TypeWithComment thisType, EventInfoWithComment evt, string?displayFormat = null, string?anchorFormat = null)
        {
            string?fmt = anchorFormat ?? EventAnchorDefaultFormat;

            TypeWithComment declaringType = evt.GetDeclaringTypeInfo();

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

                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), ".", evt.Info.Name);

                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))));
                }
            }
        }