3.1 -> 5.0
@ razor
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 BlazorApp9.Data;
namespace BlazorApp9
{
public class Program
{
public static async Task Main(string[] args)
{
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("app");
builder.Services.AddScoped(
sp => new HttpClient
{ BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
//서비스 등록으로 inject 사용
// builder.Services.AddTransient(sp => new PersonService());
builder.Services.AddTransient(sp =>new SaramService());
var host = builder.Build();
var personService = host.Services.GetRequiredService<PersonService>();
//instanace
await personService.GetPeople(); // data 생성
await host.RunAsync();
await builder.Build().RunAsync();
}
}
}
무식하게 나와도 안나오는 것보단 낫지 안되는데 왜 자꾸 암튼이래
'IT > C#' 카테고리의 다른 글
[.Net교육] Day 6 설치과정 (0) | 2020.07.22 |
---|---|
[.NET 교육] Day5 오전 (0) | 2020.07.21 |
[c# 교육]day4 2 (0) | 2020.07.20 |
[C#] 상속 (0) | 2020.07.10 |
[C#] C# 클래스 확장 (0) | 2020.07.09 |