Skip to content

Instantly share code, notes, and snippets.

@gavilanch
Created February 3, 2020 21:19
Show Gist options
  • Select an option

  • Save gavilanch/9ad720d843b6ea211f2384c870c5c867 to your computer and use it in GitHub Desktop.

Select an option

Save gavilanch/9ad720d843b6ea211f2384c870c5c867 to your computer and use it in GitHub Desktop.
using Blazor.FileReader;
using BlazorMovies.Client.Auth;
using BlazorMovies.Client.Helpers;
using BlazorMovies.Client.Repository;
using Microsoft.AspNetCore.Blazor.Hosting;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.Extensions.DependencyInjection;
using System.Threading.Tasks;
namespace BlazorMovies.Client
{
public class Program
{
public static async Task Main(string[] args)
{
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("app");
ConfigureServices(builder);
await builder.Build().RunAsync();
}
private static void ConfigureServices(WebAssemblyHostBuilder builder)
{
builder.Services.AddOptions();
builder.Services.AddTransient<IRepository, RepositoryInMemory>();
builder.Services.AddScoped<IHttpService, HttpService>();
builder.Services.AddScoped<IGenreRepository, GenreRepository>();
builder.Services.AddScoped<IPersonRepository, PersonRepository>();
builder.Services.AddScoped<IMoviesRepository, MoviesRepository>();
builder.Services.AddScoped<IAccountsRepository, AccountsRepository>();
builder.Services.AddScoped<IRatingRepository, RatingRepository>();
builder.Services.AddScoped<IDisplayMessage, DisplayMessage>();
builder.Services.AddScoped<IUsersRepository, UserRepository>();
builder.Services.AddFileReaderService(options => options.InitializeOnFirstCall = true);
builder.Services.AddAuthorizationCore();
builder.Services.AddScoped<JWTAuthenticationStateProvider>();
builder.Services.AddScoped<AuthenticationStateProvider, JWTAuthenticationStateProvider>(
provider => provider.GetRequiredService<JWTAuthenticationStateProvider>()
);
builder.Services.AddScoped<ILoginService, JWTAuthenticationStateProvider>(
provider => provider.GetRequiredService<JWTAuthenticationStateProvider>()
);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment