public async Task Get([FromQuery] FractalImageSettings input)
        {
            Console.WriteLine(input.ToString());
            var response = this.HttpContext.Response;

            // Generate the image
            var start = DateTime.Now;
            var fgen  = new MandelbrotGenerator();
            var image = fgen.Generate(input);

            Console.WriteLine($"Seconds: {(DateTime.Now - start).TotalSeconds}.");

            // Get the image properties and add them to the response header.
            var imageProperties = JsonConvert.SerializeObject(input);

            response.Headers.Add(GeneratedImagePropertiesKey, imageProperties);

            response.ContentType = MimeTypePNG;
            await response.Body.WriteAsync(image, 0, image.Length);
        }
Exemple #2
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddSingleton <IMandelbrotGenerator>(sp => MandelbrotGenerator.Create(768, 512));
     services.AddControllersWithViews();
 }