Exemplo n.º 1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();
            services.AddSingleton <RaceManager>();
            services.AddSingleton((serviceProvider) =>
            {
                AudioFilePlayerFactory audioFilePlayerFactory = new AudioFilePlayerFactory(serviceProvider.GetRequiredService <ILogger <AudioFilePlayerFactory> >());
                IAudioFilePlayer audioPlayer = audioFilePlayerFactory.CreateWavPlayer();
                return(new LapTimeAnnouncer(audioPlayer, @"Lib/Audio/WavFiles"));
            });

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo
                {
                    Version     = "v1",
                    Title       = "RaceTimer API",
                    Description = "A ASP.NET Core Web API for managing a IoT race timers",
                });

                // Set the comments path for the Swagger JSON and UI.
                var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
                var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
                c.IncludeXmlComments(xmlPath);
            });
        }
Exemplo n.º 2
0
 public LapTimeAnnouncer(IAudioFilePlayer audioFilePlayer, string audioFolderName)
 {
     _audioFilePlayer  = audioFilePlayer;
     _wavFileRetriever = new WavFileRetriever(audioFolderName);
 }