Skip to content

Commit

Permalink
Use top-level statements for Blazor app
Browse files Browse the repository at this point in the history
  • Loading branch information
tparviainen committed Dec 23, 2023
1 parent 5fc3505 commit fef79ff
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 81 deletions.
58 changes: 38 additions & 20 deletions src/ClashOfClans.Blazor/Program.cs
Original file line number Diff line number Diff line change
@@ -1,26 +1,44 @@
using ClashOfClans.Core;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.PlatformAbstractions;

namespace ClashOfClans.Blazor
var builder = WebApplication.CreateBuilder(args);

builder.Services.AddRazorPages();
builder.Services.AddServerSideBlazor();
builder.Services.AddClashOfClans(options =>
{
var clashOptions = new ClashOfClansOptionsV2();
builder.Configuration.GetSection(ClashOfClansOptions.ClashOfClans).Bind(clashOptions);
options.Tokens.AddRange(clashOptions.Tokens);
options.MaxRequestsPerSecond = clashOptions.MaxRequestsPerSecond;
});

var app = builder.Build();

if (app.Environment.IsDevelopment())
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}

public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((hostingContext, config) =>
{
config.SetBasePath(PlatformServices.Default.Application.ApplicationBasePath);
})
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}

app.UseHttpsRedirection();
app.UseStaticFiles();

app.UseRouting();
app.UseAuthorization();

app.MapDefaultControllerRoute();
app.MapRazorPages();
app.MapBlazorHub();

app.Run();
61 changes: 0 additions & 61 deletions src/ClashOfClans.Blazor/Startup.cs

This file was deleted.

0 comments on commit fef79ff

Please sign in to comment.