예제 #1
0
        public IEncodedString Link(DocumentedNamespace @namespace)
        {
            var builder = new EncodedStringBuilder();
            var url     = _context.UrlResolver.GetUrl(@namespace.Identity);

            builder.AppendRaw(@"<a href=""{0}"">", url);
            builder.AppendEncoded(@namespace.Identity);
            builder.AppendRaw("</a>");
            return(builder.ToRaw());
        }
예제 #2
0
        public IEncodedString Link(PropertyReference property)
        {
            var signature = property.GetPropertySignature(_context.UrlResolver);
            var builder   = new EncodedStringBuilder();

            builder.AppendRaw(@"<a href=""{0}"">", _context.UrlResolver.GetUrl(signature.Identity));
            builder.AppendEncoded(signature.Name);
            builder.AppendRaw("</a>");
            return(builder.ForceRaw());
        }
예제 #3
0
        private void Render(
            EncodedStringBuilder builder,
            ILanguageProvider language,
            TypeSignature signature,
            TypeRenderOption options,
            bool isWritingLink)
        {
            var needToCloseLink = false;
            var documentedType  = _model.FindType(signature.Identity);

            // Writing link?
            if ((options & TypeRenderOption.Link) == TypeRenderOption.Link)
            {
                if (!isWritingLink && documentedType != null)
                {
                    if (signature.Url != null)
                    {
                        isWritingLink = needToCloseLink = true;
                        builder.AppendRaw("<a href=\"{0}\">", signature.Url);
                    }
                }
            }

            // Write type namespace?
            if ((options & TypeRenderOption.Namespace) == TypeRenderOption.Namespace)
            {
                builder.AppendEncoded(signature.Namespace.Name);

                if ((options & TypeRenderOption.Namespace) == TypeRenderOption.Namespace)
                {
                    builder.AppendEncoded(".");
                }
            }

            // Write type name?
            if ((options & TypeRenderOption.Name) == TypeRenderOption.Name)
            {
                var alias = language.GetAlias(signature.Identity);
                var name  = alias ?? signature.Name;
                builder.AppendEncoded(name);
            }

            if (signature.GenericArguments.Count != 0)
            {
                // Write generic arguments.
                builder.AppendEncoded("<");
                var result = new List <string>();
                foreach (var argument in signature.GenericArguments)
                {
                    result.Add(argument);
                }
                builder.AppendEncoded(string.Join(", ", result));
                builder.AppendEncoded(">");
            }
            else if (signature.GenericParameters.Count != 0)
            {
                // Write generic parameters.
                builder.AppendEncoded("<");
                var result = new List <string>();
                foreach (var parameter in signature.GenericParameters)
                {
                    Render(builder, language, parameter, options, isWritingLink);
                }
                builder.AppendEncoded(string.Join(", ", result));
                builder.AppendEncoded(">");
            }

            // Writing link?
            if ((options & TypeRenderOption.Link) == TypeRenderOption.Link)
            {
                if (needToCloseLink)
                {
                    builder.AppendRaw("</a>");
                }
            }
        }