Example #1
0
        public IActionResult Descriptor()
        {
            // This endpoint provides the descriptor for the Language Cloud to inspect and register correctly.
            // It can be implemented in any number of ways. The example implementation is to load the descriptor.json file
            // into the AddonDescriptorModel object and then serialize it as a result.
            // Alternative implementation can be generating the descriptor based on config settings, environment variables,
            // etc.
            _logger.LogInformation("Entered Descriptor endpoint.");

            // Descriptor service will provide an object describing the descriptor.
            var descriptor = _descriptorService.GetDescriptor();

            var serializerSettings = new Newtonsoft.Json.JsonSerializerSettings
            {
                NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore,
                ContractResolver  = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver(),
            };

            return(Content(Newtonsoft.Json.JsonConvert.SerializeObject(descriptor, serializerSettings), "application/json", Encoding.UTF8));
        }