GetTabTemplatesAsync() static private method

static private GetTabTemplatesAsync ( ) : Task
return Task
        public static async Task <IActionResult> DfmGetOrchestrationTabMarkupFunction(
            [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = Globals.ApiRoutePrefix + "/orchestrations('{instanceId}')/custom-tab-markup('{templateName}')")] HttpRequest req,
            string instanceId,
            string templateName,
            [DurableClient(TaskHub = Globals.TaskHubRouteParamName)] IDurableClient durableClient,
            ILogger log)
        {
            // Checking that the call is authenticated properly
            try
            {
                await Auth.ValidateIdentityAsync(req.HttpContext.User, req.Headers, durableClient.TaskHubName);
            }
            catch (Exception ex)
            {
                log.LogError(ex, "Failed to authenticate request");
                return(new UnauthorizedResult());
            }

            var status = await GetInstanceStatus(instanceId, durableClient, log);

            if (status == null)
            {
                return(new NotFoundObjectResult($"Instance {instanceId} doesn't exist"));
            }

            // The underlying Task never throws, so it's OK.
            var templatesMap = await CustomTemplates.GetTabTemplatesAsync();

            string templateCode = templatesMap.GetTemplate(status.GetEntityTypeName(), templateName);

            if (templateCode == null)
            {
                return(new NotFoundObjectResult("The specified template doesn't exist"));
            }

            try
            {
                var fluidTemplate = FluidTemplate.Parse(templateCode);
                var fluidContext  = new TemplateContext(status);

                return(new ContentResult()
                {
                    Content = fluidTemplate.Render(fluidContext),
                    ContentType = "text/html; charset=UTF-8"
                });
            }
            catch (Exception ex)
            {
                return(new BadRequestObjectResult(ex.Message));
            }
        }
        public Task <IActionResult> DfmGetOrchestrationTabMarkupFunction(
            [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = Globals.ApiRoutePrefix + "/orchestrations('{instanceId}')/custom-tab-markup('{templateName}')")] HttpRequest req,
            [DurableClient(TaskHub = Globals.HubNameRouteParamName)] IDurableClient defaultDurableClient,
            string connName,
            string hubName,
            string instanceId,
            string templateName,
            ILogger log)
        {
            return(this.HandleAuthAndErrors(defaultDurableClient, req, connName, hubName, log, async(durableClient) => {
                var status = await GetInstanceStatusWithHistory(connName, instanceId, durableClient, log);
                if (status == null)
                {
                    return new NotFoundObjectResult($"Instance {instanceId} doesn't exist");
                }

                // The underlying Task never throws, so it's OK.
                var templatesMap = await CustomTemplates.GetTabTemplatesAsync();

                string templateCode = templatesMap.GetTemplate(status.GetEntityTypeName(), templateName);
                if (templateCode == null)
                {
                    return new NotFoundObjectResult("The specified template doesn't exist");
                }

                try
                {
                    var fluidTemplate = new FluidParser().Parse(templateCode);

                    var options = new TemplateOptions();
                    options.MemberAccessStrategy.Register <JObject, object>((obj, fieldName) => obj[fieldName]);
                    options.ValueConverters.Add(x => x is JObject obj ? new ObjectValue(obj) : null);
                    options.ValueConverters.Add(x => x is JValue val ? val.Value : null);

                    string fluidResult = fluidTemplate.Render(new TemplateContext(status, options));

                    return new ContentResult()
                    {
                        Content = fluidResult,
                        ContentType = "text/html; charset=UTF-8"
                    };
                }
                catch (Exception ex)
                {
                    return new BadRequestObjectResult(ex.Message);
                }
            }));
        }