더북(TheBook)

3. DependencyInjectionDemoController.cs 컨트롤러에 AtInjectDemo() 액션 메서드를 추가한다.

▼  Controllers/DependencyInjectionDemoController.cs에 액션 메서드 추가

using DotNetNote.Services;
using Microsoft.AspNetCore.Mvc;

namespace DotNetNote.Controllers
{
  public class DependencyInjectionDemoController : Controller
  {
      private ICopyrightService _service;
      private ICopyrightService _service2;
      
      public DependencyInjectionDemoController(
          ICopyrightService service, ICopyrightService service2)
      {
          _service = service;
          _service2 = service2;
      }
      
      public IActionResult Index()
      {
          ViewBag.Copyright =
              _service.GetCopyrightString() + ”, “ +
              _service2.GetCopyrightString();
          return View();
      }
      
      public IActionResult About()
      {
          ViewBag.Copyright = _service.GetCopyrightString();
          return View();
      }
      
      public IActionResult AtInjectDemo()
      {
          return View();
      }
  }
}

신간 소식 구독하기
뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.