コード例 #1
0
        public async Task GetDocumentationAsync([Remainder] string term)
        {
            var response = await DocumentationService.GetDocumentationResultsAsync(term);

            if (response.Count == 0)
            {
                await ReplyAsync("Could not find documentation for your requested term.");

                return;
            }

            var embedCount = 0;

            foreach (var res in response.Results.Take(3).OrderBy(x => x.DisplayName))
            {
                embedCount++;

                var builder = new EmbedBuilder()
                              .WithColor(new Color(46, 204, 113))
                              .WithTitle($"{res.ItemKind}: {res.DisplayName}")
                              .WithUrl(res.Url)
                              .WithDescription(res.Description);

                if (embedCount == 3)
                {
                    builder.WithFooter(
                        new EmbedFooterBuilder().WithText($"{embedCount}/{response.Results.Count} https://docs.microsoft.com/dotnet/api/?term={term}")
                        );
                    builder.Footer.Build();
                }

                await ReplyAsync("", embed : builder.Build());
            }
        }
コード例 #2
0
 public HelpModule(CommandService service, IConfigurationRoot config, LoggingService logger, DocumentationService docService)
 {
     this.service    = service;
     this.config     = config;
     this.logger     = logger;
     this.docService = docService;
 }
コード例 #3
0
        public PartialViewResult Navigation(string id)
        {
            var builder = new DocumentationService();
            var model   = builder.Build(id);

            return(this.PartialView(model));
        }
コード例 #4
0
        // GET: Documentation
        public ActionResult Index(String id)
        {
            var builder = new DocumentationService();
            var model   = builder.Build(id);

            return(View(model));
        }
コード例 #5
0
        protected override async Task OnParametersSetAsync()
        {
            await base.OnParametersSetAsync();

            examples.Clear();
            StateHasChanged();

            document = await DocumentationService.GetComponentDocumentation(ComponentName);

            await foreach (var example in document.Examples)
            {
                examples.Add(example);
                StateHasChanged();
            }
        }
コード例 #6
0
ファイル: BackEndServer.cs プロジェクト: uvbs/LeagueClient-v2
        public static void Initialize()
        {
            var tmp = new TcpListener(IPAddress.Any, 0);

            tmp.Start();

            HostName = "localhost:" + ((IPEndPoint)tmp.LocalEndpoint).Port;

            tmp.Stop();

            var docs = new DocumentationService();

            AddService(docs);

            LogService = new LogService();
            log        = LogService.CreateLog("REST");
        }
コード例 #7
0
 public DocumentationModule(DocumentationService documentationService)
 {
     DocumentationService = documentationService;
 }
コード例 #8
0
        public async Task GetDocumentationAsync(
            [Remainder]
            [Summary("The term to search for in the documentation.")]
            string term)
        {
            Regex reg = new Regex("^[0-9A-Za-z.<>]$");

            foreach (char c in term)
            {
                if (!reg.IsMatch(c.ToString()))
                {
                    //Double the escape char so discord will print it as well
                    string s = (c == '\\') ? "\\\\" : c.ToString();
                    await ReplyAsync($" '{s}' character is not allowed in the search, please try again.");

                    return;
                }
            }

            var response = await DocumentationService.GetDocumentationResultsAsync(term);

            if (response.Count == 0)
            {
                await ReplyAsync("Could not find documentation for your requested term.");

                return;
            }

            var embedCount = 0;

            var stringBuild = new StringBuilder();

            foreach (var res in response.Results.Take(3))
            {
                embedCount++;
                stringBuild.AppendLine($"**\u276F [{res.ItemKind}: {res.DisplayName}]({res.Url})**");
                stringBuild.AppendLine($"{res.Description}");
                stringBuild.AppendLine();

                if (embedCount == 3)
                {
                    stringBuild.Append(
                        $"{embedCount}/{response.Results.Count} results shown ~ [Click Here for more results](https://docs.microsoft.com/dotnet/api/?term={term})"
                        );
                }
            }
            var buildEmbed = new EmbedBuilder()
            {
                Description = stringBuild.ToString()
            }.WithColor(new Color(46, 204, 113));

            var message = await ReplyAsync(embed : buildEmbed.Build());

            await _autoRemoveMessageService.RegisterRemovableMessageAsync(Context.User, buildEmbed, async (e) =>
            {
                await message.ModifyAsync(a =>
                {
                    a.Content = string.Empty;
                    a.Embed   = e.Build();
                });
                return(message);
            });

            await Context.Message.DeleteAsync();
        }
コード例 #9
0
 public DocumentationModule(DocumentationService documentationService,
                            IAutoRemoveMessageService autoRemoveMessageService)
 {
     DocumentationService      = documentationService;
     _autoRemoveMessageService = autoRemoveMessageService;
 }
コード例 #10
0
 public DocumentationsController(DocumentationService documentationService, IOptionsSnapshot <GlobalSettings> settings)
 {
     _documentationService = documentationService;
     _settings             = settings.Value;
 }
コード例 #11
0
        public PostmanCollection GetDiscovery()
        {
            var service = new DocumentationService();

            return(service.GetDiscovery("Scribe API", Request.RequestUri));
        }