示例#1
0
        private async Task <EmbedBuilder> ShowMethodsAsync(EmbedBuilder eb, EmbedAuthorBuilder eab, IEnumerable <MethodInfoWrapper> list)
        {
            MethodInfoWrapper first = list.First();
            DocsHttpResult    result;
            string            pageUrl = SanitizeDocsUrl($"{first.Parent.TypeInfo.Namespace}.{first.Parent.TypeInfo.Name}");

            try
            {
                result = await GetWebDocsAsync($"{DocsUrlHandler.DocsBaseUrl}api/{pageUrl}.html", first);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                result = new DocsHttpResult($"{DocsUrlHandler.DocsBaseUrl}api/{pageUrl}.html{MethodToDocs(first)}");
            }
            eab.Name = $"Method: {first.Parent.TypeInfo.Namespace}.{first.Parent.DisplayName}.{first.Method.Name}";
            eab.Url  = result.Url;
            eb.AddField((x) =>
            {
                x.IsInline = true;
                x.Name     = "Docs:";
                x.Value    = FormatDocsUrl(eab.Url);
            });
            var githubUrl = await GithubRest.GetMethodUrlAsync(first);

            if (githubUrl != null)
            {
                eb.AddField((x) =>
                {
                    x.IsInline = true;
                    x.Name     = "Source:";
                    x.Value    = FormatGithubUrl(githubUrl);
                });
            }
            if (result.Summary != null)
            {
                eb.AddField((x) =>
                {
                    x.IsInline = false;
                    x.Name     = "Summary:";
                    x.Value    = result.Summary;
                });
            }
            if (result.Example != null)
            {
                eb.AddField((x) =>
                {
                    x.IsInline = false;
                    x.Name     = "Example:";
                    x.Value    = result.Example;
                });
            }
            int i = 1;

            eb.AddField((x) =>
            {
                x.IsInline = false;
                x.Name     = "Overloads:";
                x.Value    = String.Join("\n", list.OrderBy(y => IsInherited(y)).Select(y => $"``{i++}-``{(IsInherited(y) ? " (i)" : "")} {BuildMethod(y)}"));
            });
            return(eb);
        }