OutputSubFolderFromNamespace() public static method

Returns the subfolder name that should be used for Amazon artifacts belonging to the specified namespace. Typically we use the service root level (the second part) in the namespace. If the namespace is not recognized as belonging to Amazon, an empty string is returned.
public static OutputSubFolderFromNamespace ( string ns ) : string
ns string The namespace of a discovered type (Amazon or 3rd party)
return string
Beispiel #1
0
        public void GetHelpURL(FrameworkVersion version, out string url, out string target)
        {
            target = "";
            url    = null;

            if (IsSystemNamespace)
            {
                // msdn urls for generic collections are not predictable, so
                // we elect to output as simple text
                if (!this.IsGenericType)
                {
                    target = "target=_new";
                    url    = string.Format(NDocUtilities.MSDN_TYPE_URL_PATTERN, this.GetDisplayName(true).ToLower());
                }
            }
            else if (IsAmazonNamespace)
            {
                // don't know if reference is to a type in folder for namespace of declaring type we're
                // processing, or in another namespace (folder), so jump to output root on the link
                url = string.Format("../{0}/{1}",
                                    GenerationManifest.OutputSubFolderFromNamespace(this.Namespace),
                                    FilenameGenerator.GenerateFilename(this));
            }
        }
Beispiel #2
0
        public string CreateReferenceHtml(bool fullTypeName)
        {
            string html;
            var    nameOrFullName = fullTypeName ? (this.FullName ?? this.Name) : this.Name;

            if (this.IsGenericParameter)
            {
                html = this.JustName;
            }
            else if (this.IsGenericType)
            {
                var fixedName = nameOrFullName.Substring(0, nameOrFullName.IndexOf('`'));
                using (var writer = new StringWriter())
                {
                    writer.Write("<a");

                    string url;
                    if (this.IsAmazonNamespace)
                    {
                        url = $"../{GenerationManifest.OutputSubFolderFromNamespace(this.Namespace)}/{FilenameGenerator.GenerateFilename(this)}";
                    }
                    else if (this.IsSystemNamespace)
                    {
                        writer.Write(" target=_new");

                        var fixedMsdnName = this.Name.Replace('`', '-');
                        url = $"https://docs.microsoft.com/en-us/dotnet/api/{this.Namespace}.{fixedMsdnName}";
                    }
                    else
                    {
                        throw new ApplicationException($"Type {this.FullName} is not a System or Amazon type, no idea how to handle its help URL");
                    }

                    writer.Write(" href=\"{0}\"", url);
                    writer.Write(">");

                    writer.Write(fixedName);
                    writer.Write("</a>");

                    writer.Write("&lt;");
                    var typeArguments = this.GenericTypeArguments();
                    for (int i = 0; i < typeArguments.Count; i++)
                    {
                        if (i != 0)
                        {
                            writer.Write(", ");
                        }
                        var typeArgument = typeArguments[i];
                        var argumentHtml = typeArgument.CreateReferenceHtml(fullTypeName);
                        writer.Write(argumentHtml);
                    }
                    writer.Write("&gt;");

                    html = writer.ToString();
                }
            }
            else if (this.IsArray)
            {
                var elementType     = this.GetElementType();
                var elementTypeHtml = elementType.CreateReferenceHtml(fullTypeName);
                html = $"{elementTypeHtml}[]";
            }
            else
            {
                string url, label, target;
                if (this.IsAmazonNamespace)
                {
                    url    = $"../{GenerationManifest.OutputSubFolderFromNamespace(this.Namespace)}/{FilenameGenerator.GenerateFilename(this)}";
                    label  = nameOrFullName;
                    target = string.Empty;
                }
                else if (this.IsSystemNamespace)
                {
                    url    = string.Format(NDocUtilities.MSDN_TYPE_URL_PATTERN, this.GetDisplayName(true).ToLower());
                    target = " target=_new";
                    label  = nameOrFullName;
                }
                else
                {
                    throw new ApplicationException($"Type {this.FullName} is not a System or Amazon type, no idea how to handle its help URL");
                }

                html = $"<a{target} href=\"{url}\">{label}</a>";
            }

            return(html);
        }