public override async Task <HttpHandlerResult> GetContent(HttpContext context)
        {
            await using var stream = assembly.GetManifestResourceStream(resourcePath);

            if (stream != null)
            {
                var result = new byte[stream.Length];
                await stream.ReadAsync(result, 0, result.Length);

                return(HttpHandlerResult.Binary(result, contentType));
            }

            throw new MissingManifestResourceException($"resource {resourcePath} is not found");
        }
示例#2
0
        public override async Task <HttpHandlerResult> GetContent(HttpContext context)
        {
            return(await Task.Run(() => {
                var values = stringLocalizer
                             .GetAllStrings()
                             .ToDictionary(str => str.Name, str => str.Value);

                var result = new {
                    culture = CultureInfo.CurrentUICulture.Name,
                    values
                };

                return HttpHandlerResult.Json(result);
            }));
        }