Skip to content

tarekmansour/Decorator-Pattern

Repository files navigation

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")));

About

Implement decorator pattern for caching strategy

Topics

Resources

Stars

Watchers

Forks

Languages