Created
September 19, 2020 09:49
-
-
Save sumitkharche/eae8269167f38930ad174d322fece6b7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Net.Http; | |
using System.Collections.Generic; | |
using System.Threading.Tasks; | |
using System.Text; | |
using Microsoft.AspNetCore.Components.WebAssembly.Hosting; | |
using Microsoft.Extensions.Configuration; | |
using Microsoft.Extensions.DependencyInjection; | |
using Microsoft.Extensions.Logging; | |
using BlazorCosmicBlog.Models; | |
namespace BlazorCosmicBlog | |
{ | |
public class Program | |
{ | |
public static async Task Main(string[] args) | |
{ | |
var builder = WebAssemblyHostBuilder.CreateDefault(args); | |
builder.RootComponents.Add<App>("app"); | |
builder.Services.AddTransient(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); | |
ConfigureServices(builder.Services); | |
await builder.Build().RunAsync(); | |
} | |
public static void ConfigureServices(IServiceCollection services) | |
{ | |
// Example of loading a configuration as configuration isn't available yet at this stage. | |
services.AddSingleton(provider => | |
{ | |
var config = provider.GetService<IConfiguration>(); | |
return config.GetSection("App").Get<AppSettings>(); | |
}); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment