1. Trang chủ
  2. » Giáo Dục - Đào Tạo

4 asp dotnet core api building first m4 slides kho tài liệu training

14 44 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 14
Dung lượng 179,43 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

This bullet list with animations Inversion of Control and Dependency Injection Logging Creating and Using Custom Services Working with Configuration Files Coming Up... This slide is wit

Trang 1

@KevinDockx https://www.kevindockx.com

ARCHITECT

KEVIN DOCKX

Working with Services and Dependency Injection

Trang 2

This bullet list

with

animations

Inversion of Control and Dependency Injection

Logging Creating and Using Custom Services Working with Configuration Files

Coming Up

Trang 3

This slide is

with

animations

Class implementation has to change when

a dependency changes Difficult to test

Class manages the lifetime of the dependency

This is tight coupling

Inversion of Control and Dependency Injection

PointsOfInterestController

MyLogger

OtherService

uses

uses

Trang 4

Inversion of Control delegates the function of selecting a concrete implementation type for a class’s dependencies

to an external component.

Inversion of Control

Trang 5

Dependency Injection is a specialization of the Inversion

of Control pattern The Dependency Injection pattern

uses an object - the container - to initialize objects and provide the required dependencies to the object.

Dependency Injection

Trang 6

public class PointsOfInterestController :

Controller

{

private

ILogger<PointsOfInterestController>

_logger;

public PointsOfInterestController(

ILogger<PointsOfInterestController>

logger)

{

_logger = logger;

}

}

implementation

Trang 7

This slide is

with

animations

Dependency Injection is built into ASP.NET Core

ConfigureServices is used to register services with the built-in container

Inversion of Control and Dependency Injection

Trang 8

This bullet list

with

animations

Injecting and Using a Logger

Trang 9

This bullet list

with

animations

Logging to a File

Trang 10

This bullet list

with

animations

Implementing and Using a Custom Service

Trang 11

This bullet list

with

animations

Working with Configuration Files

Trang 12

This bullet list

with

animations

Scoping Configuration to Environments

Trang 13

This bullet list

with

animations

Dependency injection

- Specialization of IoC

- Loose coupling, less code changes, better testability

Summary

Trang 14

This bullet list

with

animations

Custom services are registered in ConfigureServices

- Transient

- Scoped

- Singleton

Use configuration files for configuration data, scoped to a specific environment

Summary

Ngày đăng: 17/11/2019, 08:27