12월, 2021의 게시물 표시

ASPNET 6 Web Api Basic Tutorial 2 / 2 (Swagger, SeriLog, MediatR, EntityFrameworkCore, Scrutor)

이미지
  Create Project Create Controller Add Swagger Add SeriLog Add MediatR Add EntityFramework Core Add Migration Apply Database 기타 초기화 Add Web Api  Refactoring with Extension Method 9. 기타 초기화 Scrutor 추가 개발자 프롬프트에서 프로젝트 폴더로 이동  (현재 .sln 파일이 있는 폴더라면 .csproj 파일이 있는 폴더로 이동) 아래 명령 실행 dotnet add package Scrutor Injectables 폴더 추가 Injectable.cs 추가 namespace WebApiBasicTutorial.Injectables { public interface IInjectableService { } public interface ITransientService : IInjectableService { } public interface IScopedService : IInjectableService { } public interface ISingletonService : IInjectableService { } } Program.cs 에 다음 코드 추가 using WebApiBasicTutorial.Injectables; ... ... builder.Services.Scan(scan => scan .FromAssemblies(AssemblyHelper.GetAllAssemblies()) .AddClasses(classes => classes.AssignableTo<ITransientService>()) .AsImpleme...