Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Catalog · How the catalog works
Anything · Lazarus or Delphi
Random projectRandom project

LightweightIoC

A simple and lightweight IoC container implementation

View on GitHub

Member rating

No ratings yet.

Sign in to rate this project.

README

LightweightIoC

A simple and lightweight IoC container implementation.

Example

delphi
 // Register a type
 TIoC.Container.RegisterType<IDrivable, TCar>
 
 // Register a type with a unique name
 TIoC.Container.RegisterType<IDrivable, TBicycle>('bicycle')
 
 // Resolve a component
 TIoC.Container.Resolve<IDrivable>
 
 // Resolve a component registered with a unique name
 TIoC.Container.Resolve<IDrivable>('bicycle')
 
 // Register a singleton instance
 TIoC.Container.RegisterSingleton<IDrivable>(TCar.Create)
 
 // Register a singleton instance with a unique name
 TIoC.Container.RegisterSingleton<IDrivable>(TCar.Create, 'car')