public async Task <IActionResult> Search([FromQuery(Name = "q"), Required] string text, int limit = 10)
        {
            if (string.IsNullOrEmpty(text))
            {
                return(new BadRequestResult());
            }

            var characters = await CharacterSearchService.FindCharactersAsync(text);

            return(new OkObjectResult
                   (
                       from codePoint in characters.Take(Math.Max(1, Math.Min(100, limit)))
                       select CodePointProvider.GetCodePoint(codePoint)
                   ));
        }
Exemple #2
0
        public IActionResult Decompose([FromBody] string text)
        {
            if (text == null || text.Length > 1024)
            {
                return(new BadRequestResult());
            }

            var characters = new List <Models.CodePoint>();

            foreach (int codePoint in new PermissiveCodePointEnumerable(text))
            {
                characters.Add(CodePointProvider.GetCodePoint(codePoint));
            }

            return(new OkObjectResult(characters));
        }
Exemple #3
0
 public IActionResult Get(string hexCodePoint)
 => !TryParseCodePoint(hexCodePoint, out int codePoint) ?
 new NotFoundResult() as IActionResult :
 new OkObjectResult(CodePointProvider.GetCodePoint(codePoint));