// This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();

            // Register the Swagger generator, defining 1 or more Swagger documents
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo
                {
                    Version        = "v1",
                    Title          = "ASP.NET Core Sim Connect",
                    Description    = "Backend Web API for SimConnect",
                    TermsOfService = new Uri("https://example.com/terms"),
                    Contact        = new OpenApiContact
                    {
                        Name  = "Your Name",
                        Email = string.Empty,
                        Url   = new Uri("https://twitter.com/????"),
                    },
                    License = new OpenApiLicense
                    {
                        Name = "Use under LICX",
                        Url  = new Uri("https://example.com/license"),
                    }
                });

                var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
                var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
                c.IncludeXmlComments(xmlPath);
            });

            services.AddSingleton((sp) =>
            {
                simConnectApi = new SimConnectApi();
                System.Threading.Thread.Sleep(100);
                var startTime = DateTime.UtcNow;
                while ((DateTime.UtcNow - startTime).TotalSeconds < 3) // Waits max 3 sec or when a value is returned.
                {
                    if (simConnectApi.GetNamesAndValues().Any(row => row.Value != 0))
                    {
                        break;
                    }
                    System.Threading.Thread.Sleep(100);
                }
                return(simConnectApi);
            });

            services.AddMvc().AddJsonOptions(opts =>
            {
                opts.JsonSerializerOptions.Converters.Add(new System.Text.Json.Serialization.JsonStringEnumConverter());
            });
        }
 public SimConnectController(SimConnectApi simApi)
 {
     this.simApi = simApi;
 }