Skip to content

Latest commit

 

History

History
19 lines (13 loc) · 761 Bytes

README.md

File metadata and controls

19 lines (13 loc) · 761 Bytes

Decorator-Pattern

  • Decorator pattern is a structural design pattern that allows you to dynamically add new behavior to an existing class, without modifying the original class.
  • It's more flexible than inheritance.
  • Supports the Single Responsibility Principle, as it allows functionality to be divided between classes with unique areas of concerns

Usage

I'm implementing the decorator pattern for caching strategy in this repository within a Product API HttpClient.

DI

register in DI when using ProductClient outside:

service.AddProductsClient(new Uri(configuration.GetValue<string>("ProductsApi:BaseUrl")));

//register cached client
service.AddCachedProductsClient(new Uri(configuration.GetValue<string>("ProductsApi:BaseUrl")));