Skip to content

zhangsquared/IoC-AOP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Builder Pattern, IoC + AOP

Reinvent the wheel about IoC container and AOP

Builder Pattern

The builder pattern is a design pattern designed to provide a flexible solution to various object creation problems in object-oriented programming. The intent of the Builder design pattern is to separate the construction of a complex object from its representation. It is one of the Gang of Four design patterns.

Method 1

Vanilla method using overloaded constructors

Method 2

Factory design pattern

Method 3

Builder design pattern

Chain of Responsibility

How to build middleware pipeline

Circular Reference

ChickenService and EggService is using constructor dependency injection This will cause throwing runtime error: circular reference.

Question: How to create IoC container to enable other DI other than via constructor?

MyIoC

MyContainerV0

  1. create instance, with 1 layer of constuctor DI

MyContainerV1

  1. multiple parameters in the constructor

  2. multiple constructors (IServiceCollection will choose the super constructor, with the most parameters)

Use Attribute to mark the desired constructor, e.g. BService

  1. DI by Property, DI by method (IServiceCollection only support constructor DI)

Property attribute or method attribute

  1. how to deal with 1 interface with several implementations?

  2. how to pass a const value to constructor?

MyContainerV2

  1. life cycle support

AddTransient()

AddSingleton() --- singleton across all requests

AddScoped() --- basically singlton per request, singleton in child container

AddPerThread() --- (This is not well implemented.)

  1. IoC + AOP

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages